The Instagram Managed Source type allows you to track public posts, comments, and likes on Instagram.
The Instagram Managed Source type accesses the Instagram API on your behalf to collect data. The platform manages the collection and deduplication of data, adhering to API rate limits, and complies with authentication requirements of the Instagram API.
Each request made by the platform to Instagram must be authenticated using a valid user token. When you configure an Instagram Managed Source you provide an OAuth 2.0 Access Token issued by Instagram that is used by the platform.
For test and demonstration purposes you can use the DataSift dashboard to generate access tokens. This is the route taken by the Activate an Instagram Managed Source guide.
However, for production usage you must configure your Managed Sources via the DataSift API and provide authentication tokens which relate to an Instagram application that you have created and has been approved for production usage by Instagram.
Obtaining an Instagram access token for production applications
For production implementations, an application must be created with Instagram and approved by Instagram for production usage. Once approved, the application can be used to generate user tokens for production use and scale. How to register an application is described here.
Tokens must be approved for the “basic” and “public_content” permissions. Read more about Instagram app permissions here.
Failing to use a token generated by a production approved application results in data collection in sandbox mode. This is a test and development enviroment which enforces limitations on the number of users who can use the app, the amount of data which can be returned, and API rate limits. Full details of these limitations can be found on Instagram's Developer Site.
Your DataSift account allows you to create multiple Instagram Managed Sources. Each source will be assigned its own
id, have its own independent settings, and can be assigned one or more unique resources to track.
When you configure an Instagram source you can choose which types of interactions to receive.
All sources will receive new Instagram posts, but you can optionally choose whether to receive:
- comments relating to the posts.
- aggregated counts of likes and comments for posts.
Configure this option using the parameters argument when creating or updating the source.
Each source can be configured to track one or more unique resources. You can combine different types of resources in the same source.
Types of resource include:
- user - Track posts from a specific user
- tag - Track posts given a specific tag
- location - Track posts tagged with a specific location
Each source must have at least one valid Instagram access token. If you provide more than one access token then the source will rotate between tokens, allowing your source to consume more data. See the Managed Sources best practice guide for more details.
You configure access tokens for use by the source using the auth parameter.
A running source will ingest data from the Instagram API. Data arrives as interactions in the platform which you are able to filter against.
You can use any of the Instagram targets for your filter conditions.
Each Instagram interaction contains data about the activity published on Instagram and about the user posting that activity.
If an interaction is an Instagram comment, then it will carry additional information to associate it with the Instagram post that was commented on, such as post id, author, link, content and type.
We only monitor posts for a window of seven days. Any new comments or likes to a post that is older than seven days will not be picked up, even if that post was created after you begun running your Managed Source.
When you start your Instagram Managed Source the platform will perform an initial 'pull' of data from the Instagram API which will immediately pass through filters you have running. Data will be returned for a maximum of seven days in the past.
If you set the
trueyou will receive
like_countinteractions. These interactions are delivered periodically and summarize the number of likes for each post, including the delta in the count since the previous count for the post.
- If you set the
trueyou will receive
comment_countinteractions. These interactions are delivered periodically and summarize the number of comments for each post, including the delta in the count since the previous count for the post.
Duplicate interactions across Sources and Resources
Each source you create is independent. If you are running multiple Instagram sources then it is possible that you could receive the same interactions from multiple sources.
Similarly, if you monitor multiple Resources (Users, Tags, etc) within a single Source which all match the same Instagram interaction, you should expect to receive that interaction once per Resource.
All interactions returned from Managed Sources contain a
source object, which gives you the IDs of the Managed Source and Resource which were responsible for returning that interaction.
Read our notes on handling de-duplication here.
To get started read our Activate an Instagram Managed Source guide. This guide shows you how to create a source which you can use for testing and demo purposes.
For production usage you will need to configure sources via the API, as explained in the API step-by-step guide.
It's easy to get started with Managed Sources but there are important points to keep in mind.
Read our Managed Sources best practice guide for an overview of our recommendations.
There are some limitations caused by Instagram's API which you should be aware of:
Posts from some Instagram accounts are limited to certain geographies only. Anecdotal evidence suggests that these posts will be limited based on the location of the IP address where the request is coming from; not the location of the user who owns the access token making the request.
The Managed Sources service is currently hosted in the UK only, so we are unable to access content restricted to any regions outside of the UK.
When requesting content from users which are geo-restricted, Instagram's API will respond with the following error message:
"this user does not exist"
Posts from some Instagram accounts are limited to users of a certain age. For example, some countries enforce restrictions on a minimum age to view alcohol-related content.
Anecdotal evidence suggests that if Instagram can not determine the age of the user who generated the access token making the request, then that request will fail.
Instagram's API will return the most recent 150 comments on a post only. For this reason, we can not guarantee that we can return 100% of comments for all posts.