Skip to main content

SocialAPI — Python SDK

Real-time X (Twitter) data. 40 read endpoints plus free account endpoints for checking your own balance and usage. Around 100× cheaper than the official X API.

pip install socialapi-sdk
from socialapi import SocialAPI

api = SocialAPI("sk_your_key")          # or set SOCIALAPI_KEY

user = api.user_info(username="elonmusk")
print(user["followers_count"])

for t in api.user_last_tweets(username="elonmusk", limit=10):
    print(t["created_at"], t["text"][:80])

Get a key at socialapi.tech/signup — no credit card.


Why this exists

The official X API bills per resource returned — $0.005 a post, $0.010 a profile. Pulling 30 posts costs $0.15 there; the same call here is $0.0008, and a profile is $0.00015 instead of $0.010.

That gap is the whole reason this exists. Same pay-as-you-go model, roughly 100× less, one balance across every endpoint, and composite lookups plus per-account streaming that the official API does not offer at all.

Read-only by design. There is no posting, liking, or following. That means you never hand us an X account — a leaked key costs you some data queries, not your voice.


Common tasks

# Search — full X syntax, real-time (not cached)
api.search_advanced(query="bitcoin min_faves:100", limit=30)

# Is this account alive, suspended, or gone?
api.user_status(username="someaccount")      # -> alive | suspended | not_found

# Followers / following with cursor pagination
page = api.user_followers(username="jack", limit=200)

# Trends — worldwide, or per-region with a WOEID
api.trends()
api.trends_place(woeid=1)

# One call, full picture (runs several lookups concurrently server-side)
api.user_whois(username="elonmusk")

# Batch profiles in one request
api.batch_user_info(usernames="elonmusk,jack,binance")

# Your own account — balance, spend, and what you're monitoring. These are free.
me = api.usage()                    # balance + today/month spend
api.analytics(days=14)              # per-endpoint usage + days of runway left
api.stream_subscriptions()          # which accounts you're watching, and the daily cost

Every method maps 1:1 to an endpoint in the API reference.


Watching accounts, not just querying them

The methods above are request-and-response: you ask, you get an answer. If what you need is "tell me the moment they post", that runs over a WebSocket or a webhook instead — we push to you, median two seconds from post to delivery.

# websockets, or any WS client
import json, websockets

url = "wss://api.socialapi.tech/v1/stream/ws?api_key=sk_your_key"
async with websockets.connect(url) as ws:
    async for msg in ws:
        tweet = json.loads(msg)
        print(tweet["user"], tweet["content"][:80])

Monitoring is $0.08 per account per day, billed hourly — stop it and the billing stops. One account minimum, no bundles. It draws from the same balance as everything else, so there's nothing extra to sign up for.

Setup and payload format: socialapi.tech/docs


What it costs

A call returning up to 30 tweets $0.0008
Per tweet, at 30 per call $0.000027
Single profile lookup $0.00015
Watching one account $0.08 / day

No monthly fee, no minimum, no card. Failed calls cost nothing, and credits don't expire.


Errors worth handling

from socialapi import SocialAPI, RateLimited, InsufficientCredits, SocialAPIError

try:
    data = api.user_info(username="elonmusk")
except InsufficientCredits:
    ...   # 402 — top up. Do NOT retry; it will fail the same way.
except RateLimited:
    ...   # 429 — not charged. Back off and retry (the SDK already retries twice).
except SocialAPIError as e:
    print(e.status, e)

402 and 429 mean different things. 429 is "too fast, slow down" and costs nothing. 402 is "out of balance" — retrying just burns time. The SDK retries 429 and 5xx automatically with exponential backoff, and never retries 402.


Billing, briefly

  • Only successful requests are charged.
  • A call returning up to 30 items is one tier — asking for 30 costs the same as asking for 3, so request what you actually need.
  • Every response carries an x-credits-used header.

Full rules: socialapi.tech/#pricing


Configuration

api = SocialAPI(
    api_key="sk_...",       # or env SOCIALAPI_KEY
    base_url="https://api.socialapi.tech",
    timeout=30.0,           # seconds
    max_retries=2,          # for 429 / 5xx only
)

with SocialAPI() as api:    # context manager closes the session
    ...

Support

MIT licensed.

SocialAPI is an independent service and is not affiliated with, endorsed by, or authorized by X Corp. "X" and "Twitter" are trademarks of X Corp., used here only to describe the data this service reads. We access only publicly visible data.

Release files for socialapi-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for socialapi-sdk 1.0.0
File Size Uploaded
socialapi_sdk-1.0.0.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for socialapi-sdk 1.0.0
File Interpreter ABI Platform
socialapi_sdk-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.9 kB

Release files / socialapi_sdk-1.0.0.tar.gz

Download URL socialapi_sdk-1.0.0.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1593aff3320a1719215b43ce08f0f0e599848d0f59a15cd742b368073ce87d41
BLAKE2b-256 checksum
How to use checksums
b930155cf255671143dd1f61de773cbe78cb774f67f7dab11f1bc0f05f4f0517
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / socialapi_sdk-1.0.0-py3-none-any.whl

Download URL socialapi_sdk-1.0.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf9dcfef0fbfe807df8be32a7ce3509e6e345fc705ed1d2a176b2ac88a0a64be
BLAKE2b-256 checksum
How to use checksums
3f89a312ffdd85676c76ad23ad03ccd70a83dc500b00cbef1a2c2aaf8a7869c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page