@microfox/instagram v1.2.0
Microfox Instagram SDK
A TypeScript SDK for interacting with the Instagram Graph API using OAuth 2.0.
Installation
npm install @microfox/instagramEnvironment Variables
The following environment variables are used by this SDK:
INSTAGRAM_CLIENT_ID: Your Instagram app's Client ID. Obtain this from your app's settings on the Facebook Developer platform. (Required)INSTAGRAM_CLIENT_SECRET: Your Instagram app's Client Secret. Obtain this from your app's settings on the Facebook Developer platform. Keep this value secure. (Required)INSTAGRAM_REDIRECT_URI: The OAuth redirect URI configured for your app on the Facebook Developer platform. This URI must match the one used during the OAuth flow. (Required)INSTAGRAM_ACCESS_TOKEN: The user's access token obtained through the OAuth flow. This token is used to authenticate API requests. (Required)INSTAGRAM_REFRESH_TOKEN: The user's refresh token obtained through the OAuth flow. This token is used to refresh the access token when it expires. (Required)
Additional Information
To use this SDK, you need to obtain Instagram API credentials. Follow these steps:
Create a Facebook Developer account at https://developers.facebook.com/
Create a new app or use an existing one
Add the Instagram Graph API product to your app
Set up Instagram Basic Display or Instagram Graph API
Configure your app settings, including the valid OAuth redirect URIs
Obtain your app's Client ID and Client Secret from the app dashboard
Environment variables:
INSTAGRAM_CLIENT_ID: Your Instagram app's Client ID
INSTAGRAM_CLIENT_SECRET: Your Instagram app's Client Secret
INSTAGRAM_REDIRECT_URI: The OAuth redirect URI for your app
INSTAGRAM_ACCESS_TOKEN: The user's access token (obtained through OAuth flow)
INSTAGRAM_REFRESH_TOKEN: The user's refresh token (obtained through OAuth flow)
Authentication:
This SDK uses OAuth 2.0 for authentication. You need to implement the OAuth flow in your application to obtain the initial access token and refresh token. The SDK handles token refreshing automatically.
Rate Limits:
Instagram API has rate limits that vary by endpoint. Monitor your usage and implement appropriate error handling and backoff strategies. Use the getContentPublishingLimit method to check your current rate limit status for content publishing.
Important Notes:
Always use HTTPS for API calls and redirect URIs
Keep your Client Secret and access tokens secure
Implement proper error handling in your application
Some endpoints require specific permissions. Ensure your app has the necessary permissions enabled
For video uploads, use the resumable upload process for better reliability
When working with insights, be aware of the different metrics available for media objects vs. user accounts
The oEmbed endpoint requires a separate app access token or client access token
For more detailed information, refer to the official Instagram Graph API documentation: https://developers.facebook.com/docs/instagram-api/
API Reference
For detailed documentation on the constructor and all available functions, see: