Skip to content
← Public packages

@kentcdodds/x

X API v2 helpers for tweets, search, legacy DMs, and encrypted X Chat via a Fly XDK sidecar.

src/get-post.ts

21 lines · 1000 B · TypeScript
import { getPost } from './client.ts'
import type { XGetPostParams } from './client.ts'

/**
 * Read one X post by status id or x.com/twitter.com URL (GET /2/tweets/:id).
 *
 * Defaults: expansions author_id + referenced_tweets.id + referenced_tweets.id.author_id;
 * tweet.fields include public_metrics, note_tweet, created_at, conversation_id,
 * referenced_tweets, entities. Shapes `quotedPost` / `repliedToPost` / `retweetedPost`
 * from expansions when present. `text` prefers note_tweet.text.
 *
 * @param params.includeQuotePosts - When true, also GET /tweets/:id/quote_tweets
 *   (rate-limited; default max 10, hard cap 25). Prefer false and use quotedPost.
 * @example
 * import getPost from 'kody:@kentcdodds/x/get-post'
 * const post = await getPost({ url: 'https://x.com/kentcdodds/status/123' })
 * // => { data: { id, text, public_metrics, author?, quotedPost? }, ... }
 */
export default async function getPostEntrypoint(params: XGetPostParams = {}) {
	return await getPost(params)
}