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-user-posts.ts

25 lines · 1.1 KB · TypeScript
import { getUserPosts } from './client.ts'
import type { XGetUserPostsParams } from './client.ts'

/**
 * Read recent posts for an X user id (X API GET /users/:id/tweets).
 *
 * Defaults include `public_metrics` + `note_tweet` in tweet.fields; `text` is
 * normalized to note_tweet.text when present.
 *
 * @param params.id - User id
 * @param params.maxResults - Page size
 * @param params.postFields - Maps to X API `tweet.fields`
 * @param params.expansions - Defaults to author_id,referenced_tweets.id
 * @param params.originalsOnly - exclude=retweets,replies plus residual RT/@ cleanup
 * @param params.exclude - Raw X API exclude (ignored when originalsOnly)
 * @param params.authMode - bearer (default) or oauth
 * @returns Shaped posts list for GET /users/:id/tweets.
 * @example
 * import getUserPosts from 'kody:@kentcdodds/x/get-user-posts'
 * const posts = await getUserPosts({ id: '389681470', maxResults: 5, originalsOnly: true })
 * // => { data: [{ id: '...', text: '...' }], meta: { ... } }
 */
export default async function getUserPostsEntrypoint(params: XGetUserPostsParams = {}) {
	return await getUserPosts(params)
}