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.
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');
Brief description of functions
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 from a stream:
stream.unsubscribe();
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) {
}
- Adjust function callbacks
- Update docs
MIT
Matt Razorblade Hammerstadt @mattvvhat