# Generate client-facing APIs

Get client-facing APIs with JSON, CSV or TSV for your saved queries.

Go to **Warehouse** -> [Queries as APIs](https://warehouse.betterstack.com/team/t0/queries ";_blank") -> [Create query](https://warehouse.betterstack.com/team/t0/queries/new ";_blank").

![Creating a client-facing API](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/dbd96614-cbc8-41e5-037b-4fd21cbf2500/md2x =4146x2448)

Here, you can select your [JSON events or time series](https://betterstack.com/docs/warehouse/ingesting-data/s3-vs-nvme/) source, and query your data. We'll give you a **quick visualization** along with the full results.

![Visualization and data](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/1aa908d0-3ff6-4a0f-0ed9-561fb696cf00/public =3516x2354)

As soon as the query is saved, **we'll generate a secure publicly-accessible URL** you can use as API 🚀

You can regenerate the URL at any time.

## JSON, CSV or TSV

Adjust the API to use a different **Format**.

![Adjusting format](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/339d76e6-e62e-47b6-1a47-30ab5cb42c00/lg1x =4146x2448)

For your convenience, we always generate API for all supported formats:

[code-tabs]
```bash
[label JSON export]
curl "https://$CLUSTER.betterstackdata.com/query/$SECRET.json"
```
```bash
[label CSV export]
curl "https://$CLUSTER.betterstackdata.com/query/$SECRET.csv"
```
```bash
[label TSV export]
curl "https://$CLUSTER.betterstackdata.com/query/$SECRET.tsv"
```
[/code-tabs]

## Pass variables into your saved queries

Specify any `{{variable}}`, e.g. `{{currency}}`, in your SQL query and we'll parameterize your API automatically.

![Define variables in your API](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/4bb71a78-1399-44b3-01f8-61e062d92800/lg1x =4146x2448)

And **set the value of `currency` as a query parameter** when calling the API:

[code-tabs]
```bash
[label Pass variable in URL]
curl "https://$CLUSTER.betterstackdata.com/query/$SECRET.json?currency=EUR"
```
```bash
[label Use --data-urlencode]
curl "https://$CLUSTER.betterstackdata.com/query/$SECRET.json" \
  --get \
  --data-urlencode "currency=EUR"
```
```bash
[label Multiple variables]
curl "https://$CLUSTER.betterstackdata.com/query/$SECRET.json" \
  --get \
  --data-urlencode "currency=EUR"
  --data-urlencode "country=DE"
```
[/code-tabs]

You can even use **multiple variables** in a single query!

## Optimized for high request throughput

Better Stack Warehouse client-facing APIs are optimized for many HTTP requests. They will survive your website making it to the homepage of Reddit.

### Customize cache frequency

![Customize cache frequency](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/7dea6f48-6d5f-48ba-79eb-b86f67687100/md2x =4146x2448)