Neolithic Programming Machine

    nodegram

    0.2.3 • Public • Published

    Nodegram Build Status npm version Dependency Status

    Simplest Instagram Api library in Javascript

    Call any Instagram Api method in just 10 lines of code

    var Nodegram = require('nodegram');
    var token = 'ACCESS_TOKEN';
    var gram = new Nodegram({accessToken: token});
    var mediaOptions = {
      '{user-id}': 10499416,
      maxId: 12345,
      count: 30
    };
    var likeOptions = {
      '{media-id}': 1234
    };
     
    gram.get('/users/{user-id}/media/recent', mediaOptions).then(onSuccess).catch(onError);
    gram.post('/media/{media-id}/likes', likeOptions).then(onSuccess).catch(onError);
    gram.del('/media/{media-id}/likes', likeOptions).then(onSuccess).catch(onError);
     
    function onSuccess(res, pag) {
      console.log('onSuccess', res, pag);
    }
     
    function onError(err) {
      console.log('onError', err);
    }
     

    Authentication

    1- Retrieve auth code

    var options = {
      clientId: 'CLIENT_ID',
      clientSecret: 'CLIENT_SECRET',
      redirectUri: 'REDIRECT_URI'
    };
     
    var gram = new Nodegram(options);
    var url = gram.getAuthUrl();
     

    2- Exchange code for access_token

    var code = 'CODE';
     
    gram.getAccessToken(code).then(function(res) {
      var token = res.access_token;
     
      console.log(res.user);
    });
     

    Now, you are authenticated ^^

    var gram = new Nodegram({accessToken: token});
     
    gram.get('/users/self/media/recent').then(onSuccess).catch(onError);

    Motivation

    The problem I found while trying to use a Node Instagram library was that you have to learn:

    • The Instagram Api methods
    • The Javascript library methods

    So, in order to just learn the first point I built this simple Node.js Instagram library to comunicate with Instagram using the exactly syntax that you already now...

    Install

    npm i nodegram

    DownloadsWeekly Downloads

    8

    Version

    0.2.3

    License

    MIT

    Last publish

    Collaborators

    • zzarcon