Instagram node client
Get started
Add instagram-client to your project
npm i instagram-client
Use the instagram client
const Instagram = require("instagram-client").v1
const Client = new Instagram({
CLIENT_ID: process.env.CLIENT_ID,
CLIENT_SECRET: process.env.CLIENT_SECRET,
})
API
Classes
- Comments ⇐
Endpoint
Client.comments
Client.comments.create("MEDIAID", {
text: "some comment",
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
- Likes ⇐
Endpoint
Client.likes
Client.likes.getByMedia("MEDIAID", {
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
- Locations ⇐
Endpoint
Client.locations
Client.locations.getByID("LOCATIONID", {
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
- Media ⇐
Endpoint
Client.media
Client.media.getByID("SOMEMEDIAID", {
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
- OAuth ⇐
Endpoint
Client.oauth
Client.oauth.getAccessToken({
grantType: "",
redirectURI: "",
code: "",
})
.then(result => {})
- Subscriptions ⇐
Endpoint
Client.subscriptions
Client.subscriptions.create({
object: "",
aspect: "",
verifyToken: "",
callbackURL: "",
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
- Tags ⇐
Endpoint
Client.tags
Client.tags.getByName("travel", {
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
- Users ⇐
Endpoint
Client.users
Client.users.getSelf({
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
- V1 ⇐
InstagramClient
InstagramClient V1
const Instagram = require("instragram-client").v1
const Client = new Instagram({
CLIENT_ID: "SOMECLIENTID",
CLIENT_SECRET: "SOMECLIENTSECRET",
})
const Client = new Instagram({
CLIENT_ID: "SOMECLIENTID",
CLIENT_SECRET: "SOMECLIENTSECRET",
})
Client.comments
Client.comments.create("MEDIAID", {
text: "some comment",
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
Kind: global class
Extends: Endpoint
Creates a comment for a media by media id
Kind: instance method of Comments
Param | Type | Description |
---|
id | string | the media ID |
opts | object | the options object { accessToken, sign, text } |
cb | function | callback called if paseed, otherwise returns a promise |
Deletes a comment for a media by media id
Kind: instance method of Comments
Param | Type | Description |
---|
id | string | the media ID |
opts | object | the options object { accessToken, sign, text } |
cb | function | callback called if paseed, otherwise returns a promise |
Get comments for a media by media id
Kind: instance method of Comments
Param | Type | Description |
---|
id | string | the media ID |
opts | object | the options object { accessToken, sign, text } |
cb | function | callback called if paseed, otherwise returns a promise |
Likes ⇐ Endpoint
Client.likes
Client.likes.getByMedia("MEDIAID", {
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
Kind: global class
Extends: Endpoint
likes.getByMedia(id, opts, cb)
Gets likes for a media by media id
Kind: instance method of Likes
Param | Type | Description |
---|
id | string | the media ID |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
likes.likeMedia(id, opts, cb)
Like a media by media id with user from accessToken
Kind: instance method of Likes
Param | Type | Description |
---|
id | string | the media ID |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
likes.unlikeMedia(id, opts, cb)
Unlike a media by media id with user from accessToken
Kind: instance method of Likes
Param | Type | Description |
---|
id | string | the media ID |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
Locations ⇐ Endpoint
Client.locations
Client.locations.getByID("LOCATIONID", {
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
Kind: global class
Extends: Endpoint
locations.getByID(id, opts, cb)
Gets a location by id
Kind: instance method of Locations
Param | Type | Description |
---|
id | string | the location ID |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
locations.getMediaRecent(id, opts, cb)
Gets recent media for location by location id
Kind: instance method of Locations
Param | Type | Description |
---|
id | string | the location ID |
opts | object | the options object { accessToken, sign, maxTagID, minTagID } |
cb | function | callback called if paseed, otherwise returns a promise |
locations.search(opts, cb)
Search locations
Kind: instance method of Locations
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign, lat, lng, facebookPlacesID } |
cb | function | callback called if paseed, otherwise returns a promise |
Media ⇐ Endpoint
Client.media
Client.media.getByID("SOMEMEDIAID", {
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
Kind: global class
Extends: Endpoint
media.getByID(id, opts, cb)
Gets a media by id
Kind: instance method of Media
Param | Type | Description |
---|
id | string | the media ID |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
media.getByShortcode(id, opts, cb)
Gets a media by shortcode
Kind: instance method of Media
Param | Type | Description |
---|
id | string | the media shortcode |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
media.search(id, opts, cb)
Search media by locations
Kind: instance method of Media
Param | Type | Description |
---|
id | string | the media shortcode |
opts | object | the options object { accessToken, sign, lng, lat, distance } |
cb | function | callback called if paseed, otherwise returns a promise |
OAuth ⇐ Endpoint
Client.oauth
Client.oauth.getAccessToken({
grantType: "",
redirectURI: "",
code: "",
})
.then(result => {})
Kind: global class
Extends: Endpoint
oAuth.getAccessToken(opts, cb)
It returns the accessToken
Kind: instance method of OAuth
Param | Type | Description |
---|
opts | object | the options object { code, grantType, redirectURI } |
cb | function | callback called if paseed, otherwise returns a promise |
oAuth.getAuthURL(opts)
It returns the authURL
Kind: instance method of OAuth
Param | Type | Description |
---|
opts | object | the options object { CLIENT_ID, CLIENT_SECRET, responseType, redirectURI, scope } |
Subscriptions ⇐ Endpoint
Client.subscriptions
Client.subscriptions.create({
object: "",
aspect: "",
verifyToken: "",
callbackURL: "",
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
Kind: global class
Extends: Endpoint
subscriptions.create(opts, cb)
Creates a subscription
Kind: instance method of Subscriptions
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign, object, aspect, verifyToken, callbackURL } |
cb | function | callback called if paseed, otherwise returns a promise |
subscriptions.list(opts, cb)
Lists the subscriptions for the client
Kind: instance method of Subscriptions
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign, object, aspect, verifyToken, callbackURL } |
cb | function | callback called if paseed, otherwise returns a promise |
subscriptions.del(opts, cb)
Deletes subscriptions for the client
Kind: instance method of Subscriptions
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign, object, aspect, verifyToken, callbackURL } |
cb | function | callback called if paseed, otherwise returns a promise |
Tags ⇐ Endpoint
Client.tags
Client.tags.getByName("travel", {
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
Kind: global class
Extends: Endpoint
tags.getByName(tagName, opts, cb)
Gets a tag by name
Kind: instance method of Tags
Param | Type | Description |
---|
tagName | string | the tag name |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
tags.getMediaRecent(tagName, opts, cb)
Gets a tag's recent media by tag name
Kind: instance method of Tags
Param | Type | Description |
---|
tagName | string | the tag name |
opts | object | the options object { accessToken, sign, minTagID, maxTaxID, count } |
cb | function | callback called if paseed, otherwise returns a promise |
tags.search(tagName, opts, cb)
Searches a tag by tag name
Kind: instance method of Tags
Param | Type | Description |
---|
tagName | string | the tag name |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
Users ⇐ Endpoint
Client.users
Client.users.getSelf({
accessToken: "SOMEACCESSTOKEN",
})
.then(result => {})
Kind: global class
Extends: Endpoint
- Users ⇐
Endpoint
- .getSelf(opts, cb)
- .getSelfFollows(opts, cb)
- .getSelfFollowedBy(opts, cb)
- .getSelfRequestedBy(opts, cb)
- .getRelationshipWithUser(id, opts, cb)
- .updateRelationshipWithUser(id, opts, cb)
- .getByID(id, opts, cb)
- .getUserRecentMedia(id, opts, cb)
- .getSelfRecentMedia(opts, cb)
- .getSelfMediaLiked(opts, cb)
- .search(opts, cb)
users.getSelf(opts, cb)
Gets the user from the access token
Kind: instance method of Users
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
users.getSelfFollows(opts, cb)
Gets the users followed by the user from the access token
Kind: instance method of Users
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
users.getSelfFollowedBy(opts, cb)
Gets the user's follower of the user from the access token
Kind: instance method of Users
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
users.getSelfRequestedBy(opts, cb)
Gets the pending follow requests of the user from the access token
Kind: instance method of Users
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
users.getRelationshipWithUser(id, opts, cb)
Gets the relationship between a user and the user from the access token
Kind: instance method of Users
Param | Type | Description |
---|
id | string | the ID of the user to check the relatioship with the accessToken user |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
users.updateRelationshipWithUser(id, opts, cb)
Updates the relationship between a user and the user from the access token
Kind: instance method of Users
Param | Type | Description |
---|
id | string | the ID of the user to check the relatioship with the accessToken user |
opts | object | the options object { accessToken, sign, action } |
cb | function | callback called if paseed, otherwise returns a promise |
users.getByID(id, opts, cb)
Gets a user by ID
Kind: instance method of Users
Param | Type | Description |
---|
id | string | the ID of the user to get |
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
users.getUserRecentMedia(id, opts, cb)
Gets a user's recent media by user ID
Kind: instance method of Users
Param | Type | Description |
---|
id | string | the ID of the user to get |
opts | object | the options object { accessToken, sign, count } |
cb | function | callback called if paseed, otherwise returns a promise |
users.getSelfRecentMedia(opts, cb)
Gets a self recent media from the accessToken
Kind: instance method of Users
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
users.getSelfMediaLiked(opts, cb)
Gets a self media liked from the accessToken
Kind: instance method of Users
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign } |
cb | function | callback called if paseed, otherwise returns a promise |
Search a users
Kind: instance method of Users
Param | Type | Description |
---|
opts | object | the options object { accessToken, sign, q } |
cb | function | callback called if paseed, otherwise returns a promise |
V1 ⇐ InstagramClient
InstagramClient V1
const Instagram = require("instragram-client").v1
const Client = new Instagram({
CLIENT_ID: "SOMECLIENTID",
CLIENT_SECRET: "SOMECLIENTSECRET",
})
Kind: global class
Extends: InstagramClient
new V1(opts)
Param | Type | Description |
---|
opts | object | the options object { CLIENT_ID, CLIENT_SECRET } |
v1.get(endpoint, opts, cb)
Kind: instance method of V1
Param | Type |
---|
endpoint | string |
opts | object |
cb | function |
v1.post(endpoint, opts, formData, cb)
Kind: instance method of V1
Param | Type |
---|
endpoint | string |
opts | object |
formData | object |
cb | function |
v1.del(endpoint, opts, formData, cb)
Kind: instance method of V1
Param | Type |
---|
endpoint | string |
opts | object |
formData | object |
cb | function |