/exchange/ticker

Retrieves aggregated ticker data for a market.

Client Library

#!/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 ticker 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 ticker for BTC-PERP
            response = await client.exchange_data_api.get_market_ticker(symbol="BTC-PERP")

            # Log the response
            log.info("BTC-PERP Ticker 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")

use bluefin_api::apis::configuration::Configuration;
use bluefin_api::apis::exchange_api::get_market_ticker;
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_market_ticker(
        &Configuration {
            base_path: exchange::mainnet::URL.into(),
            ..Configuration::default()
        },
        symbols::perps::BTC, // symbol
    )
    .await?;

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

    Ok(())
}

HTTPs

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

Request & Response

Language
URL
Click Try It! to start a request and see the response here!