Instagram User Media Feed API using Deno TypeScript Runtime.
Application has Web Server and Import executables.
Setup .env file.
Http:port = 8000
Instagram:appId = 'INSTAGRAM_API'
Instagram:appSecret = 'INSTAGRAM_SECRET'
Instagram:redirectUri = "INSTAGRAM_REDIRECT_URI"
Mysql:hostname = 'MYSQL_HOSTNAME'
Mysql:username = 'MYSQL_USERNAME'
Mysql:db = 'MYSQL_DATABASE'
Mysql:port = 3306
Mysql:password = 'MYSQL_PASSWORD'
Create Database using DDL Script.
/api/ig/sync
: Route redirecting to Instagram API authorization window with defined scopesuser_profile,user_media
. After allowing permission access user is redirected to your defined Redirect URI./api/ig/auth
: Redirect URI route, which takescode
and exchanged with Access Token and then with Long-Lived Access Token. After exchange is redirected toapi/ig/user/{IGUserId}
route./api/ig/user/{userId}
: Route which returns JSON formatted user media from Mysql Database. URL Query argumentforce=true
can be used to force download from Instagram API./api/ig/user/{userId}/profile
: Route which returns basic user information.
--allow-net: string
: Mandatory valuegraph.instagram.com,api.instagram.com
for allowing server to make Instagram Graph and Api Requests + your Mysql Database IP Address and your Web IP address you want this web server to run on.--allow-read: string
: Mandatory value .env allowing server to read environment file with credentials
deno run --allow-net=graph.instagram.com,api.instagram.com,127.0.0.1:3600,0.0.0.0:8000 --allow-read=.env src/http/server.ts
If you want to periodically synchronize User Media feed database. You can execute following command via cron manager.
Import also takes care of renewing Access Token which will eventually expire in 60 days.
--allow-net: string
: Mandatory valuegraph.instagram.com,api.instagram.com
for allowing server to make Instagram Graph and Api Requests + **your Mysql Database IP Address.--allow-read: string
: Mandatory value .env allowing server to read environment file with credentials
deno run --allow-net=graph.instagram.com,api.instagram.com,127.0.0.1:3600 --allow-read=.env src/import/import.ts