Twitter User Timeline & Mentions (V2) - Data API Endpoint

User Timeline & Mentions (V2) by user id, bearer token, pagination token, exclude, expansions, fields (media), fields (places) and fields (polls).


Download Twitter User Timeline & Mentions (V2) data from the Official Twitter API | 👥  Contributors: steve 🚩  Report

✏️ Inputs

User ID user_id Required

ID of the Twitter User to fetch Tweets for. If you only know the username, use the User Details Endpoint to get the User ID.

This ID is sometimes referred to as the author_id from other Twitter endpoints, such as the Tweet Search Endpoints.

E.g. 529797130
Bearer Token access_token Required

Your Twitter app’s Bearer Token for collecting data with. If you don’t have one, see How to Get a Twitter API Key Without Approval or check out Twitter’s docs on Bearer Tokens for more information.

If you get the error client-not-enrolled, then make sure you’re not using a standalone app and try creating a new application with the Add App button under a project and NOT under the standalone section.

Pagination Token pagination_token Optional

Used for pagination. Provide the next_token you see in a response here to get the next page of results.

Exclude exclude Optional

Exclude certain types of Tweets like retweets or replies (or both)

E.g. retweets,replies
Expansions expansions Optional

A comma-separated list of additional data to return back in the response. See Twitter API Expansions for possible values or copy the example value here to get as much data back as possible.

E.g. attachments.poll_ids,attachments.media_keys,author_id,entities.mentions.username,geo.place_id,in_reply_to_user_id,referenced_tweets.id,referenced_tweets.id.author_id
Fields (Media) media_fields Optional

A comma-separated list of fields you would like back for media objects (photos, videos, etc…). See the Twitter API Media Model or just use the example value here to get back as much data as possible.

E.g. duration_ms,height,preview_image_url,public_metrics,width
Fields (Places) place_fields Optional

A comma-separated list of fields you would like back for places tagged in Tweets within the response. See the Twitter API Places Model for details or just use the example value here to get back as much data as possible.

E.g. contained_within,country,country_code,geo,name,place_type
Fields (Polls) poll_fields Optional

A comma-separated list of fields you to return for Tweets with attached polls. See the Twitter API Poll Model for details or just use the example value here to get back as much data as possible.

E.g. duration_minutes,end_datetime,voting_status
Fields (Tweets) tweet_fields Optional

A comma-separated list of fields you would like back for Tweets returned in the response. See the Twitter API Tweet Model for all possible values or just use the example value here to get as much data back as possible.

E.g. attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,public_metrics,possibly_sensitive,referenced_tweets,reply_settings,source,text,withheld
Fields (Users) user_fields Optional

A comma-separated list of fields you would like back for users in the response. See the Twitter API User Model for more information or just use the example value here to get as much data back as possible.

E.g. created_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,public_metrics,url,username,verified,withheld
Time Range (Ending Time) end_time Optional

End time range of the Tweets to fetch. This is exclusive, e.g. 2021-01-01T00:00:01Z will exclude the first second of 2021. Format is in YYYY-MM-DDTHH:mm:ssZ.

E.g. 2021-01-01T00:00:01Z
Time Range (Starting Time) start_time Optional

The starting timestamp of Tweets to return in the query. This is inclusive, so 2020-01-01T00:00:00 will include the first second of the new year.

E.g. 2020-01-01T00:00:00Z
Tweets or Mentions tweets_or_mentions Default tweets

Leave this as the default tweets to get back Tweets per the User Tweets Endpoint or change this to mentions to get back mentions per the Mentions Endpoint.

Limit limit Optional

How many results to return on each request.

📝 Notes

Twitter API V2 for getting all of a users Tweets (or mentions) from their timeline. See the Twitter API V2 User Tweets Endpoint for more information.

IMPORTANT Using pagination, only the most recent 3,200 Tweets can be returned or the most recent 800 mentions.

Posted by steve on Sept. 29, 2022, 6:30 a.m. 🚩  Report

⚡️ Endpoint

GET https://api.twitter.com/2/users/{{user_id}}/{{tweets_or_mentions}}?query={{query}}&max_results={{ limit }}&tweet.fields={{tweet_fields}}&user.fields={{user_fields}}&media.fields={{media_fields}}&poll.fields={{poll_fields}}&place.fields={{place_fields}}&expansions={{expansions}}&end_time={{end_time}}&start_time={{start_time}}&exclude={{ exclude }}&pagination_token={{pagination_token}}

Body

None

Headers

Authorization
Bearer {{access_token}}