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

# Generate Perp Chart Image

> Render a candlestick chart image for a perpetual market from OHLC candles plus header/footer metadata and optional overlay lines (stop-loss, take-profit, liquidation). The candle shape is identical to the /2/perp/ohlcv-history response, so its output can be passed straight in.

Send OHLC candles together with the header and footer blocks shown around the chart, and the rendered chart is returned in `data`. This is a synchronous proxy: one request in, one rendered chart out — nothing is stored.

<Tip>Candles use the same `t / o / h / l / c` shape as [`GET /2/perp/ohlcv-history`](/rest-api-reference/endpoint/perp-chart) — feed that endpoint's output directly. `t` is UNIX **milliseconds**, and `priceChange` is a percentage (e.g. `-6.31` means `-6.31%`).</Tip>


## OpenAPI

````yaml POST /2/perp/chart
openapi: 3.0.0
info:
  version: 1.0.0
  title: Mobula API
  description: >-
    Documentation of the Mobula API


    **Demo API**: The default server (demo-api.mobula.io) is a demo API with
    rate limits.

    For production use, please use api.mobula.io with an API key from
    https://admin.mobula.io
servers:
  - url: https://demo-api.mobula.io/api/
    description: Demo API (rate limited, for testing only)
  - url: https://api.mobula.io/api/
    description: Production API (requires API key)
security: []
tags:
  - name: V2 - Token
    description: Token details, price, security, ATH, and holder data
  - name: V2 - Market Data
    description: Market details, OHLCV history, and lighthouse metrics
  - name: V2 - Trades
    description: Token trades, enriched trades, and trade filters
  - name: V2 - Wallet
    description: Wallet positions, activity, trades, analysis, and labels
  - name: V2 - Assets
    description: Cross-chain asset details and price history
  - name: V2 - Swap
    description: Swap quoting and execution
  - name: V2 - Perps
    description: Perpetual futures quoting, execution, and positions
  - name: V2 - Bridge
    description: Cross-chain bridge quoting and intent status (Alpha Preview)
  - name: V2 - DeFi
    description: Bonding pools and pulse data
  - name: V2 - Search
    description: Universal fast search
  - name: V2 - Usage
    description: Per-key API and WebSocket usage history
  - name: V2 - Blockchains
    description: System metadata and chain listings
  - name: V2 - Prediction Markets
    description: >-
      Polymarket markets/events, wallet positions, and the full execution stack
      (auth, order build/submit/cancel, approvals, pUSD wrap/unwrap, deploy,
      deposit/withdraw, redeem). Alpha — see /api/2/pm/*.
  - name: V1 - Market Data
    description: Market prices, history, sparklines, pairs, and multi-data
  - name: V1 - Wallet
    description: Wallet portfolio, transactions, history, and NFTs
  - name: V1 - Token
    description: First buyers
  - name: V1 - Trades
    description: Market trades by pair
  - name: V1 - Metadata
    description: Token metadata, categories, and news
  - name: V1 - Assets
    description: List all assets
  - name: V1 - Search
    description: Search for assets, tokens, and pairs
  - name: V1 - DeFi
    description: Bonding pool pulse data
  - name: V1 - Blockchains
    description: Blockchain listings, pairs, and stats
  - name: V1 - Webhooks
    description: Webhook management
  - name: V1 - Feed
    description: Custom feed creation
paths:
  /2/perp/chart:
    post:
      tags:
        - V2 - Perps
      summary: Generate perp chart image
      description: >-
        Render a candlestick chart image for a perpetual market. Send OHLC
        candles (same t/o/h/l/c shape as /2/perp/ohlcv-history) plus
        header/footer metadata and optional overlay lines; the rendered chart is
        returned in `data`. Synchronous — one request in, one rendered chart
        out.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - candles
                - width
                - height
                - name
                - headerData
                - footerData
              properties:
                candles:
                  type: array
                  description: >-
                    OHLC series, oldest-to-newest by `t`. Same shape as the
                    /2/perp/ohlcv-history response, so its output can be passed
                    in directly. Must contain at least one candle.
                  minItems: 1
                  items:
                    type: object
                    required:
                      - t
                      - o
                      - h
                      - l
                      - c
                    properties:
                      t:
                        type: number
                        description: Candle open time, UNIX epoch in milliseconds.
                      o:
                        type: number
                        description: Opening price.
                      h:
                        type: number
                        description: Highest price in the interval.
                      l:
                        type: number
                        description: Lowest price in the interval.
                      c:
                        type: number
                        description: Closing price.
                width:
                  type: integer
                  description: Output image width in pixels. Positive integer.
                height:
                  type: integer
                  description: Output image height in pixels. Positive integer.
                name:
                  type: string
                  description: >-
                    Chart title / pair label shown on the chart (e.g.
                    FLUID/USD).
                lines:
                  type: object
                  description: >-
                    Optional horizontal overlay lines. Each level is
                    independently optional — send only the ones you have.
                  properties:
                    stopLoss:
                      type: number
                      description: Stop-loss price level.
                    takeProfit:
                      type: number
                      description: Take-profit price level.
                    liquidation:
                      type: number
                      description: Liquidation price level.
                headerData:
                  type: object
                  description: Header block shown above the chart.
                  required:
                    - pair
                    - leverage
                    - currentPrice
                    - priceChange
                    - openInterestL
                    - openInterestS
                    - holdingL
                    - holdingS
                  properties:
                    pair:
                      type: string
                      description: Trading pair label (e.g. FLUID/USD).
                    leverage:
                      type: number
                      description: Position leverage multiplier.
                    currentPrice:
                      type: number
                      description: Current mark/last price.
                    priceChange:
                      type: number
                      description: >-
                        Price change for the displayed window, as a percentage
                        (may be negative).
                    openInterestL:
                      type: object
                      description: Long-side open interest.
                      required:
                        - value
                        - total
                      properties:
                        value:
                          type: number
                          description: Filled/used portion.
                        total:
                          type: number
                          description: Total capacity.
                    openInterestS:
                      type: object
                      description: Short-side open interest.
                      required:
                        - value
                        - total
                      properties:
                        value:
                          type: number
                          description: Filled/used portion.
                        total:
                          type: number
                          description: Total capacity.
                    holdingL:
                      type: number
                      description: Long holding amount.
                    holdingS:
                      type: number
                      description: Short holding amount.
                footerData:
                  type: object
                  description: Footer block shown below the chart.
                  required:
                    - high24h
                    - low24h
                    - volume24h
                  properties:
                    high24h:
                      type: number
                      description: 24-hour high price.
                    low24h:
                      type: number
                      description: 24-hour low price.
                    volume24h:
                      type: number
                      description: 24-hour traded volume.
              example:
                candles:
                  - t: 1780860000000
                    o: 1.0615964
                    h: 1.0656162
                    l: 1.0506006
                    c: 1.0605862
                  - t: 1780861800000
                    o: 1.0605862
                    h: 1.0655736
                    l: 1.0525683
                    c: 1.0630746
                  - t: 1780863600000
                    o: 1.0630746
                    h: 1.0695774
                    l: 1.0630746
                    c: 1.0655949
                width: 1024
                height: 850
                name: FLUID/USD
                lines:
                  stopLoss: 1.2876838333333334
                  takeProfit: 0.7358193333333334
                  liquidation: 1.4231453021582852
                headerData:
                  pair: FLUID/USD
                  leverage: 3
                  currentPrice: 1.103729
                  priceChange: -6.305772495755514
                  openInterestL:
                    value: 0
                    total: 250000
                  openInterestS:
                    value: 30.000026
                    total: 249969.999974
                  holdingL: 0.00251711712
                  holdingS: 0.00251711712
                footerData:
                  high24h: 1.2151002
                  low24h: 1.0799406
                  volume24h: 2001.2866550754236
      responses:
        '200':
          description: Rendered chart
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: string
                    description: >-
                      The rendered chart returned by the renderer, passed
                      through verbatim. Treat as an opaque string payload.
        '400':
          description: >-
            Request body failed validation (missing/invalid fields, empty
            candles, wrong candle keys).
        '500':
          description: Unexpected internal error.
        '502':
          description: Upstream chart generator failed or was unreachable.

````