> For the complete documentation index, see [llms.txt](https://gloriaai.gitbook.io/gloria/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gloriaai.gitbook.io/gloria/docs/gloria-data-platform/x402-integration.md).

# x402 Integration

Gloria X402 API is a micropayment-enabled news API that leverages the X402 protocol to provide access to real-time crypto news feeds and AI-powered summaries.

### Endpoints Overview

| Endpoint             | Price (USDC) | Description                             |
| -------------------- | ------------ | --------------------------------------- |
| /news                | $0.03        | Last news headlines by category         |
| /news-ticker-summary | $0.031       | AI-powered 24h news summary for a token |
| /news-by-keyword     | $0.05        | Search news by keyword                  |
| /recaps              | $0.10        | 12-24h news recap by category           |

***

### **News API**

Get the latest news headlines for a covered news topic, delivering the most recent 10 headlines.

#### Endpoint

```
GET /news
```

Price per request is $0.03.

#### Query Parameters

| Parameter         | Type     | Description                                                                                 |
| ----------------- | -------- | ------------------------------------------------------------------------------------------- |
| `feed_categories` | `string` | Required. Comma separated list of feed categories.                                          |
| `from_date`       | `string` | Optional. Get the news from this date, ISO format (`YYYY-MM-DD`). Defaults to `2025-05-01`. |
| `to_date`         | `string` | Optional. Get the news up to this date, ISO format (`YYYY-MM-DD`). Defaults to `today`.     |

#### Available Feeds

See [Available Feeds](/gloria/docs/gloria-data-platform/api-integration.md#feed-categories) section in REST API.

#### Response Format

See [Response Format](/gloria/docs/gloria-data-platform/api-integration.md#response-format) section in REST API.

***

### **News Ticker Summary API**

Get a 24-hour news summary for a specific token/ticker, combining internal news data with web search results. Returns decision-grade bullet points for fund managers and trading agents.

**Endpoint:** `GET /news-ticker-summary`

**Price per request:** $0.031

**Query Parameters**

| Parameter | Type   | Description                                                            |
| --------- | ------ | ---------------------------------------------------------------------- |
| `ticker`  | string | **Required.** Token symbol or name (e.g., ZRO, LayerZero, SOL, Solana) |

#### Response Format

```json
{
  "summary": "• Bullet point 1\n• Bullet point 2\n• Bullet point 3..."
}
```

***

### **Recaps API**

Get a recap/summary of the news for a covered news topic over the past 12-24 hours.

#### Endpoint

```
GET /recaps
```

Price per request is $0.10.

#### Query Parameters

| Parameter       | Type     | Description                         |
| --------------- | -------- | ----------------------------------- |
| `feed_category` | `string` | The feed category to get recap for. |

#### Available Feeds

See [Available Feeds](/gloria/docs/gloria-data-platform/api-integration.md#feed-categories) section in REST API.

#### Response Format

See [Recaps Response Format](/gloria/docs/gloria-data-platform/api-integration.md#response-format-1) section in REST API.

***

### News by Keyword API

Search news articles by keyword, returning the most recent headlines matching your query.

#### Endpoint

```
GET /news-by-keyword
```

Price per request is $0.05.

#### Query Parameters

| Parameter | Type     | Description                |
| --------- | -------- | -------------------------- |
| `keyword` | `string` | The keyword to search for. |

#### Available Feeds

See [Available Feeds](/gloria/docs/gloria-data-platform/api-integration.md#feed-categories) section in REST API.

#### Response Format

See [Response Format](/gloria/docs/gloria-data-platform/api-integration.md#response-format) section in REST API.

***

### Payment Integration

#### X402 Protocol

The API uses the X402 protocol for micropayments. Each request requires a payment to proceed.

#### Payment Flow

1. Client makes request to `/news` endpoint
2. Server responds with payment challenge (402 Payment Required)
3. Client processes payment using X402 protocol
4. Client retries request with payment proof
5. Server validates payment and serves content

Currently, only payments in **USDC on Base network** are supported. More coming soon.

#### Client Implementation

You can find more information on how to implement the client on [x402.gitbook.io](https://x402.gitbook.io/x402/getting-started/quickstart-for-buyers).

#### Example Implementation

```javascript
import { wrapFetchWithPayment } from "x402-fetch";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";

const account = privateKeyToAccount("0x...");
const walletClient = createWalletClient({
  account,
  chain: base,
  transport: http(),
});

const fetchWithPayment = wrapFetchWithPayment(fetch, walletClient);

// Get latest crypto news
const newsResponse = await fetchWithPayment(
  "https://api.itsgloria.ai/news?feed_categories=crypto"
);

// Get 24h summary for a token
const summaryResponse = await fetchWithPayment(
  "https://api.itsgloria.ai/news-ticker-summary?ticker=SOL"
);

// Search news by keyword
const keywordResponse = await fetchWithPayment(
  "https://api.itsgloria.ai/news-by-keyword?keyword=bitcoin"
);

// Get category recap
const recapResponse = await fetchWithPayment(
  "https://api.itsgloria.ai/recaps?feed_category=defi"
);
```

***

#### Status Codes

| Status Code | Description                                            |
| ----------- | ------------------------------------------------------ |
| `200`       | Success                                                |
| `400`       | Bad Request (invalid parameters)                       |
| `402`       | Payment required                                       |
| `404`       | Not Found (no data found for the specified parameters) |
