InstagramJS
Javascript wrapper around Instagram API
Features
- Promise based
- No browser support (sorry, can't get excited about JSONP)
- Tested on NodeJS 6, 7, 8
Install
npm i instagramjs
Usage
All requests are made using an access token. See Authentication for a step-by-step guide on how to obtain a token.
const Instagram = const access = 'access_token'
Note: to quickly get a token for testing purposes, check out our InstAuth tool.
Global config
Below are defaults:
const access = 'access_token' baseURL: 'https://api.instagram.com/v1' fullResponse: false // true -> include status code & headers timeout: 0 // request timeout in ms
Scenarios
User
access // GET /users/self access // GET /users/id accessmedia // GET /users/id/media/recent (recent is by default) accessmedia'liked' // GET /users/self/media/liked?count=20 access // GET /users/search?q=foo
User Relationship
access // GET /users/self/follows access // GET /users/self/followed-by access // GET /users/self/requested-by access // GET /users/id/relationship access // POST /users/id/relationship?action=unfollow
Media
accessmedia'id' // GET /media/id accessmedia // GET /media/shortcode/abc accessmedia // GET /media/search?distance=1000&lat=10&lng=20
Media Comments
accessmedia'id' // GET /media/id/comments accessmedia'id' // DELETE /media/id/comments/cid
Media Likes
accessmedia'id' // GET /media/id/likes accessmedia'id' // POST /media/id/likes accessmedia'id' // DELETE /media/id/likes
Tags
access // GET /tags/name accessmedia // GET /tags/name/media/recent (recent is by default) access // GET /tags/search?q=foo
Locations
accesslocation'id' // GET /locations/id accesslocation'id'media // GET /locations/id/media/recent (recent is by default) accesslocation // GET /locations/search?distance=100&lat=5&lng=10
Request Options
As you might've noticed in the exaples, it's possible to specify query params in the request options, e. g.:
accessmedia'liked' // ?count=20
Additionaly, a full response option could be enabled for a single request:
access // Returns full response status: 200 headers: ... data: ...
If you need to specify request timeout:
access // request timeout 100ms
And, finally, combination of above:
access
Custom Request
If some of the endpoints are not available via Resource interface, it's always possible to build a custom request:
access