Skip to main content
Client for news operations This client provides methods for interacting with the news endpoints of the X API. It handles authentication, request formatting, and response parsing for all news related operations.

Constructors

constructor

new NewsClient(client): NewsClient Creates a new news client instance

Parameters

NameTypeDescription
clientClientThe main X API client instance

Returns

NewsClient

Defined in

news/client.ts:96

Methods

get

get(id, options): Promise<Response> Get news stories by ID Retrieves news story by its ID.

Parameters

NameTypeDescription
idstringThe ID of the news story.
optionsGetOptions & { requestOptions: { raw: true } }-

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

news/client.ts:141 get(id, options?): Promise<Get2NewsIdResponse>

Parameters

NameType
idstring
options?GetOptions

Returns

Promise<Get2NewsIdResponse>

Defined in

news/client.ts:154
search(query, options): Promise<Response> Search News Retrieves a list of News stories matching the specified search query.

Parameters

NameTypeDescription
querystringThe search query.
optionsSearchOptions & { requestOptions: { raw: true } }-

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

news/client.ts:288 search(query, options?): Promise<Get2NewsSearchResponse>

Parameters

NameType
querystring
options?SearchOptions

Returns

Promise<Get2NewsSearchResponse>

Defined in

news/client.ts:301