Skip to content

ScrapingBee/social-media-scraper-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Social Media Scraper API

Social Media Scraper API

The ScrapingBee social media scraper API lets you collect public data from social platforms at scale without getting blocked. Built on the ScrapingBee Web Scraping API , it handles proxy rotation, headless browsers, and anti-bot systems for you, and returns the rendered page or parsed data over a single HTTP request.

Contents

What is social media scraping?

Social media scraping is the automated collection of publicly available data from social networks: posts, profiles, follower counts, comments, hashtags, and search results. A social media scraper API sends a request to a platform on your behalf, renders the page in a real browser, rotates IPs to avoid blocks, and returns the data in a usable format. The same idea as web scraping social media manually, except the API handles every part that usually breaks.

How it works

You send a GET request to the ScrapingBee API with two things: your API key and the target URL. ScrapingBee fetches the page from the right geographic region, executes the JavaScript, rotates proxies if needed, and returns the rendered HTML or a structured JSON response. You can layer on parameters to render JavaScript, switch to premium or stealth proxies, run custom interactions, or take a screenshot.

Supported platforms

ScrapingBee covers social media scraping in two ways: dedicated scrapers for the highest-volume platforms, and the general Web Scraping API for everything else.

Platform Method Notes
TikTok Dedicated scraper Video details, user profiles, trending content. See TikTok scraper docs.
TikTok Search Dedicated scraper Search results by query. See TikTok Search scraper docs.
YouTube Dedicated scraper Video metadata and channel data. See YouTube scraper docs.
X (Twitter), Facebook, Pinterest Web Scraping API Pass the public URL with render_js=true and premium_proxy=true.
Google results for social Google Search API Surface social posts ranking in Google. See Google Search API docs.
Instagram, LinkedIn, Reddit Not recommended Scraping these platforms breaks their terms of service. Review each platform's ToS before sending requests.

Quick start

Install the Python SDK:

pip install scrapingbee

Send your first request:

from scrapingbee import ScrapingBeeClient

client = ScrapingBeeClient(api_key='YOUR-API-KEY')
response = client.get("YOUR-URL")

print('Response HTTP Status Code: ', response.status_code)
print('Response HTTP Response Body: ', response.content)

Replace YOUR-API-KEY with the key from your dashboard and YOUR-URL with the social media page you want to scrape. The first 1,000 credits are free.

Code examples

Every snippet below is the canonical "first request" from the ScrapingBee documentation. Swap in your API key and target URL and the request runs against any social URL the API supports.

curl

curl "https://app.scrapingbee.com/api/v1?api_key=YOUR-API-KEY&url=YOUR-URL"

Python

pip install scrapingbee
from scrapingbee import ScrapingBeeClient

client = ScrapingBeeClient(api_key='YOUR-API-KEY')
response = client.get("YOUR-URL")

print('Response HTTP Status Code: ', response.status_code)
print('Response HTTP Response Body: ', response.content)

Node.js

npm install scrapingbee
const scrapingbee = require('scrapingbee');

async function get(url) {
  var client = new scrapingbee.ScrapingBeeClient('YOUR-API-KEY');
  var response = await client.get({
    url: url,
    params: {},
  })
  return response
}

get('YOUR-URL').then(function (response) {
    var decoder = new TextDecoder();
    var text = decoder.decode(response.data);
    console.log(text);
}).catch((e) => console.log('A problem occurs : ' + e.response.data));

PHP

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.scrapingbee.com/api/v1?api_key=YOUR-API-KEY&url=YOUR-URL');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;

curl_close($ch);

Ruby

require 'net/http'
require 'net/https'

uri = URI('https://app.scrapingbee.com/api/v1?api_key=YOUR-API-KEY&url=YOUR-URL')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER

req = Net::HTTP::Get.new(uri)
res = http.request(req)

puts "Response HTTP Status Code: #{res.code}"
puts "Response HTTP Response Body: #{res.body}"

Go

package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	client := &http.Client{}
	req, err := http.NewRequest("GET", "https://app.scrapingbee.com/api/v1?api_key=YOUR-API-KEY&url=YOUR-URL", nil)

	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Failure : ", err)
	}

	respBody, _ := ioutil.ReadAll(resp.Body)
	fmt.Println("response Status : ", resp.Status)
	fmt.Println("response Body : ", string(respBody))
}

Java

import java.io.IOException;
import org.apache.http.client.fluent.*;

public class SendRequest {
  public static void main(String[] args) {
    try {
      Content content = Request.Get("https://app.scrapingbee.com/api/v1?api_key=YOUR-API-KEY&url=YOUR-URL")
        .execute().returnContent();
      System.out.println(content);
    }
    catch (IOException e) { System.out.println(e); }
  }
}

Request parameters

The most common parameters when scraping social media. Full list in the API reference.

Parameter Type Description
api_key string, required Your ScrapingBee API key.
url string, required The URL to scrape. URL-encode it.
render_js boolean, default true Run a headless browser. Needed for any social platform that loads content with JavaScript.
premium_proxy boolean Route the request through residential proxies. Use when datacenter IPs get blocked.
stealth_proxy boolean Route through stealth proxies for the hardest targets.
country_code string Two-letter country code for geotargeting.
wait integer Milliseconds to wait after the page loads. Useful for lazy-loaded feeds.
js_scenario JSON Click, scroll, fill forms, or wait for selectors before returning the page.
screenshot boolean Return a PNG screenshot of the page.

Use cases

  • Track brand mentions across public posts and comments.
  • Monitor competitor follower counts, post frequency, and engagement.
  • Run sentiment analysis on product launches and campaigns.
  • Build training datasets from public social conversations.
  • Identify influencers and creators in a niche.
  • Pull public profile data for lead enrichment.

Why ScrapingBee

  • One endpoint per request. No infrastructure to maintain on your side: proxies, browser fleets, and anti-bot bypass are handled for the request.
  • JavaScript rendering on by default, which is what makes infinite-scroll platforms like TikTok and X scrapeable in the first place.
  • Dedicated scrapers for TikTok, TikTok Search, and YouTube return clean responses without you parsing HTML.
  • SDKs for Python and Node.js. Native HTTP libraries for every other language.
  • 1,000 credits free, no credit card required.

Pricing

ScrapingBee charges in API credits. The number of credits per request depends on the parameters you set (JavaScript rendering and premium proxies cost more than a plain HTML fetch).

Plan Monthly API credits Concurrent requests
Free $0 1,000 (one-off) 5
Freelance $49 250,000 10
Startup $99 1,000,000 50
Business $249 3,000,000 100
Business+ $599 8,000,000 200

Current pricing: scrapingbee.com/#pricing.

FAQ

Is social media scraping legal?

Scraping publicly available data is generally legal in many jurisdictions, but the law varies by country and by the kind of data collected. Most social platforms also restrict scraping in their terms of service, so they can block accounts or pursue ToS claims even when the underlying activity is legal. Review the platform's ToS and the regulations that apply to you (GDPR, CCPA) before running anything in production.

Which social media platforms does ScrapingBee support?

ScrapingBee has dedicated scrapers for TikTok, TikTok Search, and YouTube. The general Web Scraping API works for X (Twitter), Facebook, and Pinterest public pages. Instagram, LinkedIn, and Reddit are not recommended because their terms of service prohibit scraping.

Do I need to handle proxies and CAPTCHAs myself?

No. Proxy rotation, headless browser orchestration, and anti-bot bypass are part of the API. For the hardest targets, switch on premium_proxy=true or stealth_proxy=true.

What are the best social media scraping tools?

That depends on what you are scraping and how much you need to scale. For developers who want to send HTTP requests and get rendered data back, an API like ScrapingBee is the simplest path. ScrapingBee maintains a current comparison: Best Social Media Scraping Tools.

How do I scrape JavaScript-heavy pages like TikTok or X?

Keep render_js=true (it is on by default) and add premium_proxy=true if you hit rate limits. For infinite-scroll feeds, use js_scenario to scroll the page before the response is returned. The JavaScript scenario docs cover the syntax.