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

> ## Agent Instructions
> These docs cover the Darvas financial data API, its MCP server, data API and Darvas Pro+ webhooks, and Pine Script custom indicators for Darvas charts.
> https://docs.darvas.app/llms.txt lists every indexed page with a summary, and https://docs.darvas.app/llms-full.txt holds them in one file. Add .md to any page URL to read that page as Markdown. The lookup lists of tickers, types and series are named at https://docs.darvas.app/ai-agents.
> The docs MCP server https://docs.darvas.app/mcp searches and reads these docs. It needs no key.
> Call the REST API at https://api.darvas.app/v1. Send the API key, which starts with dvk_, in the X-API-KEY header or as Authorization: Bearer. The OpenAPI 3.1 spec of all 168 operations is https://docs.darvas.app/openapi.yaml.
> Name a company by ticker or cik. A share class takes a dot or a dash, so BRK.B and BRK-B name the same shares. Dates are YYYY-MM-DD.
> A list answer holds one page. Request its next_page_url as it is until the answer has none. limit counts rows across all pages.
> Errors are JSON with a stable error code and a message: 400 VALIDATION_ERROR, 401 UNAUTHORIZED, 403 PLAN_REQUIRED, 404 NOT_FOUND, 429 RATE_LIMITED or QUOTA_EXCEEDED, 500 INTERNAL_ERROR and 503 UNAVAILABLE. On a 429, wait the seconds in Retry-After. 1 credit = 1 successful call: a 2xx answer with data costs one credit however many rows it holds (at most 1,000 a page), and empty answers, errors and FINRA /short-volume cost 0 credits.
> The Financial Data MCP server is https://api.darvas.app/mcp (Streamable HTTP, protocol 2025-11-25, the same API key in X-API-KEY or as a Bearer token). tools/list answers 8 flagship tools plus search_data_tools and call_data_tool by default; ?mode=full lists all 164 tools and ?toolsets=sec,crypto,macro lists domains. Every tool is callable by name, takes response_format (json, compact or tsv) and fields, and a list answer's cursor value goes in the cursor argument. The darvas://catalog/* resources cost 0 credits. Setup for each client is at https://docs.darvas.app/mcp-server.
> The data API covers SEC filers and their filings, statements, XBRL facts, debt maturities, ownership and earnings, US stock prices, technicals and FINRA short volume, macro series and a global economic calendar.
> Its crypto data covers prices, indices, order books, order flow, volume profiles, derivatives, options, liquidations, spot ETF flows and a screener across 9 exchanges. It also covers DeFi protocols, stablecoins, yields and DEX pairs, and Polymarket, Kalshi and OKX prediction markets. https://docs.darvas.app/market-coverage gives the history and update time of each dataset.
> https://docs.darvas.app/ai-agents names the endpoint and the MCP tool that answer each kind of question about these datasets.
> Custom indicators for Darvas charts are Pine Script v5 or v6 indicator() or strategy() scripts. Darvas rewrites Pine v1 to v4 to v5 and runs no other indicator language. Start at https://docs.darvas.app/pine-script/introduction.
> https://docs.darvas.app/pine-script/support lists the Pine Script that Darvas runs. https://docs.darvas.app/pine-script/request-security covers request.security() and request.financial(), and https://docs.darvas.app/pine-script/limits lists the run limits.
> Darvas Pro+ webhooks send a signed POST for alarm fires and pauses, scheduled answers, economic calendar alerts, ETF flow updates, ended connections and the data API events. https://docs.darvas.app/pro/webhooks lists every event, its object and how to verify the Darvas-Signature header.

# Order Book Imbalance & Slippage History API

> Get per-bar bid and ask depth around the mid, order book imbalance and market order slippage from books recorded every second on OKX, Binance and Bybit.

## Overview

This endpoint returns, per bar, the resting bid and ask depth within each range of the book's mid, its imbalance from -1 to 1, and the slippage a market order of each dollar size would have paid. It reads the books Darvas records every second on OKX, Binance and Bybit spot and perpetual markets, oldest bar first.

A range is `complete` only where the stored book reached it on both sides; `summary` gives each range's mean and newest imbalance over the complete bars.

| Coverage | Details |
| - | - |
| Venues | `okx` (default), `binance` and `bybit`, spot and perpetual swaps |
| Bars | 1m, 5m, 15m, 30m, 1H, 2H, 4H, 1D or 1W; 168 bars by default, 1,000 at most |
| Ranges | Up to 6 ranges from 0.05% to 10%; 0.5, 1, 2 and 5 by default |
| Order sizes | Up to 4 sizes in US dollars; 100,000 and 1,000,000 by default |
| MCP tool | `get_crypto_order_book_imbalance_history` on the [data API MCP server](https://docs.darvas.app/mcp-server.md) |

## Example

```python theme={null}
import os
import requests

headers = {"X-API-KEY": os.environ["DARVAS_API_KEY"]}
answer = requests.get(
    "https://api.darvas.app/v1/crypto/order-book/imbalance-history",
    headers=headers,
    params={
        "ticker": "BTC-USDT-SWAP",
        "exchange": "okx",
        "interval": "1H",
    },
).json()
for bar in answer["bars"][-3:]:
    depth = bar["depth"][1]
    print(bar["time"], depth["range_pct"], depth["imbalance_decimal"], bar["slippage"][0]["buy_slippage_bps"])
```

```bash theme={null}
curl -H "X-API-KEY: $DARVAS_API_KEY" \
  "https://api.darvas.app/v1/crypto/order-book/imbalance-history?ticker=BTC-USDT-SWAP&exchange=okx&interval=1H"
```


## OpenAPI

````yaml openapi.yaml GET /crypto/order-book/imbalance-history
openapi: 3.1.1
info:
  title: Darvas Data API
  version: 0.9.0
  summary: >-
    Company, filing, insider, institutional, market and macro data for every SEC
    filer, US stocks, UK and French companies and crypto markets.
  description: >-
    Every value names its source. Field names follow the common financial data
    API shapes, so an existing client reads these answers unchanged; extra
    fields come after them. Send the API key in the X-API-KEY header or as a
    Bearer token. Dates are ISO 8601 and times are RFC 3339 in UTC. Billing: 1
    credit = 1 successful call. A page holds at most 1,000 rows and costs one
    credit however many it holds; an empty answer, a refusal, an error and every
    FINRA /short-volume call cost 0 credits.
  termsOfService: https://darvas.app/terms
  contact:
    name: Darvas data
    url: https://darvas.app
    email: support@darvas.app
  license:
    name: Proprietary
    identifier: LicenseRef-Darvas-Proprietary
servers:
  - url: https://api.darvas.app/v1
    description: Production.
  - url: https://darvas.app/api/data/v1
    description: Production, on the darvas.app host.
security:
  - apiKey: []
  - bearerKey: []
tags:
  - name: company
    description: Company profiles from SEC submissions.
  - name: crypto
    description: >-
      Candles, trades, order books, order flow, derivatives, options, screens
      and market structure of crypto instruments from Darvas's own market data.
  - name: defi
    description: >-
      Multi-chain DeFi protocol TVL, stablecoin supply, yield pools, and
      on-chain DEX liquidity.
  - name: earnings
    description: >-
      Each filing that reports a period, the 8-K earnings release, then the 10-Q
      or 10-K, and the KPIs, guidance and non-GAAP metrics of the releases.
  - name: filings
    description: >-
      SEC filing lists, the items of 10-K, 10-Q and 8-K filings, and search over
      them.
  - name: financials
    description: >-
      Standardized income statements, balance sheets and cash flow statements
      from XBRL filings.
  - name: funds
    description: Holdings of registered funds and ETFs from Form N-PORT.
  - name: insiders
    description: >-
      Insider trades and holdings from Forms 3, 4 and 5, and sale notices from
      Form 144.
  - name: institutions
    description: Positions of investment managers from Form 13F reports.
  - name: ipos
    description: Registration statements and prospectuses of companies going public.
  - name: macro
    description: >-
      Policy rates, the Treasury yield curve, inflation, jobs and GDP from their
      publishers.
  - name: markets
    description: >-
      Market structure data: the shares that failed to settle each day, from
      SEC, and futures positions by trader group, from the CFTC.
  - name: news
    description: >-
      Company 8-K filings and the press releases of the Federal Reserve, the
      SEC, the BEA and the BLS.
  - name: ownership
    description: Owners of more than 5% from Schedules 13D and 13G.
  - name: prediction-markets
    description: >-
      Binary event contract odds and series across Polymarket, Kalshi and OKX
      plus cross-venue arbitrage spreads.
  - name: tokenized-stocks
    description: >-
      Coinbase stock tokens on Base, priced by their USDC pools, and the stock
      instruments of OKX and Bybit.
  - name: webhooks
    description: >-
      Destinations that receive a signed event when new filings, statements,
      insider forms or macro releases arrive.
externalDocs:
  description: Market coverage
  url: https://docs.darvas.app/market-coverage
paths:
  /crypto/order-book/imbalance-history:
    get:
      tags:
        - crypto
      summary: Read order book imbalance history
      description: >-
        Per bar, the resting bid and ask depth within each range of the book's
        mid, its imbalance from -1 to 1, and the slippage a market order of each
        size would have paid, from the books Darvas records every second on OKX,
        Binance and Bybit spot and perpetual markets, oldest bar first. Each
        range is complete only where the stored book reached it. 168 bars
        without a window, 1,000 at most.
      operationId: getCryptoOrderBookImbalanceHistory
      parameters:
        - $ref: '#/components/parameters/CryptoTicker'
        - $ref: '#/components/parameters/ImbalanceExchange'
        - $ref: '#/components/parameters/SpotSwapMarketType'
        - $ref: '#/components/parameters/ImbalanceInterval'
        - $ref: '#/components/parameters/ImbalanceStartTime'
        - $ref: '#/components/parameters/ImbalanceEndTime'
        - $ref: '#/components/parameters/ImbalanceRanges'
        - $ref: '#/components/parameters/ImbalanceOrderSizes'
      responses:
        '200':
          description: 'Read order book imbalance history: one page.'
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-Quota-Unit:
              $ref: '#/components/headers/QuotaUnit'
            X-Credits-Used:
              $ref: '#/components/headers/CreditsUsed'
            X-Quota-Limit:
              $ref: '#/components/headers/QuotaLimit'
            X-Quota-Remaining:
              $ref: '#/components/headers/QuotaRemaining'
            X-Quota-Reset:
              $ref: '#/components/headers/QuotaReset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CryptoOrderBookImbalanceResponse'
              example:
                ticker: BTC-USDT
                exchange: okx
                market_type: spot
                interval: 1H
                band_tier: 1h
                start_time: '2026-11-23T12:00:00.000Z'
                end_time: '2026-11-30T12:00:00.000Z'
                as_of: '2026-11-30T12:00:00.000Z'
                size_unit: base
                ranges_pct:
                  - 0.5
                  - 1
                  - 2
                  - 5
                order_sizes_usd:
                  - 100000
                  - 1000000
                summary:
                  - range_pct: 1
                    complete_bars: 168
                    mean_imbalance_decimal: 0.0213
                    latest_imbalance_decimal: 0.060151
                bars:
                  - time: '2026-11-30T11:00:00.000Z'
                    time_milliseconds: 1796036400000
                    reference_price_usd: 96851.2
                    buckets: 60
                    samples: 3600
                    observed_reach_bid_pct: 4.8
                    observed_reach_ask_pct: 5.2
                    depth:
                      - range_pct: 1
                        complete: true
                        bid_depth_base: 412.18
                        ask_depth_base: 365.4
                        bid_depth_usd: 39920000
                        ask_depth_usd: 35390000
                        imbalance_decimal: 0.060151
                        bid_ask_ratio: 1.128
                    slippage:
                      - order_size_usd: 1000000
                        buy_slippage_bps: 1.82
                        sell_slippage_bps: 2.04
                methodology:
                  imbalance: >-
                    (bid_depth_usd - ask_depth_usd) / (bid_depth_usd +
                    ask_depth_usd), from -1 to 1.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PlanRequired'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
        '503':
          $ref: '#/components/responses/Unavailable'
components:
  parameters:
    CryptoTicker:
      name: ticker
      in: query
      required: true
      description: >-
        The instrument id: BTC-USDT or BTC-USDT-SWAP on OKX, ETH-USDC-SWAP on
        Hyperliquid, BTC-USD on Coinbase, spot:BTCUSDT or perpetual:BTCUSDT on
        Binance and Bybit. A Binance or Bybit symbol such as BTCUSDT also works
        with market_type, spot without it. A Darvas aggregated pair is
        BASE-QUOTE or BASE-QUOTE-SWAP, such as BTC-USDT-SWAP, or BTC-ALLUSD for
        one combining its USD, USDT and USDC markets.
      schema:
        type: string
        pattern: ^[A-Za-z0-9][A-Za-z0-9._:/-]{0,63}$
        maxLength: 64
      example: BTC-USDT
    ImbalanceExchange:
      name: exchange
      in: query
      required: false
      description: 'The exchange of the stored book: okx, binance or bybit; okx without it.'
      schema:
        type: string
        enum:
          - okx
          - binance
          - bybit
        default: okx
      example: binance
    SpotSwapMarketType:
      name: market_type
      in: query
      required: false
      description: spot or swap; without it, the market the ticker implies.
      schema:
        type: string
        enum:
          - spot
          - swap
        maxLength: 8
      example: swap
    ImbalanceInterval:
      name: interval
      in: query
      required: false
      description: 'The bar: 1m, 5m, 15m, 30m, 1H, 2H, 4H, 1D or 1W; 1H without it.'
      schema:
        type: string
        enum:
          - 1m
          - 5m
          - 15m
          - 30m
          - 1H
          - 2H
          - 4H
          - 1D
          - 1W
        default: 1H
      example: 15m
    ImbalanceStartTime:
      name: start_time
      in: query
      required: false
      description: >-
        The first bar: ISO 8601, a date or Unix milliseconds; 168 bars before
        end_time without it.
      schema:
        type: string
        pattern: ^[0-9TZ:.+-]{8,40}$
        maxLength: 40
      example: '2026-11-23T12:00:00Z'
    ImbalanceEndTime:
      name: end_time
      in: query
      required: false
      description: The end of the last bar, in the same forms; now without it.
      schema:
        type: string
        pattern: ^[0-9TZ:.+-]{8,40}$
        maxLength: 40
      example: '2026-11-30T12:00:00Z'
    ImbalanceRanges:
      name: ranges_pct
      in: query
      required: false
      description: >-
        Up to 6 comma-separated ranges around the mid, in percent, from 0.05 to
        10; 0.5,1,2,5 without it.
      schema:
        type: string
        pattern: ^[0-9.]+(,[0-9.]+){0,5}$
        maxLength: 60
      example: 0.25,1
    ImbalanceOrderSizes:
      name: order_sizes_usd
      in: query
      required: false
      description: >-
        Up to 4 comma-separated market order sizes, in US dollars, from 100 to
        1,000,000,000; 100000,1000000 without it.
      schema:
        type: string
        pattern: ^[0-9.]+(,[0-9.]+){0,3}$
        maxLength: 60
      example: 50000,500000
  headers:
    RateLimitLimit:
      description: Requests per minute the key may send; on a 401 the limit a new key gets.
      schema:
        type: integer
        format: int32
        minimum: 1
        maximum: 6000
      example: 60
    QuotaUnit:
      description: >-
        What the quota counts: credits. One credit is one successful call that
        returns data.
      schema:
        type: string
        enum:
          - credits
        maxLength: 7
      example: credits
    CreditsUsed:
      description: >-
        Credits this answer cost: one for a 2xx answer with data, however many
        rows it holds. An empty answer, a refusal, an error and a FINRA
        /short-volume answer cost 0.
      schema:
        type: integer
        format: int64
        minimum: 0
        maximum: 9007199254740991
      example: 1
    QuotaLimit:
      description: >-
        The plan's credits for its period plus the account's pay-as-you-go
        credit balance, as the request found them.
      schema:
        type: integer
        format: int64
        minimum: 0
        maximum: 9007199254740991
      example: 2500000
    QuotaRemaining:
      description: >-
        Credits left after this answer: the plan's own first, then the credit
        balance.
      schema:
        type: integer
        format: int64
        minimum: 0
        maximum: 9007199254740991
      example: 2499999
    QuotaReset:
      description: >-
        When the plan's credits start again, or the trial ends, in seconds since
        1970 (UTC). Pay-as-you-go answers leave it out: their credits never
        expire.
      schema:
        type: integer
        format: int64
        minimum: 0
        maximum: 4102444800
      example: 1767225600
    RetryAfter:
      description: Seconds to wait before the next request.
      schema:
        type: integer
        format: int32
        minimum: 1
        maximum: 60
      example: 1
  schemas:
    CryptoOrderBookImbalanceResponse:
      type: object
      description: The answer of GET /crypto/order-book/imbalance-history.
      additionalProperties: false
      required:
        - ticker
        - exchange
        - market_type
        - interval
        - band_tier
        - start_time
        - end_time
        - as_of
        - size_unit
        - ranges_pct
        - order_sizes_usd
        - summary
        - bars
        - methodology
      properties:
        ticker:
          type: string
          pattern: ^[^\x00-\x08\x0b\x0c\x0e-\x1f]*$
          maxLength: 64
          description: The book's instrument.
          examples:
            - BTC-USDT
        exchange:
          type: string
          enum:
            - okx
            - binance
            - bybit
          description: The book's exchange.
          examples:
            - okx
        market_type:
          type: string
          enum:
            - spot
            - swap
          description: The book's market.
          examples:
            - spot
        interval:
          type: string
          enum:
            - 1m
            - 5m
            - 15m
            - 30m
            - 1H
            - 2H
            - 4H
            - 1D
            - 1W
          description: The book bars.
          examples:
            - 1H
        band_tier:
          type: string
          enum:
            - 1m
            - 15m
            - 1h
          description: The stored band tier the bars read.
          examples:
            - 1h
        start_time:
          type: string
          format: date-time
          maxLength: 40
          description: The first book bar's open.
          examples:
            - '2026-11-23T12:00:00.000Z'
        end_time:
          type: string
          format: date-time
          maxLength: 40
          description: The last book bar's close.
          examples:
            - '2026-11-30T12:00:00.000Z'
        as_of:
          type: string
          format: date-time
          maxLength: 40
          description: When Darvas built the imbalance answer.
          examples:
            - '2026-11-30T12:00:00.000Z'
        size_unit:
          type: string
          enum:
            - base
          description: The unit of the _base sizes.
          examples:
            - base
        ranges_pct:
          type: array
          maxItems: 6
          description: The ranges around the mid, ascending.
          items:
            type: number
            format: double
          examples:
            - - 0.5
              - 1
              - 2
              - 5
        order_sizes_usd:
          type: array
          maxItems: 4
          description: The market order sizes, ascending.
          items:
            type: number
            format: double
          examples:
            - - 100000
              - 1000000
        summary:
          type: array
          maxItems: 6
          description: Each range's imbalance over the bars.
          items:
            $ref: '#/components/schemas/CryptoBookImbalanceSummary'
        bars:
          type: array
          maxItems: 1000
          description: The book bars, oldest first.
          items:
            $ref: '#/components/schemas/CryptoBookImbalanceBar'
        methodology:
          type: object
          description: How depth, imbalance and slippage are read from the stored book.
          maxProperties: 40
          additionalProperties:
            type: string
            pattern: ^[^\x00-\x08\x0b\x0c\x0e-\x1f]*$
            maxLength: 2000
          examples:
            - imbalance: >-
                (bid_depth_usd - ask_depth_usd) / (bid_depth_usd +
                ask_depth_usd), from -1 to 1.
      examples:
        - ticker: BTC-USDT
          exchange: okx
          market_type: spot
          interval: 1H
          band_tier: 1h
          start_time: '2026-11-23T12:00:00.000Z'
          end_time: '2026-11-30T12:00:00.000Z'
          as_of: '2026-11-30T12:00:00.000Z'
          size_unit: base
          ranges_pct:
            - 0.5
            - 1
            - 2
            - 5
          order_sizes_usd:
            - 100000
            - 1000000
          summary:
            - range_pct: 1
              complete_bars: 168
              mean_imbalance_decimal: 0.0213
              latest_imbalance_decimal: 0.060151
          bars:
            - time: '2026-11-30T11:00:00.000Z'
              time_milliseconds: 1796036400000
              reference_price_usd: 96851.2
              buckets: 60
              samples: 3600
              observed_reach_bid_pct: 4.8
              observed_reach_ask_pct: 5.2
              depth:
                - range_pct: 1
                  complete: true
                  bid_depth_base: 412.18
                  ask_depth_base: 365.4
                  bid_depth_usd: 39920000
                  ask_depth_usd: 35390000
                  imbalance_decimal: 0.060151
                  bid_ask_ratio: 1.128
              slippage:
                - order_size_usd: 1000000
                  buy_slippage_bps: 1.82
                  sell_slippage_bps: 2.04
          methodology:
            imbalance: >-
              (bid_depth_usd - ask_depth_usd) / (bid_depth_usd + ask_depth_usd),
              from -1 to 1.
    CryptoBookImbalanceSummary:
      type: object
      description: One range's imbalance over the answer's bars.
      additionalProperties: false
      required:
        - range_pct
        - complete_bars
        - mean_imbalance_decimal
        - latest_imbalance_decimal
      properties:
        range_pct:
          type: number
          format: double
          description: The range of the summary, in percent of the mid.
          examples:
            - 1
        complete_bars:
          type: integer
          format: int64
          minimum: 0
          maximum: 1000
          description: Bars whose stored book reached the range.
          examples:
            - 168
        mean_imbalance_decimal:
          type:
            - number
            - 'null'
          format: double
          description: The mean imbalance over the complete bars.
          examples:
            - 0.0213
        latest_imbalance_decimal:
          type:
            - number
            - 'null'
          format: double
          description: The newest bar's imbalance in the range.
          examples:
            - 0.060151
      examples:
        - range_pct: 1
          complete_bars: 168
          mean_imbalance_decimal: 0.0213
          latest_imbalance_decimal: 0.060151
    CryptoBookImbalanceBar:
      type: object
      description: One bar of stored book depth.
      additionalProperties: false
      required:
        - time
        - time_milliseconds
        - reference_price_usd
        - buckets
        - samples
        - observed_reach_bid_pct
        - observed_reach_ask_pct
        - depth
        - slippage
      properties:
        time:
          type: string
          format: date-time
          maxLength: 40
          description: The book bar's open.
          examples:
            - '2026-11-30T11:00:00.000Z'
        time_milliseconds:
          type: integer
          format: int64
          minimum: 0
          maximum: 4102444800000
          description: The book bar's open, in Unix milliseconds.
          examples:
            - 1796036400000
        reference_price_usd:
          type:
            - number
            - 'null'
          format: double
          description: The bar's sample-weighted mid.
          examples:
            - 96851.2
        buckets:
          type: integer
          format: int64
          minimum: 0
          maximum: 100000
          description: Stored buckets in the bar.
          examples:
            - 60
        samples:
          type: integer
          format: int64
          minimum: 0
          maximum: 100000000
          description: One-second book samples in the bar.
          examples:
            - 3600
        observed_reach_bid_pct:
          type:
            - number
            - 'null'
          format: double
          description: >-
            The farthest bid band stored in the bar's thinnest bucket, in
            percent.
          examples:
            - 4.8
        observed_reach_ask_pct:
          type:
            - number
            - 'null'
          format: double
          description: >-
            The farthest ask band stored in the bar's thinnest bucket, in
            percent.
          examples:
            - 5.2
        depth:
          type: array
          maxItems: 6
          description: Depth within each range asked for.
          items:
            $ref: '#/components/schemas/CryptoBookDepth'
        slippage:
          type: array
          maxItems: 4
          description: Slippage of each order size asked for.
          items:
            $ref: '#/components/schemas/CryptoBookSlippage'
      examples:
        - time: '2026-11-30T11:00:00.000Z'
          time_milliseconds: 1796036400000
          reference_price_usd: 96851.2
          buckets: 60
          samples: 3600
          observed_reach_bid_pct: 4.8
          observed_reach_ask_pct: 5.2
          depth:
            - range_pct: 1
              complete: true
              bid_depth_base: 412.18
              ask_depth_base: 365.4
              bid_depth_usd: 39920000
              ask_depth_usd: 35390000
              imbalance_decimal: 0.060151
              bid_ask_ratio: 1.128
          slippage:
            - order_size_usd: 1000000
              buy_slippage_bps: 1.82
              sell_slippage_bps: 2.04
    Error:
      type: object
      description: A refusal or failure.
      additionalProperties: false
      required:
        - error
      properties:
        error:
          type: string
          pattern: ^[A-Z_]{1,64}$
          description: A stable code.
          examples:
            - NOT_FOUND
        message:
          type: string
          pattern: ^[^\x00-\x08\x0b\x0c\x0e-\x1f]*$
          maxLength: 500
          description: What went wrong, in English.
          examples:
            - No company has this ticker or CIK
      examples:
        - error: NOT_FOUND
          message: No company has this ticker or CIK
    CryptoBookDepth:
      type: object
      description: The bar's depth within one range of the mid.
      additionalProperties: false
      required:
        - range_pct
        - complete
        - bid_depth_base
        - ask_depth_base
        - bid_depth_usd
        - ask_depth_usd
        - imbalance_decimal
        - bid_ask_ratio
      properties:
        range_pct:
          type: number
          format: double
          description: The range around the mid, in percent.
          examples:
            - 1
        complete:
          type: boolean
          description: Whether the stored book reached the range on both sides.
          examples:
            - true
        bid_depth_base:
          type:
            - number
            - 'null'
          format: double
          description: Resting bids within the range, in the base.
          examples:
            - 412.18
        ask_depth_base:
          type:
            - number
            - 'null'
          format: double
          description: Resting asks within the range, in the base.
          examples:
            - 365.4
        bid_depth_usd:
          type:
            - number
            - 'null'
          format: double
          description: Resting bids within the range, in US dollars.
          examples:
            - 39920000
        ask_depth_usd:
          type:
            - number
            - 'null'
          format: double
          description: Resting asks within the range, in US dollars.
          examples:
            - 35390000
        imbalance_decimal:
          type:
            - number
            - 'null'
          format: double
          description: (bids - asks) / (bids + asks) in dollars, from -1 to 1.
          examples:
            - 0.060151
        bid_ask_ratio:
          type:
            - number
            - 'null'
          format: double
          description: Bids over asks in dollars.
          examples:
            - 1.128
      examples:
        - range_pct: 1
          complete: true
          bid_depth_base: 412.18
          ask_depth_base: 365.4
          bid_depth_usd: 39920000
          ask_depth_usd: 35390000
          imbalance_decimal: 0.060151
          bid_ask_ratio: 1.128
    CryptoBookSlippage:
      type: object
      description: What a market order of one size would have paid.
      additionalProperties: false
      required:
        - order_size_usd
        - buy_slippage_bps
        - sell_slippage_bps
      properties:
        order_size_usd:
          type: number
          format: double
          description: The order size, in US dollars.
          examples:
            - 1000000
        buy_slippage_bps:
          type:
            - number
            - 'null'
          format: double
          description: >-
            A buy's average price over the mid, in basis points; null when the
            book is thinner.
          examples:
            - 1.82
        sell_slippage_bps:
          type:
            - number
            - 'null'
          format: double
          description: >-
            A sell's average price under the mid, in basis points; null when the
            book is thinner.
          examples:
            - 2.04
      examples:
        - order_size_usd: 1000000
          buy_slippage_bps: 1.82
          sell_slippage_bps: 2.04
  responses:
    BadRequest:
      description: A parameter is missing or malformed.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-Quota-Unit:
          $ref: '#/components/headers/QuotaUnit'
        X-Credits-Used:
          $ref: '#/components/headers/CreditsUsed'
        X-Quota-Limit:
          $ref: '#/components/headers/QuotaLimit'
        X-Quota-Remaining:
          $ref: '#/components/headers/QuotaRemaining'
        X-Quota-Reset:
          $ref: '#/components/headers/QuotaReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: VALIDATION_ERROR
            message: Send ticker or cik
    Unauthorized:
      description: The API key is missing, unknown or revoked.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-Quota-Unit:
          $ref: '#/components/headers/QuotaUnit'
        X-Credits-Used:
          $ref: '#/components/headers/CreditsUsed'
        X-Quota-Limit:
          $ref: '#/components/headers/QuotaLimit'
        X-Quota-Remaining:
          $ref: '#/components/headers/QuotaRemaining'
        X-Quota-Reset:
          $ref: '#/components/headers/QuotaReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: UNAUTHORIZED
            message: The API key is not valid
    PlanRequired:
      description: The account of the key has no active data API plan.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-Quota-Unit:
          $ref: '#/components/headers/QuotaUnit'
        X-Credits-Used:
          $ref: '#/components/headers/CreditsUsed'
        X-Quota-Limit:
          $ref: '#/components/headers/QuotaLimit'
        X-Quota-Remaining:
          $ref: '#/components/headers/QuotaRemaining'
        X-Quota-Reset:
          $ref: '#/components/headers/QuotaReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: PLAN_REQUIRED
            message: The account of this key has no active data API plan
    NotFound:
      description: No company has this ticker or CIK.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-Quota-Unit:
          $ref: '#/components/headers/QuotaUnit'
        X-Credits-Used:
          $ref: '#/components/headers/CreditsUsed'
        X-Quota-Limit:
          $ref: '#/components/headers/QuotaLimit'
        X-Quota-Remaining:
          $ref: '#/components/headers/QuotaRemaining'
        X-Quota-Reset:
          $ref: '#/components/headers/QuotaReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: NOT_FOUND
            message: No company has this ticker or CIK
    RateLimited:
      description: >-
        The key sent more requests in a minute than its limit (RATE_LIMITED), or
        its account has no credits left (QUOTA_EXCEEDED).
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-Quota-Unit:
          $ref: '#/components/headers/QuotaUnit'
        X-Credits-Used:
          $ref: '#/components/headers/CreditsUsed'
        X-Quota-Limit:
          $ref: '#/components/headers/QuotaLimit'
        X-Quota-Remaining:
          $ref: '#/components/headers/QuotaRemaining'
        X-Quota-Reset:
          $ref: '#/components/headers/QuotaReset'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: RATE_LIMITED
            message: Too many requests
    InternalError:
      description: Darvas failed; the error is reported.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-Quota-Unit:
          $ref: '#/components/headers/QuotaUnit'
        X-Credits-Used:
          $ref: '#/components/headers/CreditsUsed'
        X-Quota-Limit:
          $ref: '#/components/headers/QuotaLimit'
        X-Quota-Remaining:
          $ref: '#/components/headers/QuotaRemaining'
        X-Quota-Reset:
          $ref: '#/components/headers/QuotaReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: INTERNAL_ERROR
            message: Something went wrong
    Unavailable:
      description: The data store is unavailable.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-Quota-Unit:
          $ref: '#/components/headers/QuotaUnit'
        X-Credits-Used:
          $ref: '#/components/headers/CreditsUsed'
        X-Quota-Limit:
          $ref: '#/components/headers/QuotaLimit'
        X-Quota-Remaining:
          $ref: '#/components/headers/QuotaRemaining'
        X-Quota-Reset:
          $ref: '#/components/headers/QuotaReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: UNAVAILABLE
            message: The data service is unavailable
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-KEY
      description: 'A Darvas data API key: dvk_ and 43 characters.'
    bearerKey:
      type: http
      scheme: bearer
      description: The same key as a Bearer token.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.