Bluefin Pro SDK for Rust
Overview
The Bluefin Pro SDK for Rust allows developers to interact with the Bluefin Pro platform using generated client libraries from OpenAPI 3.0 specifications. This SDK enables seamless interaction with REST and WebSocket APIs to perform various trading operations, such as placing orders, withdrawing funds, and subscribing to market feeds.
To generate Rust client code:
Features
- REST API Client: Interact with Bluefin Pro’s REST APIs to perform operations such as creating orders, managing accounts, and retrieving trading data.
- WebSocket API Client: Subscribable channels for real-time market data and updates, generated from OpenAPI specs.
- Signature Utilities: Built-in cryptographic utilities to sign
account_authorization,adjust_isolated_margin,update_leverage,create orderandwithdrawrequests securely. - Environment Support: Example configurations and code provided to connect to DEVNET TESTNET or MAINNET environments.
Installation
Add the following to your Cargo.toml:
[]
= "1.0.0"
Note: Replace 1.0.0 with the latest version available.
Resources and API Support
REST APIs
The REST APIs are grouped by functionality and defined within the OpenAPI files located in the resources folder of the
repository. These APIs include:
- Authentication: Authenticate through Bluefin and get the Authorization token for REST API and WebSocket operations
- Trade: Place or cancel orders, fetch open orders.
- Account Management: View and manage user account information, update account leverage for market addresses.
- Exchange Info: View the public information of the exchange
Example usage for REST APIs can be found in the
examplesfolder.
WebSocket APIs
WebSocket APIs enable real-time market data and event subscription. Documentation for WebSocket messages is available
within the OpenAPI specs in resources/websocket-api.yaml file.
- Market: Real-time market updates such as Ticker, Recent Trades, Oracle Price and more
- Account: Real-time account updates such as Order Updates, Balance Changes and more (requires authentication token)
Example usage for WebSocket APIs can be found in the
examplesfolder. Websocket examples are prefixed byws-
Examples
The SDK provides example code to demonstrate how to use the APIs.
- Connecting to DEVNET, TESTNET or MAINNET: The examples are configured for DEVNET, TESTNET and MAINNET environments. You can toggle between environments based on your use case.
- Signing Requests: Ensure secure interactions by leveraging the built-in signing utilities before making
account_authorization,adjust_isolated_margin,update_leverage,create orderandwithdrawrequests.
To run examples, navigate to the examples directory and execute them using:
Replace
<example_name>with the specific example file you wish to execute.
The SDK provides test accounts with hex encoded ed25519 public key and private key available to run examples on DEVNET or TESTNET
example.rsis a full example that shows how to use the SDK to perform multiple operations, including fetching account details, exchange info, creating an order, withdrawing funds, and listening to account and market updates.
Utility Functions
The SDK comes with built-in support for signing specific API requests:
- Sign
Create OrderRequests: Cryptographically sign your order requests securely. - Sign
WithdrawRequests: Cryptographically sign your withdrawal requests. - Sign
Update LeverageRequests: Cryptographically sign your update leverage requests. - Sign
Adjust Isolated MarginRequests: Cryptographically sign your adjust isolated margin requests. - Sign
Account AuthorizationRequests: Cryptographically sign your account authorization requests.
For other API interactions, refer to the examples folder for detailed guidance.
Questions?
If you encounter an issue or have any questions, please feel free to reach out via GitHub issues or the support team.