API Documentation

Complete reference for the Datapio scraping API endpoints.

https://api.datapio.app

Authentication

All API requests require a Bearer token in the Authorization header.
  1. Go to the API Info page to find your API key.
  2. Include the API key in the Authorization header of every request.
  3. Format: Bearer YOUR_API_KEY
Authorization: Bearer YOUR_API_KEY

Response Format

Every response — success or error — follows the same top-level envelope.

Success

{
  "success": true,
  "data": "...",
  "meta": {
    "requestId": "req_abc123",
    "creditsCharged": 1,
    "creditsRemaining": 999,
    "executionTimeMs": 280,
    "cached": false
  }
}
FieldTypeDescription
successtrueAlways true on success.
dataobject | arrayThe endpoint-specific payload. Shape varies per endpoint — see Response Fields below each endpoint.
meta.requestIdstringUnique ID for this request. Include in bug reports.
meta.creditsChargednumberCredits deducted for this request. 0 when served from cache.
meta.creditsRemainingnumberCredits left in your account after this request.
meta.executionTimeMsnumberServer-side processing time in milliseconds.
meta.cachedbooleantrue if the result was served from cache. No credits are charged on cached responses.

Error

{
  "success": false,
  "error": {
    "code": "NO_HEALTHY_SCRAPER",
    "message": "No healthy scraper accounts available",
    "requestId": "req_abc123"
  }
}
FieldTypeDescription
successfalseAlways false on error.
error.codestringMachine-readable error code. Stable across API versions — safe to branch on.
error.messagestringHuman-readable description of the error.
error.requestIdstring | undefinedPresent when the request reached the server. Include in bug reports.

Rate Limits

API requests are rate-limited to ensure fair usage across all users.

120

Requests per minute

5,000

Requests per hour

100,000

Requests per day

When rate limited, the API returns a 429 status code with a Retry-After header.

X/Twitter Endpoints

POST
/profile
1 credit
Scrape a user profile from X/Twitter. Returns user details including bio, follower count, following count, tweet count, and profile metadata. Cost: 1 credit per request.
NameTypeRequiredDescription
usernamestring
required
X/Twitter handle (without @)

Code Samples

curl -X POST https://api.datapio.app/profile \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"username": "elonmusk"}'
POST
/tweets
ceil(count / 20) credits
Scrape recent tweets from a user on X/Twitter. Returns a list of tweets with text, engagement metrics, and media attachments.
NameTypeRequiredDescription
usernamestring
required
X/Twitter handle (without @)
countinteger
optional
Number of tweets to fetch. Range: 1–100. Default: 20. Cost: ceil(count / 20) credits.
includeRepliesboolean
optional
Include reply tweets. Default: false.

Code Samples

curl -X POST https://api.datapio.app/tweets \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"username": "elonmusk", "count": 20}'
POST
/mentions
ceil(count / 20) credits
Scrape mentions of a user on X/Twitter. Returns tweets that mention the specified user.
NameTypeRequiredDescription
usernamestring
required
X/Twitter handle (without @)
countinteger
optional
Number of mentions to fetch. Range: 1–100. Default: 20. Cost: ceil(count / 20) credits.

Code Samples

curl -X POST https://api.datapio.app/mentions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"username": "elonmusk", "count": 20}'

Error Codes

All errors follow a consistent format with a status code and message.
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error description"
  }
}
CodeStatusDescription
400
Bad RequestInvalid request body or missing required fields.
401
UnauthorizedMissing or invalid API key in Authorization header.
402
Insufficient CreditsNot enough credits to complete the request.
404
Not FoundThe requested resource was not found.
429
Rate LimitedToo many requests. Retry after the indicated time.
500
Internal ErrorSomething went wrong on our end. Please retry.
503
Service UnavailableThe scraping service is temporarily unavailable.