get https://api.{env}.bluefin.io/v1/exchange/trades
Retrieves recent trades executed on 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 recent trades 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 recent trades for BTC-PERP
response = await client.exchange_data_api.get_recent_trades(symbol="BTC-PERP")
# Log the response
log.info("ETH-PERP Recent Trades 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_recent_trades;
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_recent_trades(
&Configuration {
base_path: exchange::mainnet::URL.into(),
..Configuration::default()
},
symbols::perps::BTC, // symbol
None,
None,
None,
None,
None,
)
.await?;
println!("{response:#?}");
Ok(())
}
HTTPs
Alternatively, call the GET /exchange/trades endpoint using the integrated editor on the right or locally from any language supporting HTTPs network calls.