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

# Backend API

> REST API for token prices and market data

## Overview

Express.js API with Redis caching for fetching token prices from on-chain oracles.

**Base URL:** `http://localhost:3001/api`

***

## Health Check

```bash theme={null}
GET /api/health
```

**Response:**

```json theme={null}
{
  "status": "ok",
  "redis": "connected",
  "blockchain": "connected"
}
```

***

## Get All Prices

```bash theme={null}
GET /api/prices
```

**Query Parameters:**

| Param   | Type    | Description                 |
| ------- | ------- | --------------------------- |
| `cache` | boolean | Set `false` to bypass cache |

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "prices": [
      {
        "symbol": "USDC",
        "name": "USD Coin",
        "address": "0x0A8d670EBE6a01Ed1623eA13Dd928e66051c8147",
        "price": "1.00",
        "decimals": 8
      },
      {
        "symbol": "WETH",
        "name": "Wrapped Ether",
        "address": "0x1875f28FfABbf325C75544FC30Dbb920b33619eE",
        "price": "2500.00",
        "decimals": 8
      },
      {
        "symbol": "WBTC",
        "name": "Wrapped Bitcoin",
        "address": "0xE78b8806b3f9833C3A3fDC942D3F9cE304946cfC",
        "price": "45000.00",
        "decimals": 8
      }
    ],
    "timestamp": 1701234567890,
    "cached": true
  }
}
```

***

## Get Price by Symbol

```bash theme={null}
GET /api/prices/:symbol
```

**Example:**

```bash theme={null}
curl http://localhost:3001/api/prices/weth
```

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "symbol": "WETH",
    "name": "Wrapped Ether",
    "price": "2500.00",
    "decimals": 8
  }
}
```

***

## Refresh Prices

```bash theme={null}
POST /api/prices/refresh
```

Forces a cache refresh for all token prices.

***

## Configuration

### Environment Variables

```env theme={null}
PORT=3001
NODE_ENV=development
RPC_URL=https://sepolia-rollup.arbitrum.io/rpc
CHAIN_ID=421614
REDIS_HOST=localhost
REDIS_PORT=6379
PRICE_CACHE_TTL=60
```

### Supported Tokens

| Symbol      | Name            | Oracle        |
| ----------- | --------------- | ------------- |
| USDC        | USD Coin        | `0x015300...` |
| WETH        | Wrapped Ether   | `0xd30e21...` |
| WBTC        | Wrapped Bitcoin | `0x56a43E...` |
| CRYPTOPUNKS | CryptoPunks     | `0xC7e820...` |

***

## Error Handling

```json theme={null}
{
  "success": false,
  "error": "Token not found"
}
```

HTTP status codes:

* `200` - Success
* `400` - Bad request
* `404` - Not found
* `500` - Server error
