/account

Retrieves the user's account details.

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 a user's account details 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 user's account details
            response = await client.account_data_api.get_account_details()

            # Log the response
            log.info("Account Details 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::account_data_api::get_account_details;
use bluefin_api::apis::configuration::Configuration;
use bluefin_api::models::Account;
use bluefin_api::models::LoginRequest;
use bluefin_pro::prelude::*;
use chrono::Utc;
use hex::FromHex;
use sui_sdk_types::SignatureScheme;

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

/// Sends a request for account details, and returns the deserialized response.
async fn send_request(auth_token: &str) -> Result<Account> {
    println!("Sending request...");
    let response = get_account_details(
        &Configuration {
            base_path: account::mainnet::URL.into(),
            bearer_access_token: Some(auth_token.into()),
            ..Configuration::new()
        },
        Some("INSERT_ACCOUNT_ADDRESS_HERE"),
    )
    .await?;
    Ok(response)
}

#[tokio::main]
async fn main() -> Result<()> {
    let login_request = LoginRequest::new(
        "INSERT_ACCOUNT_ADDRESS_HERE",
        Utc::now().timestamp_millis(),
        auth::mainnet::AUDIENCE.into(),
    );

    let signature = login_request.signature(
        SignatureScheme::Ed25519,
        PrivateKey::from_hex("INSERT_HEX_ENCODED_PRIVATE_KEY_HERE")?,
    )?;

    let auth_token = login_request
        .authenticate(&signature, Environment::Mainnet)
        .await?
        .access_token;

    let account = send_request(&auth_token).await?;

    Ok(())
}

HTTPs

Alternatively, call the GET /account 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!