# Market Data API

Reads prices, bars, news, and toplists. It does not place orders. aNewFN is not a broker.

Interactive page: https://anewfn.com/api/docs

## Authentication

- Header: `Authorization: Bearer <token>`
- Get a token: https://anewfn.com/api/keys (needs an account). The secret is shown once.

## Rate limits and errors

Authenticated requests are counted per API token. If you exceed the allowed rate, the API returns HTTP 429.
How long to wait: read the `Retry-After` response header (delay in seconds, RFC 7231). That is the only backoff signal.
The response body is JSON with `error: "rate_limit_exceeded"` so you can tell this 429 apart from other errors.
On successful responses, `x-ratelimit-*` headers describe remaining quota for the current window.
All uses of the same token share one limit (parallel scripts, jobs, or browser tabs all count together).

## Endpoints

### Market Sessions

- Method: `GET`
- Path template: `/v1/markets/{market}/session`

Returns market open/closed session times for a market and date range.

#### Request notes

Query params: `from` and `to` in YYYYMMDD.

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `from` (query), required: From date YYYYMMDD. Example: `20260101`
- `to` (query), required: To date YYYYMMDD. Example: `20260131`

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/session?from=20260101&to=20260131
```

#### Example response

```json
{
  "sessions": [
    {
      "date": "20260102",
      "active": true,
      "open": "08:00",
      "close": "16:30"
    },
    {
      "date": "20260103",
      "active": false,
      "open": "00:00",
      "close": "00:00"
    }
  ]
}
```

### Markets List

- Method: `GET`
- Path template: `/v1/markets`

Returns all configured markets.

#### Parameters

- None

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets
```

#### Example response

```json
[
  {
    "symbol": "L",
    "name": "London Stock Exchange",
    "timezone": "Europe/London"
  },
  {
    "symbol": "BATS",
    "name": "BATS",
    "timezone": "America/New_York"
  },
  {
    "symbol": "FX",
    "name": "Foreign Exchange",
    "timezone": "UTC"
  }
]
```

### Bars

- Method: `GET`
- Path template: `/v1/markets/{market}/{symbol}/bars/{timeframe}`

Returns historical OHLCV bars for a symbol and timeframe.

#### Request notes

Query params: `from` and `to` (YYYYMMDD for daily bars, or minute resolution for intraday timeframes).

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `symbol` (path), required: Ticker symbol. Example: `VOD`
- `timeframe` (path), required: Bar timeframe. Example: `1d`
- `from` (query), required: From date/time. Example: `20260101`
- `to` (query), required: To date/time. Example: `20260131`

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/VOD/bars/1d?from=20260101&to=20260131
```

#### Example response

```json
{
  "bars": [
    {
      "tsOpen": 1767225600000,
      "open": 1.2,
      "high": 1.25,
      "low": 1.18,
      "close": 1.24,
      "volume": 1234567
    }
  ]
}
```

### Market news (list)

- Method: `GET`
- Path template: `/v1/markets/{market}/news`

Returns a page of market news articles for the exchange, optionally filtered to one ticker. Results are ordered by recency (newest first).

#### Request notes

Pagination: `page` (default 0), `pageSize` (default 20, max 100). Optional `symbol` filters to one ticker. Each article’s `symbols[].market` matches `{market}`.

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `page` (query): Page index (0-based). Example: `0`
- `pageSize` (query): Page size (max 100). Example: `20`
- `symbol` (query): Optional ticker filter. Example: ``

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/news?page=0&pageSize=20
```

#### Example response

```json
{
  "articles": [
    {
      "id": "69c3f1d87b79d33a193dbeeb",
      "title": "Example headline",
      "slug": "example-headline",
      "snippet": "Short summary text.",
      "symbols": [
        {
          "id": "734adeb5-3f10-4b5c-a45f-b3862d5b2bc4",
          "symbol": "VOD",
          "market": "L"
        }
      ],
      "timestamp": 1775039383000
    }
  ],
  "page": 0,
  "pageSize": 20,
  "hasMore": true
}
```

### Market news (by symbol)

- Method: `GET`
- Path template: `/v1/markets/{market}/{symbol}/news`

Returns news articles for a specific ticker. Equivalent to calling the list endpoint with `symbol` in the query string.

#### Request notes

Same pagination and response shape as the list endpoint.

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `symbol` (path), required: Ticker symbol. Example: `VOD`
- `page` (query): Page index (0-based). Example: `0`
- `pageSize` (query): Page size (max 100). Example: `20`

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/VOD/news?page=0&pageSize=20
```

#### Example response

```json
{
  "articles": [
    {
      "id": "69c3f1d87b79d33a193dbeeb",
      "title": "Example headline",
      "slug": "example-headline",
      "snippet": "Short summary text.",
      "symbols": [
        {
          "id": "734adeb5-3f10-4b5c-a45f-b3862d5b2bc4",
          "symbol": "VOD",
          "market": "L"
        }
      ],
      "timestamp": 1775039383000
    }
  ],
  "page": 0,
  "pageSize": 50,
  "hasMore": false
}
```

### Market news (article)

- Method: `GET`
- Path template: `/v1/markets/{market}/news/{articleId}`

Returns a single news article by id for that market.

#### Request notes

404 when the article is unavailable for this market.

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `articleId` (path), required: Article id. Example: `69c3f1d87b79d33a193dbeeb`

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/news/69c3f1d87b79d33a193dbeeb
```

#### Example response

```json
{
  "article": {
    "id": "69c3f1d87b79d33a193dbeeb",
    "title": "Example headline",
    "slug": "example-headline",
    "snippet": "Short summary text.",
    "content": "[]",
    "symbols": [
      {
        "id": "734adeb5-3f10-4b5c-a45f-b3862d5b2bc4",
        "symbol": "VOD",
        "market": "L"
      }
    ],
    "extra": "{}",
    "timestamp": 1775039383000
  }
}
```

### Quote

- Method: `GET`
- Path template: `/v1/markets/{market}/{symbol}/quote`

Returns market snapshot quote payload for a symbol.

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `symbol` (path), required: Ticker symbol. Example: `VOD`

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/VOD/quote
```

#### Example response

```json
{
  "timestamp": 1775039383,
  "last_trade_timestamp": "1775039374",
  "trading_status": "OPEN",
  "open_price": "114",
  "high_price": "115.25",
  "low_price": "113.45",
  "previous_close_price": "113.3",
  "current_price": "115",
  "last_trade_price": "115",
  "current_price_ma_15": "115.03",
  "bid_price": "115",
  "ask_price": "115.1",
  "bid_size": "57575",
  "ask_size": "52727",
  "volume": "10850860.91252143",
  "num_trades": "2654"
}
```

### Trades

- Method: `GET`
- Path template: `/v1/markets/{market}/{symbol}/trades`

Returns market trades snapshot payload for a symbol.

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `symbol` (path), required: Ticker symbol. Example: `VOD`

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/VOD/trades
```

#### Example response

```json
{
  "requestSymbol": "VOD",
  "timestamp": 1767225600,
  "trades": [
    {
      "price": "100.51",
      "size": "5000"
    }
  ]
}
```

### Level2

- Method: `GET`
- Path template: `/v1/markets/{market}/{symbol}/level2`

Returns level2 order-book style snapshot payload for a symbol.

#### Request notes

Requires L2 entitlement.

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `symbol` (path), required: Ticker symbol. Example: `VOD`

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/VOD/level2
```

#### Example response

```json
{
  "level": "2",
  "requestSymbol": "VOD",
  "timestamp": 1767225600,
  "ticker": "VOD",
  "orderLevels": [
    {
      "price": "100.50",
      "volume": "12000"
    }
  ]
}
```

### Toplist

- Method: `GET`
- Path template: `/v1/markets/{market}/toplists/{id}`

Returns a ranked toplist. Each `entries` item uses the same fields as the quote snapshot for one symbol.

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `id` (path), required: Which toplist to return: 0–9 (see option labels for each ranking).. Example: `4`

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/toplists/4
```

#### Example response

```json
{
  "level": "L",
  "requestSymbol": "4",
  "timestamp": 1767225600,
  "entries": [
    {
      "symbol": "VOD",
      "timestamp": 1775039383,
      "last_trade_timestamp": "1775039374",
      "trading_status": "OPEN",
      "open_price": "114",
      "high_price": "115.25",
      "low_price": "113.45",
      "previous_close_price": "113.3",
      "current_price": "115",
      "last_trade_price": "115",
      "current_price_ma_15": "115.03",
      "bid_price": "115",
      "ask_price": "115.1",
      "bid_size": "57575",
      "ask_size": "52727",
      "volume": "10850860.91252143",
      "num_trades": "2654"
    }
  ]
}
```

### Intraday

- Method: `GET`
- Path template: `/v1/markets/{market}/{symbol}/intraday`

Returns intraday OHLCV-style periods for a symbol.

#### Request notes

Response includes a `periods` array.

#### Parameters

- `market` (path), required: Market symbol (`L` London, `BATS` US, `FX` Forex). Example: `L`
- `symbol` (path), required: Ticker symbol. Example: `VOD`

#### Example request URL

```text
https://market-data.anewfn.com/v1/markets/L/VOD/intraday
```

#### Example response

```json
{
  "periods": [
    {
      "timestamp": "1767225600",
      "open": "100.40",
      "high": "100.90",
      "low": "100.20",
      "close": "100.55",
      "volume": "1234567"
    }
  ]
}
```

### Symbols (search or bulk)

- Method: `GET`
- Path template: `/v1/symbols`

Catalog: search symbols with `q` and pagination, or bulk-load with comma-separated `market:symbol` in `symbols`. For live quotes and bars, use `/v1/markets/{market}/{symbol}/…` instead.

#### Request notes

Use `q` with optional `page` and `pageSize` for search, or `symbols` (e.g. `L:VOD,BATS:AAPL`) for bulk load. Do not combine both in one request.

#### Parameters

- `q` (query): Search text (search mode). Example: `vod`
- `symbols` (query): Comma-separated market:symbol (bulk mode; leave empty when using q). Example: ``
- `page` (query): Zero-based page (search). Example: `0`
- `pageSize` (query): Page size (search). Example: `20`

#### Example request URL

```text
https://market-data.anewfn.com/v1/symbols?q=vod&page=0&pageSize=20
```

#### Example response

```json
{
  "page": 0,
  "pageSize": 20,
  "totalHits": 1,
  "totalPages": 1,
  "items": [
    {
      "symbol": {
        "symbol": "VOD",
        "marketSymbol": "L",
        "currency": "GBP"
      },
      "instrument": {
        "id": 12345,
        "name": "Vodafone Group",
        "instrumentType": "equity"
      },
      "issuer": {
        "id": 1,
        "type": "company",
        "name": "Example plc",
        "countryOfRegistration": "GB",
        "companyId": "12345678",
        "website": "https://example.com",
        "summary": "Example plc builds industrial equipment."
      }
    }
  ]
}
```

### Symbol by id

- Method: `GET`
- Path template: `/v1/symbols/{symbolId}`

Returns one catalog symbol row by UUID (`symbol.id`) and its instrument. Ticker-level live data uses `/v1/markets/{market}/{symbol}/…`, not this path.

#### Parameters

- `symbolId` (path), required: Symbol row UUID. Example: `8bcf0b5c-3098-42ed-a71e-3a9a4a68017d`

#### Example request URL

```text
https://market-data.anewfn.com/v1/symbols/8bcf0b5c-3098-42ed-a71e-3a9a4a68017d
```

#### Example response

```json
{
  "symbol": {
    "symbol": "VOD",
    "marketSymbol": "L",
    "currency": "GBP"
  },
  "instrument": {
    "id": 12345,
    "name": "Vodafone Group",
    "instrumentType": "equity"
  },
  "issuer": {
    "id": 1,
    "type": "company",
    "name": "Example plc",
    "countryOfRegistration": "GB",
    "companyId": "12345678",
    "website": "https://example.com",
    "summary": "Example plc builds industrial equipment."
  }
}
```

### Instrument by id

- Method: `GET`
- Path template: `/v1/instruments/{instrumentId}`

Returns a JSON array of catalog rows, same shape as symbol by id: one object per listing symbol for this instrument (each includes `symbol`, `instrument`, `issuer`).

#### Parameters

- `instrumentId` (path), required: Instrument id. Example: `12345`

#### Example request URL

```text
https://market-data.anewfn.com/v1/instruments/12345
```

#### Example response

```json
[
  {
    "symbol": {
      "symbol": "VOD",
      "marketSymbol": "L",
      "currency": "GBP"
    },
    "instrument": {
      "id": 12345,
      "name": "Vodafone Group",
      "instrumentType": "equity"
    },
    "issuer": {
      "id": 1,
      "type": "company",
      "name": "Example plc",
      "countryOfRegistration": "GB",
      "companyId": "12345678",
      "website": "https://example.com",
      "summary": "Example plc builds industrial equipment."
    }
  }
]
```

### Corporate actions (by instrument)

- Method: `GET`
- Path template: `/v1/instruments/{instrumentId}/corporate-actions`

Lists corporate actions for one instrument.

#### Request notes

`items` is ordered newest first. Each row: `id`, `type` (`issue`), `issuerId`, `instrumentId`, `quantity` (decimal string), `actionTimestamp` (Unix seconds when the action applies, or null), `createdTimestamp`, `updatedTimestamp` (Unix seconds, or null).

#### Parameters

- `instrumentId` (path), required: `instrument.id` from a catalog instrument object. Example: `12345`

#### Example request URL

```text
https://market-data.anewfn.com/v1/instruments/12345/corporate-actions
```

#### Example response

```json
{
  "items": [
    {
      "id": 42,
      "type": "issue",
      "issuerId": 1,
      "instrumentId": 100,
      "quantity": "1000000",
      "actionTimestamp": 1700000000,
      "createdTimestamp": 1700000100,
      "updatedTimestamp": 1700000101
    }
  ]
}
```

### Corporate action by id

- Method: `GET`
- Path template: `/v1/corporate-actions/{corporateActionId}`

Returns one corporate action by id.

#### Request notes

Same fields as list rows; response is `{ "corporateAction": { … } }`. `404` if not found.

#### Parameters

- `corporateActionId` (path), required: `id` from a corporate-action list element. Example: `42`

#### Example request URL

```text
https://market-data.anewfn.com/v1/corporate-actions/42
```

#### Example response

```json
{
  "corporateAction": {
    "id": 42,
    "type": "issue",
    "issuerId": 1,
    "instrumentId": 100,
    "quantity": "1000000",
    "actionTimestamp": 1700000000,
    "createdTimestamp": 1700000100,
    "updatedTimestamp": 1700000101
  }
}
```

### Contribute (get)

- Method: `GET`
- Path template: `/v1/contribute/{type}/{id}`

Returns current field values for one issuer, instrument, or corporate action (read only). Submit edits with `POST /v1/contribute`.

#### Request notes

`type`: `issuer`, `instrument`, or `corporate_action`; `id` is the row key. `corporate_action` fields include `id`, `type` (`issue`, `cancel`, `dividend`), `issuerId`, `instrumentId`, `quantity` (share count for issue/cancel), optional `data` (JSON string; dividends use `amount_per_share`, `dividend_type`, `currency`, dates), optional `actionTimestamp` (Unix seconds). `404` if there is no row for that `type` and `id`.

#### Parameters

- `type` (path), required: Row type. Example: `issuer`
- `id` (path), required: Row id. Example: `1`

#### Example request URL

```text
https://market-data.anewfn.com/v1/contribute/issuer/1
```

#### Example response

```json
{
  "fields": {
    "type": "company",
    "name": "Example plc",
    "countryOfRegistration": "GB",
    "companyId": "12345678",
    "website": "https://example.com",
    "summary": "Example plc builds industrial equipment."
  }
}
```

### Contribute (submit)

- Method: `POST`
- Path template: `/v1/contribute`

Submits a batch of contribute operations for admin review. Each op is `{ op, type, fields }` with `id` on update/delete, and optional `ref` on issuer create for later `{ "issuerId": { "$ref": "…" } }` links.

#### Request notes

Body `{ "ops": [ … ] }`, max 40 ops. `corporate_action`: create needs full `fields` (`type`, `issuerId`, `instrumentId`, plus `quantity` for issue/cancel or `data` with `amount_per_share` for `dividend`; optional `actionTimestamp`). Update sends `id` plus fields to merge. Delete sends `op`, `type: "corporate_action"`, and `id` only (omit `fields`). Validation errors respond `400` with `error`.

#### Parameters

- None

#### Example request URL

```text
https://market-data.anewfn.com/v1/contribute
```

#### Example response

```json
{
  "contributionId": "42"
}
```

### Corporate actions (by issuer)

- Method: `GET`
- Path template: `/v1/issuers/{issuerId}/corporate-actions`

Lists corporate actions for one issuer.

#### Request notes

Same `{ "items": [ … ] }` shape and ordering as `/v1/instruments/{instrumentId}/corporate-actions`.

#### Parameters

- `issuerId` (path), required: `issuer.id` from a catalog issuer object. Example: `1`

#### Example request URL

```text
https://market-data.anewfn.com/v1/issuers/1/corporate-actions
```

#### Example response

```json
{
  "items": [
    {
      "id": 42,
      "type": "issue",
      "issuerId": 1,
      "instrumentId": 100,
      "quantity": "1000000",
      "createdTimestamp": 1700000000,
      "updatedTimestamp": 1700000001
    }
  ]
}
```

### Issuer by id

- Method: `GET`
- Path template: `/v1/issuers/{issuerId}`

Returns issuer catalog metadata by numeric id (same shape as `issuer` on symbol and instrument payloads).

#### Request notes

Corporate actions: `/v1/issuers/{issuerId}/corporate-actions`, `/v1/instruments/{instrumentId}/corporate-actions`, `/v1/corporate-actions/{corporateActionId}`.

#### Parameters

- `issuerId` (path), required: `issuer.id` from a `symbol` or `instrument` payload. Example: `1`

#### Example request URL

```text
https://market-data.anewfn.com/v1/issuers/1
```

#### Example response

```json
{
  "id": 1,
  "type": "company",
  "name": "Example plc",
  "countryOfRegistration": "GB",
  "companyId": "12345678",
  "website": "https://example.com",
  "summary": "Example plc builds industrial equipment."
}
```
