Instagram API

  1. Navigate to https://developers.facebook.com/apps/

  2. Add a new app

  3. Fill in the details of "Display name" and "Contact Email"

  4. Add Instagram as a product by finding the Instagram box and click set up

  5. Fill out all of the application settings under the menu of Settings > Basic

  6. Ensure that you scroll down the page and choose "Add Platform"

  7. The platform you need is "Website" and enter the site url

  8. Navigate to Products > Instagram > Basic Settings

  9. Create a new app

  10. Add a name to your app. For example the website that you are using it on, "Welcome Italy". This will generate your APP ID and your APP secret. You will need these later.

  11. Add in the redirect URL (this can be the route), deauthorise callback URL (https://example.test/deauthorise), data deletion request url (https://example.test/data-delete). Unless you want to use these functions, these have to be urls that you will not use in your website.

  12. Click "Add or remove instagram testers"

  13. Scroll down this page and then click "Add instagram testers". In the pop up, add in the instagram username

  14. Log into instagram, navigate to the profile settings and approve the notification. This is found here

  15. From here, open your browser and navigate to the url below. This will approve the app to be able to use the api key.

    https://api.instagram.com/oauth/authorize?client_id={app-id}&redirect_uri={redirect-url}&scope=user_profile,user_media&response_type=code
    
  16. After submitting this url in the browser, this will take you to the redirect url (https://example.test) and will append the parameter ?code=. Make a note of this code, you will need it in the next steps.

  17. Open terminal.

  18. Run this command:

    curl -X POST \
      https://api.instagram.com/oauth/access_token \
      -F client_id={app-id} \
      -F client_secret={app-secret} \
      -F grant_type=authorization_code \
      -F redirect_uri={redirect-url} \
      -F code={code-from-previous-step}
    

    This will give you an access token. Make a note of this. We now need to change this into a life long token.

  19. Run this command in terminal:

      curl -i -X GET "https://graph.instagram.com/access_token?grant_type=ig_exchange_token&client_secret={app-secret}&access_token={access-token-from-previous-step}"
    
  20. This is now complete. You will get an access token in the terminal that you will need to use to perform api requests to Instagram.