Scrapingdog
HomePricingSupportLogin
  • Documentation
  • Web Scraping API
    • Request Customization
      • Javascript Rendering
        • Wait when rendering Javascript
      • Custom Headers
      • Premium Residential Proxies
      • Geotargeting
      • Sessions
  • POST Request
  • Google Search Scraper API
    • Google Country Parameter: Supported Google Countries
    • Supported Google Countries via cr parameter
    • Google Domains Page
    • Google Language Page
    • Google LR Language Page
  • Google AI Overview API
  • Google Maps API
    • Google Maps Posts API
    • Google Maps Photos API
    • Google Maps Reviews API
    • Google Maps Places API
  • Google Trends API
    • Google Trends Autocomplete API
    • Google Trends Trending Now API
  • Google Images API
  • Google News API
    • Google News API 2.0
  • Google Shopping API
  • Google Product API
  • Google Videos API
  • Google Shorts API
  • Google Autocomplete API
  • Google Scholar API
    • Google Scholar Profiles API
    • Google Scholar Author API
      • Google Scholar Author Citation API
    • Google Scholar Cite API
  • Google Finance API
  • Google Lens API
  • Google Jobs API
  • Google Local API
  • Google Patents API
    • Google Patent Details API
  • Bing Search Scraper API
  • Amazon Scraper API
    • Amazon Product Scraper
    • Amazon Search Scraper
    • Amazon Reviews API
    • Amazon Autocomplete Scraper
  • Instagram Scraper API
  • Linkedin Scraper API
    • Person Profile Scraper
    • Company Profile Scraper
  • Linkedin Jobs Scraper
    • Scrape Linkedin Jobs
    • Scrape LinkedIn Job Overview
  • Yelp Scraper API
  • Twitter Scraping API
    • X Scraping API 2.0
  • Indeed Scraper API
  • Zillow Scraper API
  • Youtube Scraper API
    • Youtube Search API
    • YouTube Transcripts API
    • YouTube Channel API
  • Walmart Scraper API
    • Walmart Product Scraper
    • Walmart Search Scraper
    • Walmart Reviews Scraper
  • Screenshot API
  • Webhook Integration
  • Datacenter Proxies
  • Account API
Powered by GitBook
On this page
  • Parameters
  • API Example
  • Response

Twitter Scraping API

PreviousYelp Scraper APINextX Scraping API 2.0

Last updated 1 month ago

With Twitter Scraping API you scrape any tweet. You just have to pass the URL of that tweet and our API will return the parsed JSON data.

Each successful request will cost you 10 API credits. Twitter Scraping API pricing is available .

You have to send a GET request to http://api.scrapingdog.com/twitter with the below-given parameters.

Parameters

Parameter
Description

api_key required

Your personal API key. Available on your dashboard. Type: String

parsed required

This is a boolean that tells our server to return JSON or HTML. If you pass true then our server will return a JSON response and if you pass false then HTML will be returned. Type: Boolean

url required

This is the tweet URL. Type: String

API Example

curl "https://api.scrapingdog.com/twitter?api_key=5eaa61a6e562fc52fe763tr516e4653&url=https://twitter.com/elonmusk/status/1655608985058267139&parsed=true"
import requests

api_key = '5eaa61a6e562fc52fe763tr516e4653'
url = 'https://twitter.com/elonmusk/status/1655608985058267139'
parsed = 'true'  # Use 'true' or 'false' based on your requirements

params = {
    'api_key': api_key,
    'url': url,
    'parsed': parsed
}

response = requests.get('https://api.scrapingdog.com/twitter', params=params)

if response.status_code == 200:
    # Parse the JSON response using response.json()
    response_data = response.json()
    
    # Now you can work with the response_data as a Python dictionary
    print(response_data)
else:
    print(f'Request failed with status code: {response.status_code}')
const axios = require('axios');

const api_key = '5eaa61a6e562fc52fe763tr516e4653';
const url = 'https://twitter.com/elonmusk/status/1655608985058267139';
const parsed = 'true'; // Use 'true' or 'false' based on your requirements

const params = {
  api_key,
  url,
  parsed,
};

axios
  .get('https://api.scrapingdog.com/twitter', { params })
  .then((response) => {
    if (response.status === 200) {
      // Parse the JSON response
      const responseData = response.data;
      console.log(responseData);
    } else {
      console.error(`Request failed with status code: ${response.status}`);
    }
  })
  .catch((error) => {
    console.error('An error occurred:', error);
  });
<?php
$api_key = '5eaa61a6e562fc52fe763tr516e4653';
$url = 'https://twitter.com/elonmusk/status/1655608985058267139';
$parsed = 'true'; // Use 'true' or 'false' based on your requirements

// Create an array with the query parameters
$params = array(
    'api_key' => $api_key,
    'url' => $url,
    'parsed' => $parsed
);

// Initialize cURL session
$ch = curl_init('https://api.scrapingdog.com/twitter?' . http_build_query($params));

// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL request
$response = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($httpCode === 200) {
        // Parse the JSON response
        $responseData = json_decode($response, true);
        print_r($responseData);
    } else {
        echo 'Request failed with status code: ' . $httpCode;
    }
}

// Close cURL session
curl_close($ch);
?>
require 'httparty'
require 'json'

api_key = '5eaa61a6e562fc52fe763tr516e4653'
url = 'https://twitter.com/elonmusk/status/1655608985058267139'
parsed = 'true' # Use 'true' or 'false' based on your requirements

# Define the API endpoint
endpoint = 'https://api.scrapingdog.com/twitter'

# Create a hash with the query parameters
params = {
  api_key: api_key,
  url: url,
  parsed: parsed
}

# Make the GET request
response = HTTParty.get(endpoint, query: params)

# Check the HTTP response code
if response.code == 200
  # Parse the JSON response
  parsed_response = JSON.parse(response.body)
  puts parsed_response
else
  puts "Request failed with status code: #{response.code}"
end
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.json.JSONObject;

public class TwitterApiExample {
    public static void main(String[] args) {
        String api_key = "5eaa61a6e562fc52fe763tr516e4653";
        String url = "https://twitter.com/elonmusk/status/1655608985058267139";
        String parsed = "true"; // Use 'true' or 'false' based on your requirements

        String endpoint = "https://api.scrapingdog.com/twitter";
        
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url(endpoint + "?api_key=" + api_key + "&url=" + url + "&parsed=" + parsed)
                .get()
                .build();

        try {
            Response response = client.newCall(request).execute();
            ResponseBody responseBody = response.body();

            if (response.isSuccessful() && responseBody != null) {
                String jsonString = responseBody.string();
                JSONObject jsonResponse = new JSONObject(jsonString);
                System.out.println(jsonResponse.toString(4)); // Pretty print the JSON response
            } else {
                System.err.println("Request failed with status code: " + response.code());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Response

[
    {
        "views": "78.2M",
        "retweets": "39.1K",
        "quotes": "17.1K",
        "likes": "394.8K",
        "bookmarks": "3,246",
        "tweet": "We’re purging accounts that have had no activity at all for several years, so you will probably see follower count drop",
        "profile_picture": "https://pbs.twimg.com/profile_images/1683325380441128960/yRsRRjGO_normal.jpg",
        "name": "Elon Musk",
        "profile_handle": "@elonmusk",
        "profile_url": "https://www.twitter.com/elonmusk",
        "tweet_timing": "4:21 PM",
        "tweet_date": "May 8, 2023",
        "tweet_id": "1655608985058267139",
        "tweet_url": "https://www.twitter.com/elonmusk/status/1655608985058267139"
    }
]
here