Scrape X (Twitter) with a JSON API. This repo has working Python examples for DataGuru's X (Twitter) scraper APIs: X (Twitter) Profile, X (Twitter) Search and X (Twitter) Trends.
DataGuru runs the scraping, proxies, retries and parsing, and returns clean JSON. You pay only for successful requests, from $0.001 per request, out of a prepaid balance: no subscription. New accounts get $1.00 of free credit.
| API | What it returns | Price | Page |
|---|---|---|---|
| X (Twitter) Profile | Get a public X (Twitter) profile: name, handle, bio, followers, following, verified status, and profile picture. | $0.0025 | https://dataguru.cc/apis/x-profile/ |
| X (Twitter) Search | Search X (Twitter) posts and accounts by keyword or query. | $0.001 | https://dataguru.cc/apis/x-search/ |
| X (Twitter) Trends | Get trending hashtags, topics, and discussions on X (Twitter) by country or worldwide. | $0.003 | https://dataguru.cc/apis/x-trends/ |
- Create a free account and an API key at dashboard.dataguru.cc.
- Install and run:
git clone https://github.com/dataguru-cc/twitter-scraper-api.git
cd twitter-scraper-api
pip install -r requirements.txt
export DATAGURU_API_KEY="your key"
python examples/sdk_example.py x-profileEvery example covers all 3 X (Twitter) APIs. Pass an API name to run just one; with no name each script runs them all, and each call is billed at the price above.
| File | Style | Run |
|---|---|---|
examples/sdk_example.py |
DataGuru Python SDK (pip install dataguru-sdk), one function per API, saves JSON to output/ |
python examples/sdk_example.py |
examples/requests_example.py |
Plain requests, synchronous |
python examples/requests_example.py |
examples/async_example.py |
asyncio + httpx, concurrent with a limit |
python examples/async_example.py |
examples/scrapy_spider.py |
Scrapy spider, items to JSON/CSV | scrapy runspider examples/scrapy_spider.py -O x-twitter.json |
All requests use the header Authorization: Api-Key YOUR_API_KEY. Errors return {"success": false, "error": {"code", "message", "request_id"}}, with HTTP 402 when the balance runs out and 429 (with Retry-After) when rate limited. Failed requests are not charged.
Get a public X (Twitter) profile: name, handle, bio, followers, following, verified status, and profile picture.
- Endpoint:
POST https://api.dataguru.cc/api/v1/x/profile - Price: $0.0025 per successful request ($2.50 per 1,000)
- Rate limit: 60 requests/minute
- Page and live playground: https://dataguru.cc/apis/x-profile/
- Documentation: https://dataguru.cc/documentation/x-profile/
| Parameter | Type | Required | Description |
|---|---|---|---|
profile_url |
string | yes | Public X profile URL or username, e.g. https://x.com/elonmusk |
Response fields: username, full_name, biography, external_link, follower_count, following_count, total_post_count, account_category, verified_badge, profile_picture_hd_url, unique_id, nickname, total_heart_like_count, video_count, screen_name, location, join_date, verified_type, pinned_tweet_id, plus _metadata
curl -X POST "https://api.dataguru.cc/api/v1/x/profile" \
-H "Authorization: Api-Key $DATAGURU_API_KEY" \
-H "Content-Type: application/json" \
-d '{"profile_url": "https://x.com/NASA"}'Response schema
Values are type placeholders from the API's published schema, not real data.
{
"user_profile": {
"username": "string",
"full_name": "string",
"biography": "string",
"external_link": "https://example.com/...",
"follower_count": 0,
"following_count": 0,
"total_post_count": 0,
"account_category": "string",
"verified_badge": false,
"profile_picture_hd_url": "https://example.com/...",
"unique_id": "1234567890",
"nickname": "string",
"total_heart_like_count": 0,
"video_count": 0,
"screen_name": "string",
"location": "string",
"join_date": "2026-01-01T12:00:00Z",
"verified_type": "Blue",
"pinned_tweet_id": "1234567890"
},
"_metadata": {
"request_id": "3f6c1a2e-8b4d-4c1e-9a7f-2d5e6b7c8d9e",
"execution_time_ms": 842,
"endpoint": "X (Twitter) Profile",
"mode": "live",
"format": "json",
"timestamp": "2026-01-01T12:00:00+00:00"
}
}Search X (Twitter) posts and accounts by keyword or query.
- Endpoint:
POST https://api.dataguru.cc/api/v1/x/search - Price: $0.001 per successful request ($1.00 per 1,000)
- Rate limit: 60 requests/minute
- Page and live playground: https://dataguru.cc/apis/x-search/
- Documentation: https://dataguru.cc/documentation/x-search/
| Parameter | Type | Required | Description |
|---|---|---|---|
limit |
integer | no | Maximum number of search results to return (1-50). Default: 5. |
query |
string | yes | Search query or topic, e.g. "openai" or "AI". |
Response fields: query, search_url, total_results, results, plus _metadata
curl -X POST "https://api.dataguru.cc/api/v1/x/search" \
-H "Authorization: Api-Key $DATAGURU_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "openai"}'Response schema
Values are type placeholders from the API's published schema, not real data.
{
"x_search": {
"query": "string",
"search_url": "https://example.com/...",
"total_results": 0,
"results": [
{
"post_id": "1234567890",
"post_url": "https://example.com/...",
"author_username": "string",
"author_name": "string",
"author_id": "1234567890",
"author_profile_image": "string",
"text": "string",
"embedded_hashtags": [
"string"
],
"create_time": "string",
"reply_count": 0,
"retweet_count": 0,
"like_count": 0,
"quote_count": 0,
"view_count": 0,
"save_count": 0,
"is_retweet": false,
"is_pinned": false
}
]
},
"_metadata": {
"request_id": "3f6c1a2e-8b4d-4c1e-9a7f-2d5e6b7c8d9e",
"execution_time_ms": 842,
"endpoint": "X (Twitter) Search",
"mode": "live",
"format": "json",
"timestamp": "2026-01-01T12:00:00+00:00"
}
}Get trending hashtags, topics, and discussions on X (Twitter) by country or worldwide.
- Endpoint:
POST https://api.dataguru.cc/api/v1/x/trends - Price: $0.003 per successful request ($3.00 per 1,000)
- Rate limit: 60 requests/minute
- Page and live playground: https://dataguru.cc/apis/x-trends/
- Documentation: https://dataguru.cc/documentation/x-trends/
| Parameter | Type | Required | Description |
|---|---|---|---|
include_tweets |
boolean | no | Whether to include sample tweets for the top trends. Default: False. |
limit |
integer | no | Maximum number of trending items to return (1-100). Default: 50. |
location |
string | no | Country name, country code, or "worldwide" (e.g. us, uk, worldwide). Default: worldwide. |
tweets_limit |
integer | no | Number of sample tweets per trend if include_tweets is true (1-10). Default: 3. |
Response fields: location, location_slug, source_url, scraped_at, total_trends, total_hashtags, total_topics, top_hashtags, popular_topics, all_trends, longest_trending, new_trends, hourly_timeline, plus _metadata
curl -X POST "https://api.dataguru.cc/api/v1/x/trends" \
-H "Authorization: Api-Key $DATAGURU_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'Response schema
Values are type placeholders from the API's published schema, not real data.
{
"x_trends": {
"location": "string",
"location_slug": "string",
"source_url": "https://example.com/...",
"scraped_at": "2026-01-01T12:00:00Z",
"total_trends": 0,
"total_hashtags": 0,
"total_topics": 0,
"top_hashtags": [
{
"rank": 0,
"name": "string",
"type": "hashtag",
"clean_name": "string",
"description": "string",
"post_url": "https://example.com/...",
"current_rank": 0,
"peak_rank": 0,
"hours_trending": 0,
"rank_change": "string",
"status": "NEW",
"tweet_count": "string",
"sample_tweets": [
{
"post_id": "1234567890",
"post_url": "https://example.com/...",
"author_username": "string",
"author_name": "string",
"author_id": "1234567890",
"author_profile_image": "string",
"text": "string",
"embedded_hashtags": [
"string"
],
"create_time": "string",
"reply_count": 0,
"retweet_count": 0,
"like_count": 0,
"quote_count": 0,
"view_count": 0,
"save_count": 0,
"is_retweet": false,
"is_pinned": false
}
],
"hashtag": "string",
"overall_rank": 0
}
],
"popular_topics": [
{
"rank": 0,
"name": "string",
"type": "hashtag",
"clean_name": "string",
"description": "string",
"post_url": "https://example.com/...",
"current_rank": 0,
"peak_rank": 0,
"hours_trending": 0,
"rank_change": "string",
"status": "NEW",
"tweet_count": "string",
"sample_tweets": [
{
"post_id": "1234567890",
"post_url": "https://example.com/...",
"author_username": "string",
"author_name": "string",
"author_id": "1234567890",
"author_profile_image": "string",
"text": "string",
"embedded_hashtags": [
"string"
],
"create_time": "string",
"reply_count": 0,
"retweet_count": 0,
"like_count": 0,
"quote_count": 0,
"view_count": 0,
"save_count": 0,
"is_retweet": false,
"is_pinned": false
}
],
"topic": "string",
"overall_rank": 0
}
],
"all_trends": [
{
"rank": 0,
"name": "string",
"type": "hashtag",
"clean_name": "string",
"description": "string",
"post_url": "https://example.com/...",
"current_rank": 0,
"peak_rank": 0,
"hours_trending": 0,
"rank_change": "string",
"status": "NEW",
"tweet_count": "string",
"sample_tweets": [
{
"post_id": "1234567890",
"post_url": "https://example.com/...",
"author_username": "string",
"author_name": "string",
"author_id": "1234567890",
"author_profile_image": "string",
"text": "string",
"embedded_hashtags": [
"string"
],
"create_time": "string",
"reply_count": 0,
"retweet_count": 0,
"like_count": 0,
"quote_count": 0,
"view_count": 0,
"save_count": 0,
"is_retweet": false,
"is_pinned": false
}
]
}
],
"longest_trending": [
{
"rank": 0,
"name": "string",
"type": "hashtag",
"clean_name": "string",
"description": "string",
"post_url": "https://example.com/...",
"current_rank": 0,
"peak_rank": 0,
"hours_trending": 0,
"rank_change": "string",
"status": "NEW",
"tweet_count": "string",
"sample_tweets": [
{
"post_id": "1234567890",
"post_url": "https://example.com/...",
"author_username": "string",
"author_name": "string",
"author_id": "1234567890",
"author_profile_image": "string",
"text": "string",
"embedded_hashtags": [
"string"
],
"create_time": "string",
"reply_count": 0,
"retweet_count": 0,
"like_count": 0,
"quote_count": 0,
"view_count": 0,
"save_count": 0,
"is_retweet": false,
"is_pinned": false
}
]
}
],
"new_trends": [
{
"name": "string",
"rank": 0,
"type": "hashtag",
"post_url": "https://example.com/..."
}
],
"hourly_timeline": [
{
"time": "string",
"top_trends": [
"string"
]
}
]
},
"_metadata": {
"request_id": "3f6c1a2e-8b4d-4c1e-9a7f-2d5e6b7c8d9e",
"execution_time_ms": 842,
"endpoint": "X (Twitter) Trends",
"mode": "live",
"format": "json",
"timestamp": "2026-01-01T12:00:00+00:00"
}
}- Python SDK and examples for all DataGuru APIs: github.com/dataguru-cc/dataguru-python (docs)
- Every API, with a live playground: https://dataguru.cc/apis/
- Use DataGuru from Claude, ChatGPT or Cursor through the MCP server: https://dataguru.cc/mcp/
- Run thousands of inputs from a CSV at half price with batch jobs: https://dataguru.cc/documentation/
- Other scraper APIs: 1688, Airbnb, Alibaba, AliExpress, Amazon, arXiv, ASOS, Best Buy, Booking.com, Brave Search, CA State Bar, Capterra, CoinGecko, CoinMarketCap, Companies House, Costco, CourtListener, Crunchbase, Discord, DoorDash, eBay, Etsy, Expedia, Fiverr, Flipkart, Glassdoor, Google Flights, Google Patents, Google Scholar, Google Search, Grubhub, Home Depot, Instagram, Investing.com, Justia, Kayak, Kick, Lazada, MarketWatch, Mercado Libre, Monster, OpenCorporates, OpenTable, PACER, PitchBook, PubMed, Reddit, Redfin, Resy, Rightmove, SEC EDGAR, Seeking Alpha, Shopee, Skyscanner, Target, TikTok, TradingView, TripAdvisor, Trulia, TrustRadius, Twitch, Uber Eats, Upwork, Vrbo, Walmart, Wayfair, Yahoo Finance, YouTube, Zillow, ZoomInfo, Zoopla
The example code is MIT licensed. Use of the DataGuru API is subject to the terms of service.