> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# NewsClient

> Methods for X API v2 News endpoints.

Access **News** endpoints via `client.news()` (`NewsClient`).

## Methods

| Method | Endpoint | Behavior | Summary |
| :- | :- | :- | :- |
| [`get`](#get) | `GET /2/news/{id}` | Standard | Get News Stories by ID |
| [`search`](#search) | `GET /2/news/search` | Standard | Search News |

## `get`

GET `/2/news/{id}`

**Get News Stories by ID**

Retrieves news story by its ID.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

var response = client.news().get("1895000000000000000");
System.out.println(response);
```

### Parameters

**id** `String` *required*

`id` (path parameter).

**Optional parameters (NewsClient.GetOptions — 1)**

**options.newsFields** `List\<String\>`

A comma separated list of News fields to display.

**Returns:** `Schemas.GetNewsResponse`

***

## `search`

GET `/2/news/search`

**Search News**

Retrieves a list of News stories matching the specified search query.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

var response = client.news().search("from:XDevelopers");
System.out.println(response);
```

### Parameters

**query** `String` *required*

`query` (query parameter).

**Optional parameters (NewsClient.SearchOptions — 3)**

**options.maxResults** `Integer`

`max_results` (query parameter).

**options.maxAgeHours** `Integer`

`max_age_hours` (query parameter).

**options.newsFields** `List\<String\>`

A comma separated list of News fields to display.

**Returns:** `Schemas.SearchNewsResponse`

***
