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

# Download a daily history file

> Answers `302` with a presigned link, valid for up to 15 minutes, to a gzip-compressed
CSV (`application/gzip`, downloaded as `<date>_<file>.csv.gz`). Costs one **file credit**
from the separate `history_files` daily bucket, not a request. A 400, 404 or 503 costs
nothing. Follow the redirect without your `X-API-Key` header. Column layouts:
https://docs.gammaflip.io/data-dictionary#daily-history-files




## OpenAPI

````yaml /openapi.yaml get /history/files/{exchange}/{coin}/{date}/{file}
openapi: 3.1.0
info:
  title: GammaFlip GEX API
  version: 1.0.0
  description: >
    Programmatic access to Gamma Exposure (GEX) data for crypto options

    (Bybit, Deribit, OKX, Derive) and US options (the `tradfi` exchange).


    API access is a plan entitlement (`api_access`). The trial includes it

    (50 requests/day); other plans with API access get 500 requests/day.

    Only `/gex/...`, `/levels/...` and the `/history/...` query endpoints count

    against the quota; `/exchanges`, `/coins`, `/expirations/...`, `/me` and

    `/history/coverage` are free. History file downloads use a separate daily

    bucket of file credits (trial 20, other plans 200). A `429` carries no

    `Retry-After` header: use `X-RateLimit-Reset`, `X-History-Files-Reset` or
    `/me`.


    All GEX values are USD per 1% move of the underlying. Field definitions:

    https://docs.gammaflip.io/data-dictionary
  contact:
    name: GammaFlip Support
    email: admin@gammaflip.io
    url: https://gammaflip.io
servers:
  - url: https://api.gammaflip.io/api/v1
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /history/files/{exchange}/{coin}/{date}/{file}:
    get:
      tags:
        - History
      summary: Download a daily history file
      description: >
        Answers `302` with a presigned link, valid for up to 15 minutes, to a
        gzip-compressed

        CSV (`application/gzip`, downloaded as `<date>_<file>.csv.gz`). Costs
        one **file credit**

        from the separate `history_files` daily bucket, not a request. A 400,
        404 or 503 costs

        nothing. Follow the redirect without your `X-API-Key` header. Column
        layouts:

        https://docs.gammaflip.io/data-dictionary#daily-history-files
      operationId: downloadHistoryFile
      parameters:
        - $ref: '#/components/parameters/HistoryExchange'
        - $ref: '#/components/parameters/Coin'
        - name: date
          in: path
          required: true
          description: Session date, `YYYY-MM-DD`.
          schema:
            type: string
            format: date
            example: '2026-10-05'
        - name: file
          in: path
          required: true
          schema:
            type: string
            enum:
              - levels
              - strikes_total
              - strikes_by_expiry
      responses:
        '302':
          description: Redirect to the presigned file link.
          headers:
            Location:
              description: Presigned link, valid for up to 15 minutes.
              schema:
                type: string
                format: uri
            X-History-Files-Limit:
              description: >-
                Daily file credits; `0` means unlimited. Omitted if the quota
                service is unavailable.
              schema:
                type: integer
            X-History-Files-Remaining:
              description: >-
                Credits left; `0` together with a `0` limit means unlimited.
                Omitted if the quota service is unavailable.
              schema:
                type: integer
            X-History-Files-Reset:
              schema:
                type: string
                format: date-time
        '400':
          $ref: '#/components/responses/HistoryNotAvailable'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: No such file (`no_file`). Costs no credit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >
            Daily file credits used up (`history_files_limit_exceeded`). No
            `Retry-After`

            header: use `X-History-Files-Reset` or `GET /me`.
          headers:
            X-History-Files-Limit:
              description: >-
                Daily file credits (`0` means unlimited, which never yields a
                429).
              schema:
                type: integer
            X-History-Files-Remaining:
              schema:
                type: integer
                example: 0
            X-History-Files-Reset:
              schema:
                type: string
                format: date-time
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            File storage temporarily unavailable (`files_unavailable`). Costs no
            credit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    HistoryExchange:
      name: exchange
      in: path
      required: true
      description: >
        `bybit`, `deribit`, `okx`, `derive`, `combined` or `tradfi`. `all` and
        `combined`

        with a TradFi ticker resolve to `tradfi`. Venue subsets such as
        `deribit+derive`

        have no history: `400 history_not_available`.
      schema:
        type: string
        examples:
          - deribit
          - combined
          - tradfi
    Coin:
      name: coin
      in: path
      required: true
      description: >-
        Symbol (case-insensitive), for example `BTC` or `QQQ`. Use `/coins` for
        the list.
      schema:
        type: string
        example: BTC
  responses:
    HistoryNotAvailable:
      description: >
        `invalid_exchange`, `invalid_pair`, `invalid_param`,
        `history_not_available`

        (venue subset; with `valid_exchanges`) or `range_too_large` (with
        `max_window_days`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: >
        Missing or invalid credential, or a credential that does not resolve to
        a user. Both return `unauthorized`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >
        `subscription_required` (the plan has no API access) or
        `market_not_in_plan`

        (the plan does not include the coin's market).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      description: >
        Standard error body. `error` is a stable slug safe to branch on;
        `message` is human-readable prose that may change and must not be
        parsed. Errors are never wrapped in the data/meta envelope used by
        successful responses. Some errors add hint fields.
      required:
        - error
        - message
      properties:
        error:
          type: string
          enum:
            - unauthorized
            - subscription_required
            - market_not_in_plan
            - rate_limit_exceeded
            - invalid_exchange
            - invalid_pair
            - invalid_expiration
            - invalid_param
            - no_data
            - unsupported_coin
            - market_unavailable
            - history_not_available
            - range_too_large
            - no_snapshot
            - no_file
            - files_unavailable
            - history_files_limit_exceeded
            - method_not_allowed
          example: invalid_exchange
        message:
          type: string
          example: Exchange 'kraken' is not available.
        current_tier:
          type: string
          description: With `subscription_required` and `market_not_in_plan`.
          example: trial
        valid_exchanges:
          type: array
          items:
            type: string
          description: With `invalid_exchange`, `invalid_pair` and `history_not_available`.
          example:
            - deribit
            - bybit
            - okx
            - derive
            - combined
        nearest_expirations:
          type: array
          items:
            type: string
          description: >-
            With `invalid_expiration`; up to five ISO dates closest to the
            request (the earliest five if the value is not a date).
          example:
            - '2026-10-17'
            - '2026-10-19'
        valid_values:
          type: array
          items:
            type: string
          description: >-
            With `invalid_param` for `view`, `granularity`, `file` and
            `compare`.
          example:
            - full
            - levels
        max_value:
          type: number
          description: With `invalid_param` for `range_pct`.
          example: 50
        max_window_days:
          type: integer
          description: With `range_too_large`.
          example: 31
        nearest_timestamps:
          type: array
          items:
            type: string
            format: date-time
          description: With `no_snapshot`; up to three capture times closest to `at`.
          example:
            - '2026-10-05T20:15:00Z'
            - '2026-10-05T13:45:00Z'
        market:
          type: string
          description: With `market_not_in_plan`; the market the requested coin belongs to.
          enum:
            - crypto
            - tradfi
          example: tradfi
        markets_in_plan:
          type: array
          items:
            type: string
          description: With `market_not_in_plan`.
        supported_crypto:
          type: array
          items:
            type: string
          description: >-
            With `unsupported_coin`; crypto coins listed by at least one
            exchange.
          example:
            - BTC
            - ETH
            - HYPE
            - SOL
            - XRP
        supported_tradfi:
          type: array
          items:
            type: string
          description: With `unsupported_coin`; US tickers we track.
          example:
            - QQQ
            - SPX
            - SPY
        rate_limit:
          allOf:
            - $ref: '#/components/schemas/RateLimit'
          description: >-
            With `rate_limit_exceeded` and `history_files_limit_exceeded`;
            mirrors the X-RateLimit-* headers.
    RateLimit:
      type: object
      properties:
        limit:
          type: integer
          example: 500
        remaining:
          type: integer
          example: 487
        reset:
          type: string
          format: date-time
          example: '2026-04-15T00:00:00+00:00'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        API key prefixed with `gex_sk_`. Create one in your
        [account dashboard](https://gammaflip.io/account).

````

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