npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gramscraper

v1.0.4

Published

A simple middleware to retrieve recent photos from Instagram

Downloads

6

Readme

Gramscraper npm version License: MIT

Gramscraper is a simple middleware to retrieve recent photos from Instagram.

Registering for an Instagram access token

  1. Go to (https://www.instagram.com/developer/)
  2. Click Register Your Application
  3. Click Register a New Client
  4. Specify all the details as much as possible but the most important thing is the "Valid redirect URIs".
  5. For development purposes, just specify http://localhost:7000 (Default rails server).
  6. Click Register
  7. Notice that your CLIENT STATUS is still in "Sandbox Mode". This is ok. All you need for now is to grab your own photos and you do not need to be in "Production Mode" to do that.
  8. Once saved, copy the CLIENT ID token.
  9. Open your browser and copy this URL but replace "CLIENT-ID" and "REDIRECT-URI".
  • Format:
    https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token
  • Example:
    https://api.instagram.com/oauth/authorize/?client_id=55555555555555555555&redirect_uri=http://localhost:7000&response_type=token
  1. Whether or not you actually have localhost:7000 server started, once you open the url, the address will change to something like:
  • Format:
    http://your-redirect-uri#access_token=ACCESS-TOKEN
  • Example:
    https://api.instagram.com/v1/media/username?access_token=1234567890
  1. Copy the access_token (i.e. 1234567890) value and you're done!

Installing the Module

Using npm:

npm install gramscraper

Using yarn:

yarn add gramscraper

Basic Usage

It is easy to get gramscraper working once you have acquired an instagram access token. Refer to the instructions above on how you can get an access token.

const gramscraper = require('gramscraper')

// Replace this with your Instagram username
const username = 'goproglenn'
// Repalce this with your Instagram access token (See instructions above on how to get one)
const access_token = '1234567890'

function getPhotos() {
  // Scrape takes 2 parameters: access token and username
  gramscraper.scrape(access_token, username)
    .then(res => {
      res.map( photo => {
        // Display url for standard resolution photo
        console.log( photo.standard_resolution )
        // Display url for low resolution photo
        console.log( photo.low_resolution )
        // Display url for thumbnail
        console.log( photo.thumbnail )
        // Display the photo caption
        console.log( photo.caption )
      })
    })
}