---
updatedAt: 2025-09-22T22:39:55.000Z
agentTools:
  projectIndex: https://bluefin-exchange.readme.io/llms.txt
---

# /exchange/candlesticks

Retrieves candle stick data for a market.

## Client Library

```python Python
#!/usr/bin/env python

import asyncio
import logging

from bluefin_pro_sdk import BluefinProSdk, Environment, RpcUrl
from crypto_helpers.signature import SuiWallet

# Set up logging
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)


async def main():
    """
    Example showing how to fetch candlesticks for BTC-PERP from the Bluefin Pro API
    using the PRODUCTION environment.
    """
    # Create a wallet with your private key
    sui_wallet = SuiWallet(
        mnemonic="dilemma salmon lake ceiling moral glide cute that ginger float area aunt vague remind cage mother concert inch dizzy present proud program time urge"
    )

    log.info(f"Using wallet address: {sui_wallet.sui_address}")
    
    # Initialize the Bluefin Pro SDK client with PRODUCTION environment and RPC
    async with BluefinProSdk(
            sui_wallet=sui_wallet,
            contracts=None,  # Not needed for this example
            rpc_url=RpcUrl.PROD,
            env=Environment.PRODUCTION,
            debug=False  # Set to True for more verbose output
    ) as client:
        try:
            # Initialize the client, which will handle authentication
            await client.init()

            # Get candlesticks for BTC-PERP
            response = await client.exchange_data_api.get_recent_trades(symbol="BTC-PERP")

            # Log the response
            log.info("BTC-PERP Candlesticks Information:")
            log.info(f"{response=}")

            # Return the response for further use if needed
            return response

        except Exception as e:
            log.error(f"Error fetching exchange info: {e}")
            raise


if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        log.info("Exiting due to keyboard interrupt")

```
```rust Rust
use bluefin_api::apis::configuration::Configuration;
use bluefin_api::apis::exchange_api::get_candlestick_data;
use bluefin_api::models::{CandlePriceType, KlineInterval};
use bluefin_pro::prelude::*;

type Error = Box<dyn std::error::Error>;
type Result<T> = std::result::Result<T, Error>;

#[tokio::main]
async fn main() -> Result<()> {
    let response = get_candlestick_data(
        &Configuration {
            base_path: exchange::mainnet::URL.into(),
            ..Configuration::default()
        },
        symbols::perps::BTC,       // symbol
        KlineInterval::Variant1m, // interval
        CandlePriceType::Last,     // type
        None,                      // start_time_at_millis
        None,                      // end_time_at_millis
        None,                      // limit
        None,                      // page
    )
    .await?;

    println!("{response:#?}");

    Ok(())
}

```

## HTTPs

Alternatively, call the GET /exchange/candlesticks endpoint using the integrated editor on the right or locally from any language supporting HTTPs network calls.

## Request & Response

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Bluefin Exchange API",
    "description": "Exchange Info Endpoints | All numeric quantities are represented as string in e9 format.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.{env}.bluefin.io",
      "variables": {
        "env": {
          "default": "sui-staging",
          "enum": [
            "sui-staging",
            "sui-prod"
          ]
        }
      }
    }
  ],
  "paths": {
    "/v1/exchange/candlesticks": {
      "get": {
        "tags": [
          "Exchange"
        ],
        "operationId": "getCandlestickData",
        "summary": "/exchange/candlesticks",
        "description": "Retrieves candle stick data for a market.",
        "parameters": [
          {
            "name": "symbol",
            "in": "query",
            "required": true,
            "description": "The market symbol to get the klines for.",
            "schema": {
              "type": "string",
              "example": 291
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": true,
            "description": "The interval to get the klines for.",
            "schema": {
              "$ref": "#/components/schemas/KlineInterval"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": true,
            "description": "Candle price type (last price, market price or oracle).",
            "schema": {
              "$ref": "#/components/schemas/CandlePriceType"
            }
          },
          {
            "name": "startTimeAtMillis",
            "in": "query",
            "required": false,
            "description": "Timestamp in milliseconds in ms to get klines from.",
            "example": 1499040000000,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          },
          {
            "name": "endTimeAtMillis",
            "in": "query",
            "required": false,
            "description": "Timestamp in milliseconds in ms to get klines until.",
            "example": 1499644799999,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Default 50; max 1000.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50,
              "maximum": 1000,
              "minimum": 0
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 1
            },
            "required": false,
            "description": "The page number to retrieve in a paginated response."
          }
        ],
        "responses": {
          "200": {
            "description": "Kline/candlestick data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CandlesticksResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CandlesticksResponse": {
        "type": "array",
        "description": "list of candles sticks each item is a list of values ordered like the following.\n[\n  [\n    1499040000000,      // Open time in ms\n    \"163479000\",       // Open price in e9\n    \"800000000\",       // High price in e9\n    \"15758000\",       // Low price in e9\n    \"15771000\",       // Close price in e9\n    \"148976114278150\",  // Volume in e9\n    1499644799999,      // Close time in ms\n    \"2434190553340\",    // Quote asset volume in e9\n    308                 // Number of trades\n  ]\n]\n",
        "items": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "example": [
          [
            1499040000000,
            "163479000",
            "800000000",
            "15758000",
            "15771000",
            "148976114278150",
            1499644799999,
            "2434190553340",
            308
          ]
        ]
      },
      "KlineInterval": {
        "type": "string",
        "enum": [
          "1m",
          "3m",
          "5m",
          "15m",
          "30m",
          "1h",
          "2h",
          "4h",
          "6h",
          "8h",
          "12h",
          "1d",
          "1w",
          "1Mo",
          "UNSPECIFIED"
        ]
      },
      "CandlePriceType": {
        "type": "string",
        "enum": [
          "Last",
          "Market",
          "Oracle",
          "UNSPECIFIED"
        ]
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```