Introduction to reading API
The instagram photo or tweet reading api is very similar to the recent twitter search API, so if you have experience with it, it shouldn’t take long to implement it.
Authentication & Configuration
You need to send a token
parameter in each request.
To get your token, please send an email to help@cool-tabs.com
Sorting and querying data
When querying content via the API, we return them in order from newest to oldest. The field used for sorting and pagination is the unique identifier (Tweet ID or or Instagram ID).
If I am asking for the most recent content than a given one, we will return them in reverse order (this is different from twitter API).
If you’re saving/processing content in any way, whenever you come to an entry that you’ve already processed, you can stop making requests to the API because the rest will always include those that you have previously processed.
The idea is that once the initial processing of all the existing data is done, each new request you have to ask only for new data that arrives.
Parameters
Parameter | Description |
---|---|
since_id | Returns content with identifier greater (more recent) than this one (excluded) |
max_id | Returns content with identifier less (older) than this one (excluded) |
Response
The API returns a JSON object with 3 possible headers:
Parameter | Description |
---|---|
data | Array of content |
pagination | Information on how to obtain the rest of the content |
error | {error: {code: error_code, message: “Error message”}} |
Monitoring list in your account
curl https://www.cool-tabs.com/api/v1/monitors.json?token=xxx
{
"data": [
{
"name": "Hashtag Twitter - #rockclimbing",
"nicename": "Hashtag Twitter - #rockclimbing",
"provider": "twitter",
"performance_type": "hashtag",
"start_date": null,
"end_date": null,
"timezone_name": "UTC",
"api_url": "https://www.cool-tabs.com/api/v1/monitors/1.json"
}
]
}
Twitter pagination example
We assume that when you start requesting data from the API there are already 5 tweets
curl https://www.cool-tabs.com/api/v1/monitors/1.json?token=xxx&limit=3&summary=true
{
"data": [
{
"id_str": "790421089738424320",
"text": "#rockclimbing #bouldering @ Desert Rocks Indoor Climbing Gym https://t.co/6ZWnCunoGW",
"hashtags": [
"rockclimbing",
"bouldering"
],
"source": "<a href=\"http://instagram.com\" rel=\"nofollow\">Instagram</a>",
"created_at": "2016-10-24T05:14:07.000Z",
"created_time": "2016-10-24T05:14:07.000Z",
"retweet_count": 0,
"user": {
"screen_name": "SteezeKitten"
}
},
{
"id_str": "790417941238059008",
"text": "RT @ClimbingBlog1: Nationals xxx Place Aaron Barrett On Outright Waivers #RockClimbing #bees https://t.co/DMRQqWUdV3",
"hashtags": [
"RockClimbing",
"bees"
],
"source": "<a href=\"http://myrt.dpl.local.antlab.co.uk/\" rel=\"nofollow\">MyRetweetUK</a>",
"created_at": "2016-10-24T05:01:37.000Z",
"created_time": "2016-10-24T05:01:37.000Z",
"retweet_count": 1,
"user": {
"screen_name": "BeeHouzz"
}
},
{
"id_str": "790417841690333185",
"text": "Texto que no hace match de categorías, pero sí de montañica",
"hashtags": [
],
"source": "<a href=\"http://instagram.com\" rel=\"nofollow\">Instagram</a>",
"created_at": "2016-10-24T08:18:00.000Z",
"created_time": "2016-10-24T08:18:00.000Z",
"retweet_count": 0,
"user": {
"screen_name": "gaizkaaaa"
}
}
],
"meta": {
"provider": "twitter",
"type": "hashtag",
"search": "#rockclimbing"
},
"pagination": {
"max_id": "790417841690333185",
"since_id": "790421089738424320",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790417841690333185"
}
}
We collect older and older tweets until there are no more left
We request the results with the max_id
parameter to request results older than this one.
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790417841690333185
{
"data": [
{
"id_str": "790416414544834561",
"text": "No filter needed. #iloveyoucalifornia #rockclimbing @ Santa Monica Mountains https://t.co/orYNysMd7z",
"hashtags": [
"iloveyoucalifornia",
"rockclimbing"
],
"source": "<a href=\"http://instagram.com\" rel=\"nofollow\">Instagram</a>",
"created_at": "2016-10-24T04:55:33.000Z",
"created_time": "2016-10-24T04:55:33.000Z",
"retweet_count": 0,
"user": {
"screen_name": "arielkbartlett"
}
},
{
"id_str": "790414268650913792",
"text": "Can't wait to use this👌🏻🎒🍂🎃⛺️🌄#newclimber #RockClimbing #avl #mountains #runnergirl #adventure https://t.co/fzzEZ85FPT",
"hashtags": [
"newclimber",
"RockClimbing",
"avl",
"mountains",
"runnergirl",
"adventure"
],
"source": "<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
"created_at": "2016-10-24T04:47:01.000Z",
"created_time": "2016-10-24T04:47:01.000Z",
"retweet_count": 0,
"user": {
"screen_name": "BreezieHannah"
}
}
],
"meta": {
"provider": "twitter",
"type": "hashtag",
"search": "#rockclimbing"
},
"pagination": {
"max_id": "790414268650913792",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790414268650913792"
}
}
We should keep asking for information because we keep getting values in response for max_id
and older_results
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790414268650913792
{
"data": [
],
"meta": {
"provider": "twitter",
"type": "hashtag",
"search": "#rockclimbing"
},
"pagination": {
"max_id": 0,
"older_results": null
}
}
This indicates that we no longer have older results.
Now that we’ve processed the first batch, we need to ask the API for any new tweets we’ve gotten since then.
To do this, if we have saved the pagination results of the first search (https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320
), we can use it .
If we have not stored it, we can use the largest tweet id that we have processed as the value of the since_id
parameter.
A) If no tweet has appeared yet, we will get:
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320
{
"data": [
],
"meta": {
"provider": "twitter",
"type": "hashtag",
"search": "#rockclimbing"
},
"pagination": {
"since_id": "790421089738424320",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320"
}
}
This indicates that we don’t have older results.
B) If new tweets have already appeared (if we have new tweets):
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320
{
"data": [
{
"id_str": "790425871316357120",
"text": "Nationals Place Aaron Barrett On Outright Waivers #RockClimbing #bees https://t.co/uUE3sRXfZ1",
"hashtags": [
"RockClimbing",
"bees"
],
"source": "<a href=\"https://www.socialoomph.com\" rel=\"nofollow\">SocialOomph</a>",
"created_at": "2016-10-24T05:33:07.000Z",
"created_time": "2016-10-24T05:33:07.000Z",
"retweet_count": 0,
"user": {
"screen_name": "ClimbingTweets1"
}
},
{
"id_str": "790440094121418752",
"text": "I've been Shunky Monkey, and this has been climbing a rock. \nOver to you.\n#Monkey #rockclimbing https://t.co/uFJACfndY8",
"hashtags": [
"Monkey",
"rockclimbing"
],
"source": "<a href=\"http://instagram.com\" rel=\"nofollow\">Instagram</a>",
"created_at": "2016-10-24T06:29:38.000Z",
"created_time": "2016-10-24T06:29:38.000Z",
"retweet_count": 0,
"user": {
"screen_name": "HalfAComic"
}
},
{
"id_str": "790440094121418753",
"text": "#RockClimbing Mobile Singko | Wall And Rock Climbing 101 - https://t.co/ryHLDWe689 #RT #Retweet https://t.co/btmtIX8H9Y",
"hashtags": [
"RockClimbing",
"RT",
"Retweet"
],
"source": "<a href=\"http://rockclimbinghq.net\" rel=\"nofollow\">Rock Climbing HQ</a>",
"created_at": "2016-10-24T06:18:42.000Z",
"created_time": "2016-10-24T06:18:42.000Z",
"retweet_count": 0,
"user": {
"screen_name": "RockClimbingHQ"
}
}
],
"meta": {
"provider": "twitter",
"type": "hashtag",
"search": "#rockclimbing"
},
"pagination": {
"max_id": "790425871316357120",
"since_id": "790440094121418753",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790440094121418753",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790425871316357120&since_id=790421089738424320"
}
}
The API now gives us the results ordered from oldest to newest starting from the most recent tweet we have.
We continue to ask for tweets with the value of the newer_results
parameter, or simply by using the since_id
.
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790440094121418753
{
"data": [
{
"id_str": "790453397988278272",
"text": "paracord bracelet, braided bracelet, urban bracelet\n\n#rockclimbing #ropebracelet #anchorbracelet #giftformen… https://t.co/Z6JB5XxEZA",
"hashtags": [
"rockclimbing",
"ropebracelet",
"anchorbracelet",
"giftformen"
],
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"created_at": "2016-10-24T07:22:30.000Z",
"created_time": "2016-10-24T07:22:30.000Z",
"retweet_count": 0,
"user": {
"screen_name": "BagsNadamlada"
}
},
{
"id_str": "790454289923727360",
"text": "chalk bag climbing, rock climbing gifts\n\n#rockclimbing #bouldering #chalkbag #giftforclimber #climbing #climbers https://t.co/l7rTYTiedc",
"hashtags": [
"rockclimbing",
"bouldering",
"chalkbag",
"giftforclimber",
"climbing",
"climbers"
],
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"created_at": "2016-10-24T07:26:03.000Z",
"created_time": "2016-10-24T07:26:03.000Z",
"retweet_count": 0,
"user": {
"screen_name": "BagsNadamlada"
}
}
],
"meta": {
"provider": "twitter",
"type": "hashtag",
"search": "#rockclimbing"
},
"pagination": {
"max_id": "790453397988278272",
"since_id": "790454289923727360",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790454289923727360",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790453397988278272&since_id=790440094121418753"
}
}
We keep asking for more recent tweets:
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790454289923727360
{
"data": [
],
"meta": {
"provider": "twitter",
"type": "hashtag",
"search": "#rockclimbing"
},
"pagination": {
"since_id": "790454289923727360",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790454289923727360"
}
}
There are no more results, but the api tells us the url to consult to obtain the new ones.
Example of complete data in a tweet
curl https://www.cool-tabs.com/api/v1/monitors/1.json?token=xxx&limit=1&summary=false
{
"data": [
{
"in_reply_to_status_id": null,
"in_reply_to_user_id_str": null,
"lang": "en",
"updated_at": "2016-10-24T09:47:59.707Z",
"text": "chalk bag climbing, rock climbing gifts\n\n#rockclimbing #bouldering #chalkbag #giftforclimber #climbing #climbers https://t.co/l7rTYTiedc",
"extended_entities": {
"media": [
{
"media_url": "http://pbs.twimg.com/media/CvhB91cWEAAQyfl.jpg",
"media_url_https": "https://pbs.twimg.com/media/CvhB91cWEAAQyfl.jpg",
"indices": [
113,
136
],
"type": "photo",
"expanded_url": "https://twitter.com/BagsNadamlada/status/790454289923727360/photo/1",
"id_str": "790454265177313280",
"url": "https://t.co/l7rTYTiedc",
"id": 790454265177313280,
"sizes": {
"medium": {
"h": 750,
"resize": "fit",
"w": 1000
},
"large": {
"w": 1000,
"h": 750,
"resize": "fit"
},
"thumb": {
"resize": "crop",
"h": 150,
"w": 150
},
"small": {
"w": 680,
"h": 510,
"resize": "fit"
}
},
"display_url": "pic.twitter.com/l7rTYTiedc"
}
]
},
"retweet_count": 0,
"favorite_count": 0,
"created_at": "2016-10-24T07:26:03.000Z",
"entities": {
"user_mentions": [
],
"media": [
{
"media_url": "http://pbs.twimg.com/media/CvhB91cWEAAQyfl.jpg",
"media_url_https": "https://pbs.twimg.com/media/CvhB91cWEAAQyfl.jpg",
"indices": [
113,
136
],
"sizes": {
"thumb": {
"resize": "crop",
"h": 150,
"w": 150
},
"small": {
"h": 510,
"resize": "fit",
"w": 680
},
"large": {
"resize": "fit",
"h": 750,
"w": 1000
},
"medium": {
"w": 1000,
"h": 750,
"resize": "fit"
}
},
"display_url": "pic.twitter.com/l7rTYTiedc",
"type": "photo",
"expanded_url": "https://twitter.com/BagsNadamlada/status/790454289923727360/photo/1",
"url": "https://t.co/l7rTYTiedc",
"id_str": "790454265177313280",
"id": 790454265177313280
}
],
"urls": [
],
"hashtags": [
{
"text": "rockclimbing",
"indices": [
41,
54
]
},
{
"indices": [
55,
66
],
"text": "bouldering"
},
{
"indices": [
67,
76
],
"text": "chalkbag"
},
{
"text": "giftforclimber",
"indices": [
77,
92
]
},
{
"text": "climbing",
"indices": [
93,
102
]
},
{
"indices": [
103,
112
],
"text": "climbers"
}
],
"symbols": [
]
},
"id_str": "790454289923727360",
"in_reply_to_screen_name": null,
"coordinates": null,
"place": null,
"contributors": null,
"in_reply_to_status_id_str": null,
"created_time": "2016-10-24T07:26:03.000Z",
"truncated": false,
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"possibly_sensitive": false,
"is_quote_status": false,
"in_reply_to_user_id": null,
"geo": null,
"metadata": {
"result_type": "recent",
"iso_language_code": "en"
},
"engagement": 0,
"hashtags": [
"rockclimbing",
"bouldering",
"chalkbag",
"giftforclimber",
"climbing",
"climbers"
],
"kind": "tweet",
"user": {
"_id": 726624842171174912,
"friends_count": 26,
"profile_background_color": "F5F8FA",
"profile_sidebar_fill_color": "DDEEF6",
"has_extended_profile": false,
"lang": "en",
"profile_sidebar_border_color": "C0DEED",
"ggender": "nodata",
"favourites_count": 26,
"time_zone": "Pacific Time (US & Canada)",
"utc_offset": -25200,
"screen_name": "BagsNadamlada",
"translator_type": "none",
"created_at": "Sun May 01 04:10:37 +0000 2016",
"entities": {
"url": {
"urls": [
{
"display_url": "etsy.com/shop/ChalkBags…",
"indices": [
0,
23
],
"url": "https://t.co/C08BfWfycC",
"expanded_url": "http://www.etsy.com/shop/ChalkBagsNadamlada/items"
}
]
},
"description": {
"urls": [
]
}
},
"profile_background_image_url_https": null,
"listed_count": 16,
"profile_link_color": "2B7BB9",
"geo_enabled": false,
"following": false,
"location": "Bulgaria",
"profile_background_image_url": null,
"profile_image_url": "http://pbs.twimg.com/profile_images/726656733872017408/ITO-Kkoc_normal.jpg",
"statuses_count": 215,
"protected": false,
"profile_background_tile": false,
"is_translation_enabled": false,
"id_str": "726624842171174912",
"profile_text_color": "333333",
"contributors_enabled": false,
"name": "Chalk Bags Nadamlada",
"verified": false,
"is_translator": false,
"default_profile": true,
"profile_banner_url": "https://pbs.twimg.com/profile_banners/726624842171174912/1462083368",
"profile_use_background_image": true,
"follow_request_sent": false,
"description": "Handmade chalk bags for rock climbing and bouldering",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/726656733872017408/ITO-Kkoc_normal.jpg",
"default_profile_image": false,
"url": "https://t.co/C08BfWfycC",
"followers_count": 31,
"notifications": false
},
"id": 790454289923727360
}
],
"meta": {
"provider": "twitter",
"type": "hashtag",
"search": "#rockclimbing"
},
"pagination": {
"max_id": "790454289923727360",
"since_id": "790454289923727360",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=1&summary=false&token=xxx&since_id=790454289923727360",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=1&summary=false&token=xxx&max_id=790454289923727360"
}
}
Instagram pagination example
We assume that when you start requesting data from the API there are already 5 photos
curl https://www.cool-tabs.com/api/v1/monitors/1.json?token=xxx&limit=3
{
"data": [
{
"likes": {
"count": 129
},
"tags": [
"perseids",
"perseidmeteorshower",
"leninpeak"
],
"comments": {
"count": 3
},
"videos": {
"standard_resolution": {
"url": "https://video-cdt1-1.cdninstagram.com/v/t50.2886-16/237425298_116829364019682_3671853028205300281_n.mp4?_nc_cat=101&vs=17995718869363541_971928881&_nc_vs=HBksFQAYJEdKTFNKZzdpNGIxMFFXb0FBRG1LbnZYZkN2VXlia1lMQUFBRhUAAsgBABUAGCRHQlhXUHc3RFVydkk2dVFCQUVmNFgwN1dRUGhJYmtZTEFBQUYVAgLIAQAoABgAGwGIB3VzZV9vaWwBMRUAACaw57HZpbrZPxUCKAJDMywXQCIzMzMzMzMYEmRhc2hfYmFzZWxpbmVfMV92MREAdeoHAA%3D%3D&ccb=1-5&_nc_sid=59939d&efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5mZWVkIn0%3D&_nc_ohc=G9ROyQonrnMAX8EQEgR&_nc_ht=video-cdt1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=94f7037c857277a6d752559eb76a4d4a&oe=611C88A6&_nc_rid=05da3ea126"
}
},
"idl": 17878014809438129,
"words": [
"base",
"camp",
"business",
"under",
"the",
"epic",
"meteor",
"showers",
"of",
"august",
"#perseids",
"#perseidmeteorshower",
"#leninpeak"
],
"link": "https://www.instagram.com/p/CSriKHIAbsl/",
"caption": {
"text": "base camp business under the epic meteor showers of august ✨🪐⛺️💫 \n#perseids #perseidmeteorshower #leninpeak"
},
"failed_to_cache_to_s3": true,
"created_time": "2021-08-17T15:22:56.000Z",
"type": "video",
"id": "17878014809438129"
},
{
"idl": 17876535116474961,
"words": [
"pour",
"ceux",
"qui",
"pensent",
"que",
"je",
"ne",
"sort",
"jamais",
"du",
"gymnase",
"david",
"machet",
"photographe",
"david_machet_photographe"
],
"tags": [
],
"comments": {
"count": 6
},
"likes": {
"count": 564
},
"link": "https://www.instagram.com/p/CSrt1G-DSIw/",
"caption": {
"text": "Pour ceux qui pensent que je ne sort jamais du gymnase !!??\n📸 david_machet_photographe"
},
"cached_to_s3": true,
"created_time": "2021-08-17T16:58:22.000Z",
"images": {
"standard_resolution": {
"orig_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/239328083_1735083803347432_3089893753465375856_n.jpg?_nc_cat=110&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=JTf6NG6Ka_IAX_bWfyE&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=a8cf40060bba7dbde804a3dc24c668ed&oe=612049F1",
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17876535116474961/b4aab3692d19f884/17876535116474961-standard_resolution.jpg"
},
"thumbnail": {
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17876535116474961/b4aab3692d19f884/17876535116474961-thumbnail.jpg",
"orig_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/239328083_1735083803347432_3089893753465375856_n.jpg?_nc_cat=110&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=JTf6NG6Ka_IAX_bWfyE&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=a8cf40060bba7dbde804a3dc24c668ed&oe=612049F1"
}
},
"type": "image",
"id": "17876535116474961"
},
{
"created_time": "2021-08-17T13:17:33.000Z",
"failed_to_cache_to_s3": true,
"type": "video",
"likes": {
"count": 64
},
"words": [
],
"idl": 17874017927490424,
"tags": [
],
"videos": {
"standard_resolution": {
"url": "https://video-cdt1-1.cdninstagram.com/v/t50.16885-16/238918740_128585139488173_5609812480488923558_n.mp4?_nc_cat=109&vs=17900655389180013_106433389&_nc_vs=HBksFQAYJEdGU2NQUTZ0QlpDUDhuUUFBS1poR0p5NkR0cE5idlZCQUFBRhUAAsgBABUAGCRHUFdyUlE3ZWxhYnd4Q1FCQUR5b3NTWVVuazVqYnZWQkFBQUYVAgLIAQAoABgAGwGIB3VzZV9vaWwBMRUAACa0j9fAtv%2ByQBUCKAJDMywXQDTdsi0OVgQYEmRhc2hfYmFzZWxpbmVfMV92MREAdewHAA%3D%3D&ccb=1-5&_nc_sid=59939d&efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5pZ3R2In0%3D&_nc_ohc=cWTOsXmg4yoAX9bGQ--&_nc_ht=video-cdt1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=647519ea09d147102741026c46a67e69&oe=611C3E2A&_nc_rid=e2d466f17a"
}
},
"comments": {
"count": 4
},
"caption": {
"text": "원데이 단 하나!\n一天限制问题只有一个。"
},
"link": "https://www.instagram.com/tv/CSrUhH7JgPT/",
"id": "17874017927490424"
}
],
"meta": {
"provider": "instagram",
"type": "hashtag_fbapi",
"search": "rockclimbing"
},
"pagination": {
"max_id": "17874017927490424",
"since_id": "17878014809438129",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17878014809438129",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&max_id=17874017927490424"
}
}
We should collect older and older photos until there are no more
We request the results with the max_id
parameter to request results older than this one.
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&max_id=17874017927490424
{
"data": [
{
"link": "https://www.instagram.com/p/CSq-4CGpT3R/",
"caption": {
"text": "Exciting things coming this Saturday! 🤫🤫\n#globalclimbingday #wallsaremeantforclimbing"
},
"cached_to_s3": true,
"words": [
"exciting",
"things",
"coming",
"this",
"saturday",
"#globalclimbingday",
"#wallsaremeantforclimbing"
],
"idl": 17857310030584628,
"comments": {
"count": 3
},
"tags": [
"globalclimbingday",
"wallsaremeantforclimbing"
],
"likes": {
"count": 45
},
"type": "carousel",
"children": {
"data": [
{
"id": "17961331741439004",
"media_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/237119169_1093031701518443_7568933520323543621_n.jpg?_nc_cat=100&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=Rz6ECqkQGoYAX9eyLyk&_nc_ht=scontent-lcy1-1.cdninstagram.com&oh=73c2876337c2e92ef2470234e4613ad2&oe=61203243"
},
{
"id": "17886611627385725",
"media_url": "https://video-lcy1-1.cdninstagram.com/v/t50.2886-16/237701438_990298491822642_6351788071500567608_n.mp4?_nc_cat=103&vs=17908023089057809_961241942&_nc_vs=HBkcFQAYJEdENEpLdzR5b3RQVnE0UURBRGpVV2dxWkZTWllia1lMQUFBRhUAAsgBACgAGAAbAYgHdXNlX29pbAExFQAAJp74xYbM%2Fc8%2FFQIoAkMzLBdABqn752yLRBgSZGFzaF9iYXNlbGluZV8xX3YxEQB17gcA&ccb=1-5&_nc_sid=59939d&efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5jYXJvdXNlbF9pdGVtIn0%3D&_nc_ohc=iOb8-r3IYr4AX_qOvUv&_nc_ht=video-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=b4928a25bec0d90abe0e3b2d6b2e92b6&oe=611C9B51&_nc_rid=1d2f61bc5c"
}
]
},
"created_time": "2021-08-17T10:08:05.000Z",
"images": {
"thumbnail": {
"orig_url": "https://scontent-cdg2-1.cdninstagram.com/v/t51.29350-15/237119169_1093031701518443_7568933520323543621_n.jpg?_nc_cat=100&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=Rz6ECqkQGoYAX9eyLyk&_nc_ht=scontent-cdg2-1.cdninstagram.com&oh=84a5a69b220f43c95606ac1daf17e4d1&oe=61203243",
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17857310030584628/ba5fe1db65109d6a/17857310030584628-thumbnail.jpg"
},
"standard_resolution": {
"orig_url": "https://scontent-cdg2-1.cdninstagram.com/v/t51.29350-15/237119169_1093031701518443_7568933520323543621_n.jpg?_nc_cat=100&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=Rz6ECqkQGoYAX9eyLyk&_nc_ht=scontent-cdg2-1.cdninstagram.com&oh=84a5a69b220f43c95606ac1daf17e4d1&oe=61203243",
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17857310030584628/ba5fe1db65109d6a/17857310030584628-standard_resolution.jpg"
}
},
"id": "17857310030584628"
},
{
"likes": {
"count": 77
},
"videos": {
"standard_resolution": {
"url": "https://video-cdg2-1.cdninstagram.com/v/t50.2886-16/238923210_514612529834946_8079609550451122844_n.mp4?_nc_cat=111&vs=17959420027462843_3683427756&_nc_vs=HBksFQAYJEdNcXRQUTdDcXdtUkNkUUJBSndpZmhvVWlpQndia1lMQUFBRhUAAsgBABUAGCRHTkxYT2c1end5cnJMZmNBQVBhWW1uenpreXNWYmtZTEFBQUYVAgLIAQAoABgAGwGIB3VzZV9vaWwBMRUAACb%2B0bLkwrPMPxUCKAJDMywXQDzu2RaHKwIYEmRhc2hfYmFzZWxpbmVfMV92MREAdeoHAA%3D%3D&ccb=1-5&_nc_sid=59939d&efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5mZWVkIn0%3D&_nc_ohc=na1K3fXhRjwAX9h4yuf&_nc_ht=video-cdg2-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=c3fcaa72cf8c26f19d2c7ffb4c56000b&oe=611C5A55&_nc_rid=e622b8150b"
}
},
"tags": [
],
"comments": {
"count": 2
},
"words": [
"growth",
"requires",
"change",
"change",
"requires",
"effort",
"and",
"effort",
"requires",
"us",
"to",
"put",
"ourselves",
"first"
],
"idl": 17842855370641865,
"caption": {
"text": "Growth requires change. Change requires effort. And effort requires us to put ourselves first ✨💛"
},
"link": "https://www.instagram.com/p/CSrPYrblRyU/",
"failed_to_cache_to_s3": true,
"created_time": "2021-08-17T12:39:19.000Z",
"type": "video",
"id": "17842855370641865"
}
],
"meta": {
"provider": "instagram",
"type": "hashtag_fbapi",
"search": "rockclimbing"
},
"pagination": {
"max_id": "17842855370641865",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&max_id=17842855370641865"
}
}
We should keep asking for information because we keep getting values in response for max_id
and older_results
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&max_id=17842855370641865
{
"data": [
],
"meta": {
"provider": "instagram",
"type": "hashtag_fbapi",
"search": "rockclimbing"
},
"pagination": {
"max_id": 0,
"older_results": null
}
}
This indicates that we no longer have older results.
Now that we’ve processed the first batch, we need to ask the API for any new photos we’ve gotten since then.
To do this, if we have saved the pagination results of the first search (https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17878014809438129
), we can use it .
If we have not stored it, we can use the largest photo id that we have processed as the value of the since_id
parameter.
A) If no photo has appeared yet, we will get:
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17878014809438129
{
"data": [
],
"meta": {
"provider": "instagram",
"type": "hashtag_fbapi",
"search": "rockclimbing"
},
"pagination": {
"since_id": "17878014809438129",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17878014809438129"
}
}
This indicates that we don’t have older results.
B) If photos have already appeared (if we have new photos):
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17878014809438129
{
"data": [
{
"words": [
"heel",
"heel",
"baby"
],
"idl": 17878041938449185,
"tags": [
],
"videos": {
"standard_resolution": {
"url": "https://video-cdt1-1.cdninstagram.com/v/t50.31694-16/237566612_580388943303536_7855892946767643749_n.mp4?_nc_cat=110&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=0V1YSDk-2QcAX8_4KmB&_nc_oc=AQkwz0Jag78rs5tfBT-q9bqUrOHrvENl1Go57547w-FhyrTPYhogLGI6dtw3gXUQ4ZM&_nc_ht=video-cdt1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=a590567888fed588dfc73bd634aabbde&oe=611C6505"
}
},
"comments": {
"count": 4
},
"likes": {
"count": 41
},
"caption": {
"text": "Heel, heel, baby"
},
"link": "https://www.instagram.com/p/CSrd19fHl-l/",
"created_time": "2021-08-17T14:39:34.000Z",
"failed_to_cache_to_s3": true,
"type": "video",
"id": "17878041938449185"
},
{
"idl": 17878375730445337,
"words": [
"red",
"rock",
"kenziebishplease"
],
"tags": [
],
"comments": {
"count": 2
},
"likes": {
"count": 15
},
"link": "https://www.instagram.com/p/CSrxrGPM9ZA/",
"caption": {
"text": "Red Rock 🧗 \n\n📸 kenziebishplease"
},
"cached_to_s3": true,
"created_time": "2021-08-17T17:31:58.000Z",
"images": {
"thumbnail": {
"orig_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/237748893_833197127569137_3015389684338383734_n.jpg?_nc_cat=109&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=mvrgm5wLtpkAX_RrJcB&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=7365b27085d82d88d251ab12f5057407&oe=6121A9F7",
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17878375730445337/ca3f52c5b027ad1b/17878375730445337-thumbnail.jpg"
},
"standard_resolution": {
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17878375730445337/ca3f52c5b027ad1b/17878375730445337-standard_resolution.jpg",
"orig_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/237748893_833197127569137_3015389684338383734_n.jpg?_nc_cat=109&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=mvrgm5wLtpkAX_RrJcB&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=7365b27085d82d88d251ab12f5057407&oe=6121A9F7"
}
},
"type": "image",
"id": "17878375730445337"
},
{
"tags": [
],
"comments": {
"count": 8
},
"words": [
"stop",
"pressuring",
"me",
"to",
"like",
"trad",
"trad-",
"crack",
"climbing",
"sucks",
"and",
"it",
"hurts",
"-",
"said",
"the",
"girl",
"who",
"ended",
"up",
"low",
"key",
"liking",
"it"
],
"idl": 17886255428321648,
"likes": {
"count": 106
},
"link": "https://www.instagram.com/p/CSr0Z67JR2R/",
"caption": {
"text": "“Stop pressuring me to like trad- crack climbing SUCKS and it hurts” - said the girl who ended up low key liking it 😏"
},
"cached_to_s3": true,
"images": {
"standard_resolution": {
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17886255428321648/b185a2a5563ed311/17886255428321648-standard_resolution.jpg",
"orig_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/238425042_2688736814758833_3058709461560242388_n.jpg?_nc_cat=104&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=PnJXdGTnABcAX-1T_7k&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=4564a777665d5d3960e60d87e19ab287&oe=6121FE2D"
},
"thumbnail": {
"orig_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/238425042_2688736814758833_3058709461560242388_n.jpg?_nc_cat=104&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=PnJXdGTnABcAX-1T_7k&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=4564a777665d5d3960e60d87e19ab287&oe=6121FE2D",
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17886255428321648/b185a2a5563ed311/17886255428321648-thumbnail.jpg"
}
},
"created_time": "2021-08-17T17:55:50.000Z",
"type": "image",
"id": "17886255428321648"
}
],
"meta": {
"provider": "instagram",
"type": "hashtag_fbapi",
"search": "rockclimbing"
},
"pagination": {
"max_id": "17878041938449185",
"since_id": "17886255428321648",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17886255428321648",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&max_id=17878041938449185&since_id=17878014809438129"
}
}
The API now gives us the results ordered from oldest to newest starting from the most recent photo we have.
We should continue asking for photos with the value of the newer_results
parameter, or simply by using the since_id
.
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17886255428321648
{
"data": [
{
"type": "image",
"images": {
"thumbnail": {
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17889120983477205/6672ca6e274a42b6/17889120983477205-thumbnail.jpg",
"orig_url": "https://scontent-cdg2-1.cdninstagram.com/v/t51.29350-15/239034503_105425438469071_2636005728629980176_n.jpg?_nc_cat=102&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=Nk6xnlrEf6MAX9vx-Eo&_nc_ht=scontent-cdg2-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=df12d0b95c819bd4aefb41023c2b8426&oe=61219310"
},
"standard_resolution": {
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17889120983477205/6672ca6e274a42b6/17889120983477205-standard_resolution.jpg",
"orig_url": "https://scontent-cdg2-1.cdninstagram.com/v/t51.29350-15/239034503_105425438469071_2636005728629980176_n.jpg?_nc_cat=102&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=Nk6xnlrEf6MAX9vx-Eo&_nc_ht=scontent-cdg2-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=df12d0b95c819bd4aefb41023c2b8426&oe=61219310"
}
},
"created_time": "2021-08-17T15:33:17.000Z",
"cached_to_s3": true,
"caption": {
"text": "Identifiez votre partenaire de grimpe pour essayer de gagner un ensemble pour deux 😬"
},
"link": "https://www.instagram.com/p/CSrkF34jzWW/",
"likes": {
"count": 0
},
"tags": [
],
"comments": {
"count": 1
},
"words": [
"identifiez",
"votre",
"partenaire",
"de",
"grimpe",
"pour",
"essayer",
"de",
"gagner",
"un",
"ensemble",
"pour",
"deux"
],
"idl": 17889120983477205,
"id": "17889120983477205"
},
{
"type": "carousel",
"images": {
"thumbnail": {
"orig_url": "https://scontent-cdt1-1.cdninstagram.com/v/t51.29350-15/238414098_356451672842714_5428161640385892000_n.jpg?_nc_cat=105&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=xEWCeUU3a-UAX-1lyAX&_nc_ht=scontent-cdt1-1.cdninstagram.com&oh=4307afb7c5a273bff27ef3ff99ccd4ef&oe=61211AB6",
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17891590679240585/ddb99787618cc22d/17891590679240585-thumbnail.jpg"
},
"standard_resolution": {
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17891590679240585/ddb99787618cc22d/17891590679240585-standard_resolution.jpg",
"orig_url": "https://scontent-cdt1-1.cdninstagram.com/v/t51.29350-15/238414098_356451672842714_5428161640385892000_n.jpg?_nc_cat=105&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=xEWCeUU3a-UAX-1lyAX&_nc_ht=scontent-cdt1-1.cdninstagram.com&oh=4307afb7c5a273bff27ef3ff99ccd4ef&oe=61211AB6"
}
},
"created_time": "2021-08-17T15:17:21.000Z",
"children": {
"data": [
{
"id": "18057740833289929",
"media_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/238414098_356451672842714_5428161640385892000_n.jpg?_nc_cat=105&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=xEWCeUU3a-UAX-1lyAX&_nc_ht=scontent-lcy1-1.cdninstagram.com&oh=ec85e8cb7646e81e0d28040b6fc757d0&oe=61211AB6"
},
{
"id": "17856117848615196",
"media_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/238342467_360785835721064_8697903678875504425_n.jpg?_nc_cat=105&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=yi3KGRnuJrsAX8ha6T_&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=2cc954e13f7c0b238738cbd67ad41715&oe=61203408"
},
{
"id": "17917208857807123",
"media_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/238506160_849469739030953_6598130759133178944_n.jpg?_nc_cat=100&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=JCqfdQg4KQMAX-y01Yj&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=e41066405415e052d0f18604154241df&oe=61219F50"
}
]
},
"cached_to_s3": true,
"link": "https://www.instagram.com/p/CSriRJbsJqK/",
"caption": {
"text": "Petit tour à Ljubljana 🇸🇮🐉"
},
"likes": {
"count": 1288
},
"comments": {
"count": 8
},
"tags": [
],
"words": [
"petit",
"tour",
"a",
"ljubljana"
],
"idl": 17891590679240585,
"id": "17891590679240585"
}
],
"meta": {
"provider": "instagram",
"type": "hashtag_fbapi",
"search": "rockclimbing"
},
"pagination": {
"max_id": "17889120983477205",
"since_id": "17891590679240585",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17891590679240585",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&max_id=17889120983477205&since_id=17886255428321648"
}
}
We keep asking for more recent photos:
curl https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17891590679240585
{
"data": [
],
"meta": {
"provider": "instagram",
"type": "hashtag_fbapi",
"search": "rockclimbing"
},
"pagination": {
"since_id": "17891590679240585",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=3&token=xxx&since_id=17891590679240585"
}
}
There are no more results, but the api tells us the url to consult to obtain the new ones.
Example of complete data in an instagram photo/video
curl https://www.cool-tabs.com/api/v1/monitors/1.json?token=xxx&limit=1
{
"data": [
{
"type": "carousel",
"images": {
"thumbnail": {
"orig_url": "https://scontent-cdt1-1.cdninstagram.com/v/t51.29350-15/238414098_356451672842714_5428161640385892000_n.jpg?_nc_cat=105&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=xEWCeUU3a-UAX-1lyAX&_nc_ht=scontent-cdt1-1.cdninstagram.com&oh=4307afb7c5a273bff27ef3ff99ccd4ef&oe=61211AB6",
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17891590679240585/ddb99787618cc22d/17891590679240585-thumbnail.jpg"
},
"standard_resolution": {
"url": "https://cool-tabs-eu.s3.eu-west-1.amazonaws.com/ctigc/17/17891590679240585/ddb99787618cc22d/17891590679240585-standard_resolution.jpg",
"orig_url": "https://scontent-cdt1-1.cdninstagram.com/v/t51.29350-15/238414098_356451672842714_5428161640385892000_n.jpg?_nc_cat=105&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=xEWCeUU3a-UAX-1lyAX&_nc_ht=scontent-cdt1-1.cdninstagram.com&oh=4307afb7c5a273bff27ef3ff99ccd4ef&oe=61211AB6"
}
},
"created_time": "2021-08-17T15:17:21.000Z",
"children": {
"data": [
{
"id": "18057740833289929",
"media_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/238414098_356451672842714_5428161640385892000_n.jpg?_nc_cat=105&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=xEWCeUU3a-UAX-1lyAX&_nc_ht=scontent-lcy1-1.cdninstagram.com&oh=ec85e8cb7646e81e0d28040b6fc757d0&oe=61211AB6"
},
{
"id": "17856117848615196",
"media_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/238342467_360785835721064_8697903678875504425_n.jpg?_nc_cat=105&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=yi3KGRnuJrsAX8ha6T_&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=2cc954e13f7c0b238738cbd67ad41715&oe=61203408"
},
{
"id": "17917208857807123",
"media_url": "https://scontent-lcy1-1.cdninstagram.com/v/t51.29350-15/238506160_849469739030953_6598130759133178944_n.jpg?_nc_cat=100&ccb=1-5&_nc_sid=8ae9d6&_nc_ohc=JCqfdQg4KQMAX-y01Yj&_nc_ht=scontent-lcy1-1.cdninstagram.com&edm=AEoDcc0EAAAA&oh=e41066405415e052d0f18604154241df&oe=61219F50"
}
]
},
"cached_to_s3": true,
"link": "https://www.instagram.com/p/CSriRJbsJqK/",
"caption": {
"text": "Petit tour à Ljubljana 🇸🇮🐉"
},
"likes": {
"count": 1288
},
"comments": {
"count": 8
},
"tags": [
],
"words": [
"petit",
"tour",
"a",
"ljubljana"
],
"idl": 17891590679240585,
"id": "17891590679240585"
}
],
"meta": {
"provider": "instagram",
"type": "hashtag_fbapi",
"search": "rockclimbing"
},
"pagination": {
"max_id": "17891590679240585",
"since_id": "17891590679240585",
"newer_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=1&token=xxx&since_id=17891590679240585",
"older_results": "https://www.cool-tabs.com/api/v1/monitors/1.json?limit=1&token=xxx&max_id=17891590679240585"
}
}