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

# RESTful API Getting Started

> Complete guide to querying the CloudQuant Data Liberator RESTful API using curl and standard HTTP tools.

# RESTful API getting started

The CloudQuant Data Liberator API provides RESTful endpoints for querying financial market data. The primary endpoint is `/liberator/query`, which accepts JSON payloads and returns data as JSON objects or Apache Arrow batches.

## Requirements

* `curl`
* `jq`
* `base64`
* Python with `pyarrow` (for Arrow format decoding)
* `pigz` (for compressed Arrow format)

## Authentication

All requests require user credentials and your Liberator base URL (both provided on your Profile page):

```bash theme={null}
URL=<your-base-url>
USER=TODO-ADD-YOUR-USERID-HERE
TOKEN=TODO-ADD-YOUR-TOKEN-HERE
```

<Note>
  As of release version 2.0, the P12 client certificate (`liberator.pfx`) is no longer required. The `--cert-type P12 --cert liberator.pfx` flags shown in the examples below are only needed for releases prior to 2.0.
</Note>

## Quick start: JSON queries

### Current value query

```bash theme={null}
curl -qs --cert-type P12 --cert liberator.pfx \
  -H "Content-Type: application/json" --noproxy '*' \
  --data '{"json_xfer":true,"symbols":["AAPL","IBM"],"name":"daily_bars","user":"'"$USER"'","token":"'"$TOKEN"'","system":"API","debug_stream":false}' \
  $URL/liberator/query
```

### Time range query

```bash theme={null}
curl -qs --cert-type P12 --cert liberator.pfx \
  -H "Content-Type: application/json" --noproxy '*' \
  --data '{"json_xfer":true,"symbols":"AAPL","name":"daily_bars","user":"'"$USER"'","token":"'"$TOKEN"'","system":"API","back_to":"2022-12-01","debug_stream":false}' \
  $URL/liberator/query
```

### Point-in-time query

```bash theme={null}
curl -qs --cert-type P12 --cert liberator.pfx \
  -H "Content-Type: application/json" --noproxy '*' \
  --data '{"json_xfer":true,"symbols":"AAPL","name":"daily_bars","user":"'"$USER"'","token":"'"$TOKEN"'","system":"API","as_of":"2022-12-15","debug_stream":false}' \
  $URL/liberator/query
```

## Advanced: Apache Arrow format

### Without compression

```bash theme={null}
BATCHES=$(curl -qs --cert-type P12 --cert liberator.pfx \
  -H "Content-Type: application/json" --noproxy '*' \
  --data '{"json_xfer":false,"compress":false,"symbols":["AAPL"],"back_to":"2023-01-01","debug_stream":false,"name":"daily_bars","user":"'"$USER"'","token":"'"$TOKEN"'","system":"API"}' \
  $URL/liberator/query | jq -r '.[] | select(type=="object") | .batch')
for BATCH in $BATCHES; do
    echo $BATCH | base64 -d | python -c "import sys; import pyarrow as pa; print(pa.ipc.open_stream(sys.stdin.buffer.read()).read_next_batch().to_pylist())"
done
```

### With compression

```bash theme={null}
BATCHES=$(curl -qs --cert-type P12 --cert liberator.pfx \
  -H "Content-Type: application/json" --noproxy '*' \
  --data '{"json_xfer":false,"compress":true,"symbols":["AAPL"],"back_to":"2023-01-01","debug_stream":false,"name":"daily_bars","user":"'"$USER"'","token":"'"$TOKEN"'","system":"API"}' \
  $URL/liberator/query | jq -r '.[] | select(type=="object") | .batch')
for BATCH in $BATCHES; do
    echo $BATCH | base64 -d | pigz -dz | python -c "import sys; import pyarrow as pa; print(pa.ipc.open_stream(sys.stdin.buffer.read()).read_next_batch().to_pylist())"
done
```

## Response format

Standard JSON response includes fields such as: `_seq`, `_dsname`, `timestamp`, `symbol`, `open`, `high`, `low`, `close`, `volume`, `vwap`, `spread`, `bidvol`, `askvol`, and `count`.
