X (Twitter) API
13 endpoints for accounts, posts and Spaces.
Every X (Twitter) endpoint, by group. Each is a GET under /v1/x.
Quick Reference
| Property | Value |
|---|---|
| Base path | /v1/x |
| Endpoints | 13 |
| Credits | See Below |
| Guide | X (Twitter) |
Accounts
GETProfile
/v1/x/profileAn account with its follower and post counts.1 creditGETProfile Highlights/v1/x/profile/highlightsThe posts an account highlighted, newest first.1 creditGETProfile Posts/v1/x/profile/postsAn account's posts and reposts, newest first.1 creditGETProfile Similar/v1/x/profile/similarAccounts like one, as X suggests them.1 creditCommunities
GETCommunity
/v1/x/communityA community with its members, rules and topic.1 creditGETCommunity Posts/v1/x/community/postsA community's top posts.1 creditPosts
GETPost
/v1/x/postOne post with its views, likes, replies and reposts.1 creditGETPost Comments/v1/x/post/commentsThe top replies to a post.1 creditGETPost Transcript/v1/x/post/transcriptA video post's captions as text.10 creditsDiscovery
GETTrending
/v1/x/trendingThe topics trending in a country, or worldwide.1 creditGETTrending Posts/v1/x/trending/postsThe posts trending on X today.1 creditLive
GETLive
/v1/x/liveA live video broadcast, running or ended.1 creditGETSpace/v1/x/spaceA Space with its hosts, speakers and audience.1 creditExample Request
Every X (Twitter) endpoint is called this way: its path, and what to read as query parameters.
import { SocialAPI } from "@socialapihq/sdk";
const client = new SocialAPI({ apiKey: process.env.SOCIALAPI_API_KEY });
const { data } = await client.x.profile({ handle: "NASA" });{
"data": {
"id": "11348282",
"username": "NASA",
"displayName": "NASA",
"bio": "Making the seemingly impossible, possible. ✨",
"avatarUrl": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_400x400.jpg",
"url": "https://x.com/NASA",
"verified": true,
"private": false,
"followers": 92078384,
"following": 115,
"likes": null,
"posts": 74589,
"externalUrl": "http://www.nasa.gov/",
"createdAt": "2007-12-19T20:20:32.000Z",
"ext": {
"bannerUrl": "https://pbs.twimg.com/profile_banners/11348282/1788992290",
"location": "Pale Blue Dot",
"blueVerified": true,
"verifiedType": "Government",
"verifiedSince": "2009-08-07T19:53:50.941Z",
"mediaPosts": 28267,
"highlights": 296,
"likesGiven": 17125,
"pinnedPosts": []
}
}
}Errors
A call that fails costs nothing. See Errors for every code.