Search code examples
facebook-graph-apiinstagram-apiinstagram-graph-api

Can I access instagram insights on instagram media in my backend?


after reading the instagram api documentation (actually I think it's facebook's), I found myself being more confused than before.

Basically, my users would post their media links and I'd save them in my backend, then I somehow need to access insights periodically and update the statistics in my app. What are my options? Do I need facebook login in my app and then save their access token in my backend? Is this a safety concern for them? Can I get this to work without requiring facebook login?

Nodejs for the backend and Kotlin Multiplatform for the frontend. Trying to make this process as painless as possible for the users. I just need to access the insights on their posts and not sure what the way to go is.


Solution

  • https://developers.facebook.com/docs/instagram-api/reference/ig-media/insights#requirements explains the requirements; you will have to use a user access token for these requests.

    Storing user access tokens in the backend is fine.
    Keep in mind that user access tokens expire though (even extended ones), so you probably want to implement some mechanism to alert the user when that happens, so you can send them through the login flow again to create a new one.