Giter VIP home page Giter VIP logo

node-instagram's Introduction

npm version Build Status Coverage Status Dependency Status devDependency Status Known Vulnerabilities

node-instagram

Greenkeeper badge

Instagram api client for node that support promises.

To see all endpoint available take a look at instagram developer documentation.

Install

npm install --save node-instagram

yarn add node-instagram

Usage

import Instagram from 'node-instagram';

// Create a new instance.
const instagram = new Instagram({
  clientId: 'your-client-id',
  accessToken: 'user-access-token',
});

// You can use callbacks or promises
instagram.get('users/self', (err, data) => {
  console.log(data);
});

// Get information about the owner of the access_token.
const data = await instagram.get('users/self');
console.log(data);

// Get information about a user.
instagram.get('users/:user-id').then((data) => {
  console.log(data);
});

// Get the most recent media published by the owner of the access_token.
instagram.get('users/self/media/recent').then((data) => {
  console.log(data);
});

// Get the most recent media published by a user.
instagram.get('users/:user-id/media/recent').then((data) => {
  console.log(data);
});

// Get the list of recent media liked by the owner of the access_token.
instagram.get('users/self/media/liked').then((data) => {
  console.log(data);
});

// Get a list of users matching the query.
instagram.get('users/search', { q: 'paris' }).then((data) => {
  console.log(data);
});

// Get information about this media.
instagram.get('media/:media-id').then((data) => {
  console.log(data);
});

// Get a list of users who have liked this media.
instagram.get('media/:media-id/likes').then((data) => {
  console.log(data);
});

// Set a like on this media by the currently authenticated user.
instagram.post('media/:media-id/likes').then((data) => {
  console.log(data);
});

// Remove a like on this media by the currently authenticated user.
instagram.delete('media/:media-id/likes').then((data) => {
  console.log(data);
});

// Get information about a tag object.
instagram.get('tags/:tag-name').then((data) => {
  console.log(data);
});

// Get a list of recently tagged media.
instagram.get('tags/:tag-name/media/recent').then((data) => {
  console.log(data);
});

// Search for tags by name.
instagram.get('tags/search', { q: 'paris' }).then((data) => {
  console.log(data);
});

// Handle errors
instagram.get('tags/paris').then((data) => {
  console.log(data);
}).catch((err) => {
  // An error occur
  console.log(err);
});

// Fake stream for instagram (running setInterval inside)
// Streaming can be used on all endpoints taking MIN_TAG_ID as parameter
const stream = instagram.stream('tags/:tag-name/media/recent');

stream.on('messages', (messages) => {
  console.log(messages);
});

// handle stream error
stream.on('error', (err) => {
  // An error occur
  console.log(err);
});

Api

###const instagram = new Instagram(config) Create a new Instagram instance ####Arguments

  • clientId string
  • accessToken string

###instagram.get(endpoint, [params, callback]) Make a GET request on endpoint ####Arguments

  • endpoint string
  • params object
  • callback function

###instagram.post(endpoint, [params, callback]) Make a POST request on endpoint ####Arguments

  • endpoint string
  • params object
  • callback function

###instagram.delete(endpoint, [params, callback]) Make a DELETE request on endpoint ####Arguments

  • endpoint string
  • params object
  • callback function

###instagram.stream(endpoint, params) Start a fake stream to a endpoint and return new messages found ####Arguments

  • endpoint string
  • params object
  • params.interval number interval to run inside default 10000
  • params.runOnCreation boolean run the request when creating object
  • params.minTagId boolean instagram min_tag_id to start request

node-instagram

node-instagram's People

Contributors

katawura avatar

Watchers

bolser avatar James Cloos avatar  avatar  avatar Matt Booth avatar Dave avatar Ray Smith avatar  avatar Tony avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.