Platforms
X (Twitter)
Read X accounts with their posts and highlights, posts with their replies and transcripts, trends, communities, broadcasts and Spaces.
Read accounts with their posts, highlights and similar accounts, a post with its top replies and its video's transcript, what is trending in a country, communities with their top posts, live broadcasts and Spaces.
Quick Reference
| Property | Value |
|---|---|
| Endpoints | 13 |
| Accounts by | handle or url |
| Posts by | url or id |
| Communities, broadcasts, Spaces by | url or id |
| Posts a page | 20 |
| Transcripts | Yes |
| Counts | Views, likes, replies, reposts, quotes, bookmarks |
Accounts
| Endpoint | Returns | Credits |
|---|---|---|
profile | An account with its follower and post counts. | 1 |
profile/highlights | The posts an account highlighted, newest first. | 1 |
profile/posts | An account's posts and reposts, newest first. | 1 |
profile/similar | Accounts like one, as X suggests them. | 1 |
Read a Profile
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": []
}
}
}- A profile has its follower, following and post counts, and its media posts in
ext.mediaPosts. - Its
exthas its banner, location, checkmark (blueVerified,verifiedType), highlights, the likes it gave and its pinned posts. - A
handleis taken with or without@.
Account Lists
- Posts are the account's posts and reposts, newest first, 20 a page and about 600 in all. A repost has
ext.repost, with who reposted it and when. - Highlights are the posts the account highlighted, every one of them, 20 a page.
- Similar accounts are the 20 accounts X suggests beside it, each with its counts.
- A protected account's posts return
403 PRIVATE, at no cost.
Posts
| Endpoint | Returns | Credits |
|---|---|---|
post | One post with its views, likes, replies and reposts. | 1 |
post/comments | The top replies to a post. | 1 |
post/transcript | A video post's captions as text. | 10 |
Post Fields
- A post's
idis X's, the digits its link ends with. - The
statshave views, likes, comments (its replies), shares (its reposts) and saves (its bookmarks). - Its
ext.quotesis the posts quoting it, andext.quotedthe post it quotes. - Its text has its links written out in full, also listed in
ext.links, and a long post's whole text. - Its
mediais its images, videos and GIFs. A video'surlis its best MP4, andext.playlistsits HLS playlist.
Replies
A post's comments are its top replies, a few threads on one page. A reply to another reply names it as parentId, and a reply by the post's author has ext.byAuthor.
Transcripts
A video post's transcript is X's own caption track, as timed lines and as plain text. It is either the track uploaded with the video or the one X made from its speech, which has generated. A transcript costs 10 credits and is kept 30 days. A post without a video, or a video without captions, returns 404, at no cost.
Communities
| Endpoint | Returns | Credits |
|---|---|---|
community | A community with its members, rules and topic. | 1 |
community/posts | A community's top posts. | 1 |
- A community has its members, creation date, topic, rules, creator and the hashtags trending in it.
- Its posts are its 20 top posts, ranked by X, on one page.
Discovery
| Endpoint | Returns | Credits |
|---|---|---|
trending | The topics trending in a country, or worldwide. | 1 |
trending/posts | The posts trending on X today. | 1 |
- Trending takes
country, an ISO code (us,gb,tr), and is worldwide without one. Each topic has its search on X and, when X counts one, its volume of posts. - Trending posts are the day's trending posts worldwide, on one page.
Live
| Endpoint | Returns | Credits |
|---|---|---|
live | A live video broadcast, running or ended. | 1 |
space | A Space with its hosts, speakers and audience. | 1 |
- A broadcast is a live video, running or ended, with its viewers while it runs and its views in all.
- A Space is a live audio conversation, with its hosts, speakers, listeners and replays.
- Both have their stream's playlist in
ext: live while they run, their recording after.