메인 콘텐츠로 건너뛰기
뉴스 관련 작업을 위한 Client 이 Client는 X API의 뉴스 엔드포인트와 상호 작용하기 위한 메서드를 제공합니다. 인증, 요청 서식 지정, 응답 파싱을 처리하여 뉴스와 관련된 모든 작업을 수행합니다.

생성자

constructor

new NewsClient(client): NewsClient NewsClient 인스턴스를 생성합니다

매개변수

이름타입설명
clientClient주요 X API Client 인스턴스

반환

NewsClient

정의된 위치

news/client.ts:96

메서드

get

get(id, options): Promise<Response> ID로 뉴스 스토리를 가져옵니다. 주어진 ID를 사용해 뉴스 스토리를 가져옵니다.

매개변수

NameTypeDescription
idstring뉴스 기사의 식별자(id)입니다.
optionsGetOptions & { requestOptions: { raw: true } }-

반환

Promise<Response> API 응답으로 resolve되는 Promise이며, requestOptions.raw가 true인 경우에는 raw Response를 반환합니다.

정의 위치

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

매개변수

이름타입
idstring
options?GetOptions

반환 값

Promise<Get2NewsIdResponse>

정의된 위치

news/client.ts:154
search(query, options): Promise<Response> 뉴스 검색 지정된 검색 쿼리에 부합하는 뉴스 스토리 목록을 가져옵니다.

매개변수

NameTypeDescription
querystring검색 쿼리입니다.
optionsSearchOptions & { requestOptions: { raw: true } }-

반환값

Promise<Response> API 응답으로 resolve되는 Promise이며, requestOptions.rawtrue인 경우에는 원시 Response입니다.

정의 위치

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

매개변수

이름Type
querystring
options?SearchOptions

반환값

Promise<Get2NewsSearchResponse>

정의된 위치

news/client.ts:301