# Price API

> Provides real-time and historical price data for tokens listed on PiperX. > Supports querying tokens without transactions (price = 0) and up to 7 days of hourly snapshots.

### 1. Get All Tokens

Fetch all tokens and their latest price on PiperX (V2 & V3), including tokens without transactions.

**Endpoint**

<mark style="color:blue;background-color:purple;">**`[GET]`**</mark>  `https://piperxdb.piperxprotocol.workers.dev/api/piperxapi/getAllTokens`

**Example Request**

```json
curl https://piperxdb.piperxprotocol.workers.dev/api/piperxapi/getAllTokens
```

**Example Response**

```json
{
  "tokens": [
    {
      "id": "0x1514000000000000000000000000000000000000",
      "name": "Wrapped IP",
      "symbol": "WIP",
      "decimals": 18,
      "latestPriceUSD": "6757786",
      "latestPriceNative": "1000000000000000000"
    }
  ]
}
```

### 2. Get Historical Token Prices

Fetch 24-hour and 7-day price history of one or more tokens.

**Endpoint**

<mark style="color:blue;background-color:purple;">**`[POST]`**</mark>  `https://piperxdb.piperxprotocol.workers.dev/api/piperxapi/getAllTokenPrices`

**Request Body**

```json
{
  "addresses": ["0x1514000000000000000000000000000000000000"]
}
```

> **Note**: If the `addresses` field is omitted or left empty, the API will return historical price data for **all tokens**.

**Example Request**

```json
curl -X POST \
-H "Content-Type: application/json" \
-d '{"addresses": ["0x1514000000000000000000000000000000000000"]}' \
https://piperxdb.piperxprotocol.workers.dev/api/piperxapi/getAllTokenPrices
```

**Example Response**

```json
{
  "tokens": {
    "0x1514000000000000000000000000000000000000": {
      "symbol": "WIP",
      "now": "4.450893",
      "1h": "4.466922",
      "2h": "4.466922",
      "3h": "4.4358",
      "4h": "4.462126",
      "5h": "4.546206",
      "6h": "4.608218",
      "7h": "4.601109",
      "8h": "4.783078",
      "9h": "4.622222",
      "10h": "4.315662",
      "11h": "4.325639",
      "12h": "4.380279",
      "13h": "4.229204",
      "14h": "4.170735",
      "15h": "4.171767",
      "16h": "4.232448",
      "17h": "4.249791",
      "18h": "4.262093",
      "19h": "4.286277",
      "20h": "4.256168",
      "21h": "4.217988",
      "22h": "4.285186",
      "23h": "4.31172",
      "24h": "4.305063",
      "1d": "4.170735",
      "2d": "4.352007",
      "3d": "4.619924",
      "4d": "3.493126",
      "5d": "3.099228",
      "6d": "3.043802",
      "7d": "3.190185"
    }
  },
  "timestamp": 1752495887019
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.piperx.xyz/developer/api/price-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
