Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including instagram-realtime with all npm packages installed. Try it out:

var instagramRealtime = require("instagram-realtime")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

instagram-realtime v0.0.4

Event-driven, Object-oriented Instagram API Wrapper

instagram-realtime

Event-based, object-oriented Instagram API wrapper for NodeJS

That is, program instagram-related things, using an event-driven framework. Note that this adds middleware, which handles the Instagram API's subscription verification.

Minimal Example

var app     = require('express')();
var colors  = require('colors');
var server  = require('http').createServer(app).listen(process.env.PORT || 5000);

var InstagramStream = require('instagram-realtime');
var secrets = require('./secrets.json');

var stream = InstagramStream(
  server,
  {
    client_id     : secrets.client_id,
    client_secret : secrets.client_secret,
    url           : secrets.url,
    callback_path : 'callback'
  }
);

stream.on('unsubscribe', function (req, resp) {
  console.log('unsubscribe'.green);
  stream.subscribe({ tag : 'yolo' });
});

stream.on('new', function (req, body) {
  console.log(body);
});

app.get('/', function (req, resp) {
  resp.set('Content-Type', 'text/plain; charset=utf-8');
  resp.end('🍕🏊');
});

stream.unsubscribe('all');

Methods

Brief description of functions

subscribe

Subscribe to a hashtag:

stream.subscribe({ tag : 'yolo' });

Subscribe to a geographic location:

stream.subscribe({ lat:35.657872, lng:139.70232', radius:1000 });

Subscribe to a location by ID:

stream.subscribe({ location : 2345 });

Subscribe to all users registered with the app:

stream.subscribe({ user : true });

unsubscribe

Unsubscribe from a stream:

stream.unsubscribe();

on

Register a trigger for unsubscription:

stream.on('unsubscribe', function (response, body) {
}
stream.on('unsubscribe/error', function (error, response, body) {
}

Register a trigger for subscription:

stream.on('subscribe', function (response, body) {
}
stream.on('subscribe/error', function (error, response, body) {
}

Register a trigger for new media:

stream.on('new', function (response, body) {
}
stream.on('new/error', function (error, response, body) {
}

TODO

  1. Adjust function callbacks
  2. Update docs

License

MIT

Author

Matt Razorblade Hammerstadt @mattvvhat

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free