The Social Media Scraping API allows you to scrape information from Instagram. The API uses GraphQL targets which return data in JSON.
While the targets in this page use GraphQL under the hood, they are interfaced with via REST.
The following GraphQL targets are available:
Target | Supports pagination |
---|---|
instagram_graphql_user_posts | β |
instagram_graphql_profile | |
instagram_graphql_post | |
instagram_graphql_reel |
Instagram GraphQL User Posts
Returns information about a specific Instagram user.
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
target | string | β | target | instagram_graphql_user_posts |
query | string | β | Instagram user profile name. | nba |
count | string | post count: min 12, max 24 per response | 24 | |
cursor | string | next page string (end_cursor value in response) | QVFBUG5LVkxEaXpPbjZ2T2dhQnVfZTdaUHdnX0VmcXNzek5IRGJTdFdQWkpqOFZDcWRTbXpZSXhkdVRoTlI3d1ExSklzay1sSW1jMkphQVROdnNXazJ6ZA== |
Return value JSON:
- Basic information (name, description, follower count).
Instagram GraphQL profile
Returns information about a specific Instagram user.
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
target | string | β | target | instagram_graphql_profile |
query | string | β | Instagram profile name | nba |
Return value JSON:
- Basic information (name, description, follower count).
- 12 most recent posts.
Instagram GraphQL Reel
Returns the number of profiles this user is following (no exact profile handles).
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
target | string | β | target | `instagram_graphql_reel |
url | string | β | Instagram reel URL | https://www.instagram.com/reel/ClfPAdQgqTc/ |
Instagram GraphQL post
Returns information from a specific Instagram post.
Parameter | Type | Required | Description | Example | |
---|---|---|---|---|---|
target | string | β | target | instagram_graphql_post | |
url | string | β | Instagram post URL | https://www.instagram.com/p/ChYHpdAvnob |
Create callback for Instagram post
POST https://scraper-api.smartproxy.com/v2/task
Payload type: JSON
Parameter | Type | Required | Description | Examples |
---|---|---|---|---|
target | string | β | target | instagram_graphql_post |
url | url | β | Instagram post URL | https://www.instagram.com/p/ChYHpdAvnob |
curl -u username:password -X POST --url https://scraper-api.smartproxy.com/v2/task -H "Content-Type: application/json" -d "{\"url\": \"https://www.instagram.com/p/ChYHpdAvnob/\", \"target\": \"instagram_graphql_post\",\"locale\": \"en-us\",\"geo\": \"United States\" }"
import requests
headers = {
'Content-Type': 'application/json'
}
task_params = {
'url': 'https://www.instagram.com/p/ChYHpdAvnob/',
'target': 'instagram_graphql_post',
'locale': 'en-us',
'geo': 'United States'
}
username = 'username'
password = 'password'
response = requests.post(
'https://scraper-api.smartproxy.com/v2/task',
headers = headers,
json = task_params,
auth = (username, password)
)
print(response.text)
<?php
$params = array(
'url' => 'https://www.instagram.com/p/ChYHpdAvnob/',
'target' => 'instagram_graphql_post',
'locale' => 'en-us',
'geo' => 'United States'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartproxy.com/v2/task');
curl_setopt($ch, CURLOPT_USERPWD, 'username' . ':' . 'password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>
Pagination for Posts & Hashtags
Pagination is supported for instagram_graphql_hashtags
& instagram_graphql_user_posts
targets. First response returns pagination information - existence of multiple pages & end cursor of the current page. Providing this cursor
value with a subsequent request will fetch the following page.
Retrieve parsed results via callback
GET https://scraper-api.smartproxy.com/v2/task/{Task_ID}/results?type=parsed
Retrieve raw HTML results via callback
GET https://scraper-api.smartproxy.com/v2/task/{Task_ID}/results?type=raw
Updated 16 days ago