> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.drazill.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.drazill.com/_mcp/server.

# Google Sheets

Two custom functions put Drazill market data in any Google Sheet. They call the same
public endpoints documented in this reference — no private surface, no shared
credential, no server in the middle.

```text
=DRAZILL("boc-rate-cut-september")            → 0.62
=DRAZILL("boc-rate-cut-september", "title")   → Will the Bank of Canada cut rates in September?
=DRAZILLHIST("boc-rate-cut-september", 30)    → 30 days of daily closes, one column per outcome
```

> **Info**
>
> The add-on is **read-only**. It cannot place an order, move money, or read your
> balance — and it requests no Google permission that would let it write to your
> spreadsheet.

## The formulas

### `=DRAZILL(market, [field], [outcome])`

| Argument  | Accepts                                                                                 |
| --------- | --------------------------------------------------------------------------------------- |
| `market`  | A market slug, a market id, a pasted market URL — or a **range** of them.               |
| `field`   | `price` (default), `title`, `volume`, `closes_at`, `status`.                            |
| `outcome` | For `price`: the outcome to price, e.g. `"No"`. Defaults to the market's first outcome. |

```text
=DRAZILL("boc-rate-cut-september")                    the first outcome's price
=DRAZILL("boc-rate-cut-september", "price", "No")     a named outcome
=DRAZILL("boc-rate-cut-september", "closes_at")       the close time, as a date
=DRAZILL(A2:A50)                                      a whole column, in one batch
```

Passing a range is not just shorthand: every market in it is fetched in a **single**
batched request, and a market repeated inside the range is fetched once. A column of
fifty markets costs one round trip, not fifty.

### `=DRAZILLHIST(market, [days])`

Spills a header row (`Date`, then one column per outcome) followed by one row per day
of daily closing prices. `days` defaults to 30.

A day an outcome has no recorded point is left **blank** — never zero-filled and never
carried forward from the previous day, so a gap in the data reads as a gap.

## Your key, and only yours

You supply your own API key. It is stored per **Google account**, in the add-on's
per-user property store — not in a cell, not in a shared script store, and not on any
Drazill server beyond the key you already minted.

> **Warning**
>
> Sharing a sheet shares the **values** your formulas produced, because those values
> live in the cells. It never shares your key. For a collaborator to *refresh* those
> cells, they set their own key in the same sidebar.

A key is required rather than optional. Anonymous reads are limited **per IP**
([Rate limits](/rate-limits)), and Google Apps Script calls out from shared egress
ranges — so an unkeyed add-on would share one anonymous bucket with every other Apps
Script user calling Drazill. With your key, you get your own per-key limit and quota.

Requests carry three headers and nothing else: `X-API-Key`, `Accept`, and a static
`User-Agent`. No document id, user id, or email address is sent.

## Environments

| Environment           | Base URL                      | Keys         |
| --------------------- | ----------------------------- | ------------ |
| Staging (the default) | `https://staging.drazill.com` | `drzl_test_` |
| Production            | `https://api.drazill.com`     | `drzl_live_` |

The add-on ships pointed at **staging**; production is a choice you make in the
sidebar. Both hosts are pinned in the Apps Script manifest, so the add-on cannot fetch
anywhere else. Start at [Get an API key](/get-a-key).

## When a cell cannot be fetched

Cells show a `#DRAZILL: …` message that names the real condition. They never show a
stale number, a zero, or a guess.

| Cell                                                           | Means                                                                    |
| -------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `#DRAZILL: no API key — Extensions ▸ Drazill ▸ Set API key`    | No key saved for your account yet.                                       |
| `#DRAZILL: unknown market`                                     | No market with that slug or id.                                          |
| `#DRAZILL: rate limited — retry in 30s`                        | A `429`; the wait comes from the `Retry-After` header.                   |
| `#DRAZILL: key rejected — Extensions ▸ Drazill ▸ Set API key`  | A `401`.                                                                 |
| `#DRAZILL: key not allowed to read markets — check its scopes` | A `403`.                                                                 |
| `#DRAZILL: Drazill returned 503 — no data`                     | An upstream failure, with the real status.                               |
| `#DRAZILL: no outcome named "Maybe"`                           | Argument 3 matched no outcome — it never silently prices the other side. |

## What it calls

Everything above runs on endpoints that already exist. The add-on adds nothing to the
API:

| Endpoint                                        | Used for                          |
| ----------------------------------------------- | --------------------------------- |
| `GET /api/v1/markets/slug/{slug}`               | `=DRAZILL` with a slug            |
| `GET /api/v1/markets/{market_id}`               | `=DRAZILL` with a market id       |
| `GET /api/v1/markets/{market_id}/price-history` | `=DRAZILLHIST`                    |
| `GET /api/v1/usage`                             | the sidebar's **Test key** button |

## Installing it today

> **Note**
>
> The add-on is **not published to the Google Workspace Marketplace.** That listing is
> a deliberate, separate decision, and it has not been made — so there is no
> one-click install link, and this page does not pretend otherwise.

What works today is deploying your own copy. The Apps Script project lives at
[`integrations/sheets`](https://github.com/ishreet-fan-club/drazill/tree/main/integrations/sheets),
and its README covers the `clasp` steps end to end:

```bash
npm i -g @google/clasp && clasp login
clasp create --type sheets --title "Drazill" --rootDir ./src
clasp push
```

Then open the sheet and set your key under **Extensions ▸ Drazill ▸ Set API key…**.