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-dm-conversation.ts

20 lines · 910 B · TypeScript
import { getDmConversation } from './client.ts'
import type { XGetDmConversationParams } from './client.ts'

/**
 * Read DM events for one conversation, addressed by conversation id, or by the
 * other participant's user id or username (1-1 conversations).
 * OAuth user-context only; requires the dm.read scope.
 *
 * Limitation: this hits legacy `/dm_conversations/.../dm_events`. For
 * encrypted X Chat plaintext use `get-chat-conversation`.
 *
 * @returns Shaped DM events for the conversation.
 * @example
 * import getDmConversation from 'kody:@kentcdodds/x/get-dm-conversation'
 * const events = await getDmConversation({ username: 'kentcdodds', maxResults: 10 })
 * // => { data: [{ id: '...', event_type: 'MessageCreate', text: '...' }], meta: { ... } }
 */
export default async function getDmConversationEntrypoint(params: XGetDmConversationParams = {}) {
  return await getDmConversation(params)
}