BuyProxy logo
Log inSign up

How to Scrape Instagram and TikTok Data With an API

Scrape Instagram and TikTok data with one API call: setup, curl, Python and Node examples, error handling and cost control, from $0.002235 per call.

BPThe BuyProxy Team
October 8, 20266 min read

To scrape Instagram and TikTok data with an API, you create an API key, add a small prepaid balance, and send a GET request to a scraper endpoint such as /v1/scrape/instagram/profile. You get structured JSON back instead of HTML, with no proxies, parsers or browser to run. This guide walks through the full setup on BuyProxy's Scraper API, with working examples in curl, Python and Node, the costs per call, and the error handling you need before you put it in production.

What You Need Before You Start

You need three things: a BuyProxy account, an API key, and a Scraper API balance. The balance is separate from your proxy bandwidth, so adding GB for proxies does not fund scraper calls and the reverse.

  1. Create an account. Sign up here if you do not have one.
  2. Create an API key. In the dashboard, open API keys and create a personal key. Your requests send it in an X-API-Key header. The authentication docs cover key handling.
  3. Add a balance. Open Scraper API in the dashboard and add at least $5 by card or crypto. Credits do not expire.

At the standard rate of $0.002235 per call, the $5 minimum covers roughly 2,200 calls. That is enough to test many profiles before you commit to anything larger.

Step 1: Pick a Scraper and Check Its Inputs

Each scraper is one platform plus one action, such as instagram/profile or tiktok/profile-videos. Open the catalog in your dashboard, search for the platform, and select a scraper. The page lists every input, which ones are required, and the price per call. You can run it once from the dashboard first, which is the fastest way to see what the response looks like before you write code.

A few examples from the catalog, with their inputs:

ScraperRequired inputUseful optional inputsPrice per call
Instagram Profilehandletrim, cache_max_age$0.002235
TikTok Profilehandle or user_idtrim, cache_max_age$0.002235
YouTube ChannelchannelId, handle or urlcache_max_age$0.002235
TikTok Videourlget_transcript, region, download_media$0.02235

Some scrapers accept "one of" inputs, like the TikTok profile, where you provide either a handle or a user ID. If you leave out every option in that group, the API tells you what to provide.

Step 2: Make Your First Call

The endpoint pattern is the same everywhere: GET or POST to https://www.buyproxy.org/v1/scrape/{platform}/{action}. Here is an Instagram profile lookup with curl:

curl "https://www.buyproxy.org/v1/scrape/instagram/profile?handle=instagram&trim=true" \
  -H "X-API-Key: YOUR_API_KEY"

The same call in Python, for a TikTok profile:

import requests

API_KEY = "YOUR_API_KEY"

response = requests.get(
    "https://www.buyproxy.org/v1/scrape/tiktok/profile",
    params={"handle": "tiktok"},
    headers={"X-API-Key": API_KEY},
    timeout=60,
)
response.raise_for_status()
body = response.json()

print(body["data"])        # the scraper's JSON result
print(body["costUsd"])     # what this call cost
print(body["balanceUsd"])  # your remaining Scraper API balance

And in Node.js:

const res = await fetch(
  "https://www.buyproxy.org/v1/scrape/youtube/channel-lookup?handle=MrBeast",
  { headers: { "X-API-Key": process.env.BUYPROXY_API_KEY } }
);
const body = await res.json();
if (!res.ok) throw new Error(body.error);
console.log(body.data, body.costUsd, body.balanceUsd);

Every successful response wraps the scraper's output in data and adds costUsd and balanceUsd, so you can track spend inside your own code without a separate billing call. You can also read your balance at any time from /v1/scraper/balance.

Step 3: Handle Errors and Retries Properly

Handle each error class differently, because most of them are free and safe to retry. Errors, timeouts and rate-limited requests are not charged, so retrying costs nothing extra.

StatusMeaningWhat to do
400A missing, unknown or invalid input, or the target could not be fetched with those inputsFix the request. Do not retry unchanged.
402Not enough balance for this callAdd balance, then retry.
404Unknown platform or action, or a target that was not foundCheck the spelling against the catalog.
429Too many requestsBack off and retry. Personal keys allow 60 requests per minute.
502, 503, 504The scraper timed out or is temporarily unavailableRetry with exponential backoff.

A small retry wrapper covers most of it:

import time, requests

def scrape(platform, action, params, retries=4):
    for attempt in range(retries):
        r = requests.get(
            f"https://www.buyproxy.org/v1/scrape/{platform}/{action}",
            params=params,
            headers={"X-API-Key": API_KEY},
            timeout=60,
        )
        if r.status_code in (429, 502, 503, 504):
            time.sleep(2 ** attempt)   # 1s, 2s, 4s, 8s
            continue
        r.raise_for_status()
        return r.json()["data"]
    raise RuntimeError("scraper unavailable after retries")

Third-party platforms change their pages and limits, and a scraper can occasionally return fewer fields or fail until it is updated. Read the data defensively, for example by treating every field as optional, and do not build a pipeline that assumes the output shape never changes. The guide to proxy error codes explains the same 429 and 5xx patterns from the proxy side.

Step 4: Control Your Costs

Most of the savings come from not asking for the same data twice. Three options help:

  • Use cache_max_age. Many scrapers accept a maximum cache age such as 1d, 7d or 30d. Recent data can be reused instead of fetched again.
  • Use trim. It shrinks the response, which makes it easier to store and process.
  • Store results. Save each response to your own database and look it up before calling again.

Pagination multiplies calls: pulling a long comment thread or a creator's whole video list takes several requests. Estimate calls per useful record before you plan a budget. For pricing across vendors, see our scraper API pricing comparison.

A Short Note on Legality

Collecting public data is treated differently from accessing private accounts, but the law varies by country and platform. One widely cited example is the January 23, 2024 ruling in Meta v. Bright Data in a US federal court in California, which held that Meta's terms of service did not bar logged-off scraping of publicly available data. Law firm summaries note the case still had other claims in play, and a single district court ruling does not settle the question everywhere. Privacy laws such as the GDPR can still apply to personal data. Read our legality guide, collect only public information you have a legitimate reason to use, and get legal advice for your situation. This is general information, not legal advice.

Frequently Asked Questions

Q: Do I need proxies to use the Scraper API?
No. The provider handles IPs, retries and parsing for each scraper. You only need an API key and a Scraper API balance.

Q: How much does it cost to scrape an Instagram profile?
At BuyProxy's current rate an Instagram Profile call costs $0.002235, about $2.23 per 1,000 calls. A few scrapers, such as TikTok Video, cost more, and the dashboard shows each price before you run it.

Q: Can I try a scraper before writing code?
Yes. Every scraper in the dashboard catalog has a form that runs a real call and shows the JSON. It uses your balance, so it costs the same as an API call.

Q: What happens if a call fails?
You are not charged. Errors, timeouts and rate limits are refunded automatically, and failed calls show as "Not charged" in your recent-calls list.

Q: Is there a rate limit?
Personal API keys are limited to 60 requests per minute. If you exceed it, back off and retry.

Summary

Scraping Instagram, TikTok or YouTube data through an API takes four steps: create a key, add a balance, pick a scraper and call it. Wrap your calls in retries for 429 and 5xx responses, cache results to avoid paying twice, and read the output defensively because the sites behind it change. Start with the $5 minimum and measure cost per usable record.

Open the BuyProxy Scraper API and run your first call โ†’

Source: Quinn Emanuel client alert on Meta v. Bright Data.

Frequently Asked Questions

Q: Do I need proxies to use the Scraper API?+

No. The provider handles IPs, retries and parsing for each scraper. You only need an API key and a Scraper API balance.

Q: How much does it cost to scrape an Instagram profile?+

At BuyProxy's current rate an Instagram Profile call costs $0.002235, about $2.23 per 1,000 calls. A few scrapers, such as TikTok Video, cost more, and the dashboard shows each price before you run it.

Q: Can I try a scraper before writing code?+

Yes. Every scraper in the dashboard catalog has a form that runs a real call and shows the JSON. It uses your balance, so it costs the same as an API call.

Q: What happens if a call fails?+

You are not charged. Errors, timeouts and rate limits are refunded automatically, and failed calls show as "Not charged" in your recent-calls list.

Q: Is there a rate limit?+

Personal API keys are limited to 60 requests per minute. If you exceed it, back off and retry.

Need residential proxies right now? Start free โ€” no card required.

Sign up free โ†’

Written by

BP

The BuyProxy Team

The BuyProxy team writes about residential proxy infrastructure, geo-targeting, session management, and best practices for scraping and data collection at scale.

Try residential proxies free

Rotating and sticky sessions, city-level geo-targeting, full HTTP/HTTPS/SOCKS5 support.

Get started free โ†’