Skip to content

How do I get tweets programmatically in 2026?

Last updated August 31, 2026

Four moving parts get tweets into your code: an Authorization: Bearer header, one GET endpoint, a cursor loop, and a retry on 429. TwitterAPIs hands back parsed JSON with the text, author, timestamps and engagement counts already split out. Each page is one billed call at $0.0008 and carries about 20 items. No OAuth exchange, no app registration.

Every rate here is the pricing TwitterAPIs publishes. The billed rate is $0.0008 per call; $0.04 per 1,000 tweets is derived from it at a full 20-tweet page, which is the default page size rather than a guaranteed yield (source: twitterapis.com/pricing).

The shortest call that returns tweets

Sign up, copy the key, send one GET request. The header is Authorization: Bearer followed by your key, and the endpoint takes a handle or a query as an ordinary parameter. Back comes a JSON object holding a tweets array, where each item carries id, text, created_at, an author object, and the engagement counts as favorite_count, retweet_count, reply_count, quote_count, bookmark_count and view_count. No SDK is needed to do this. A single curl invocation is a complete client for the first attempt.

Authentication is one header

There is no OAuth exchange, no consumer key and secret pair, no app to register and no approval queue. The API key issued at signup is the entire credential, and it travels in the Authorization header on every request. Two practical rules follow. Keep the key on a server, never in browser code or a mobile bundle, since anything holding it can spend your balance. And read the body of a failure: a 401 says the key is missing, malformed or revoked, which is a different problem from an exhausted balance, which returns 402.

Paging, cursor in and cursor out

One request is one page, and one page is one billed call. The response carries next_cursor and has_more. Send next_cursor back as the cursor parameter to fetch the following page, and repeat while has_more stays true. Do not stop merely because next_cursor is null: the follower-graph endpoints keep emitting a cursor past the end of a collection, so has_more turning false, or an empty item array, is the loop stop to trust. Raising a count parameter will not help either. The upstream page is fixed at roughly 20 items, and count is accepted but not honoured.

Errors worth branching on

Six responses cover nearly everything. A 400 means a malformed parameter, so repair the request rather than retrying it. A 401 means the key is missing, malformed or revoked. A 402 means the balance is exhausted, and the remedy is a top-up rather than a backoff. A 404 is a deleted post or a private account, which inside a bulk job is ordinary and belongs in a skip list rather than an exception. A 429 means slow down, and the answer is exponential backoff. Anything in the 5xx range is server side, so retry with backoff and give up after a bounded number of attempts.

The same loop in any language

The shape does not change between Python, Node, Go, Ruby or a shell script, because no SDK is doing anything clever underneath. Build the query string. Attach the header. Send the request. On a 429 or a 5xx, sleep and retry with a growing delay. On a 200, write the items somewhere durable before asking for the next page, so a crash halfway through a long run costs one page rather than the whole job. Then read next_cursor and go again while has_more stays true. Everything else, concurrency, storage, deduplication, is your own code rather than the API's.

The four stages of a tweet-fetching loop

StageWhat you sendWhat you read backWhat goes wrong
AuthenticateAuthorization: Bearer with your API key200 and a JSON body401 for a bad key, 402 for an empty balance
Request a pageEndpoint plus query parameterstweets array, next_cursor, has_more400 when a parameter is malformed
Advance the cursorcursor set to the previous next_cursorThe following page of itemsAn endless loop if you stop on the cursor rather than has_more
Absorb pressureThe same request, later200 once the backoff clears it429 for throughput, 5xx for a server fault
Starting February 9, we will no longer support free access to the Twitter API, both v2 and v1.1. A paid basic tier will be available instead.
X Developer Platform (@TwitterDev). Source

Questions and answers

Do I need OAuth to fetch tweets?
No. One API key travels as Authorization: Bearer on every request. There is no consumer key and secret to exchange, no token to refresh, and no app registration or approval step standing in front of the first call.
How do I get the next page of results?
Read next_cursor from the response and send it back as the cursor parameter, continuing while has_more is true. Do not stop on a null cursor: follower-graph endpoints keep emitting one past the end, so has_more, or an empty item array, is the reliable stop.
Can I ask for more than 20 items in one call?
No. The upstream page is fixed at roughly 20 items, and a count parameter is accepted but not honoured, so raising it changes nothing. More results means more pages, and each page is one billed call at $0.0008.
What should my code do on a 429?
Back off and retry with a growing delay. A 429 says the request rate crossed the ceiling on your key, which is 600 requests a minute with 20 in flight. It is a throughput signal, not a billing one, and it is distinct from a 402, which no amount of waiting will clear.
Which language should I write it in?
Any of them. The loop is a header, a query string, a cursor and a retry, which every HTTP client already has. Python, Node, Go and curl all reach the same JSON, so pick whatever the rest of the job is written in rather than hunting for an SDK.

Start with $0.50 in free credits

No credit card. Roughly 12,500 tweets to test every endpoint.