coinbase_advanced/lib.rs
1//! # Coinbase Advanced Trade API Client
2//!
3//! A Rust client library for the Coinbase Advanced Trade API.
4//!
5//! ## Features
6//!
7//! - REST API client with JWT authentication
8//! - Strongly typed request/response models
9//! - Async/await support with tokio
10//! - Support for both production and sandbox environments
11//!
12//! ## Quick Start
13//!
14//! ```no_run
15//! use coinbase_advanced::{Credentials, RestClient};
16//!
17//! #[tokio::main]
18//! async fn main() -> coinbase_advanced::Result<()> {
19//! // Create credentials from environment variables
20//! let credentials = Credentials::from_env()?;
21//!
22//! // Build the client
23//! let client = RestClient::builder()
24//! .credentials(credentials)
25//! .build()?;
26//!
27//! // Make API calls...
28//! Ok(())
29//! }
30//! ```
31//!
32//! ## Authentication
33//!
34//! The Coinbase Advanced Trade API uses JWT (JSON Web Tokens) for authentication.
35//! You'll need:
36//!
37//! - An API key (in the format `organizations/{org_id}/apiKeys/{key_id}`)
38//! - An EC private key in PEM format
39//!
40//! These can be obtained from the Coinbase Developer Platform.
41//!
42//! ## Sandbox Mode
43//!
44//! For testing, you can use the sandbox environment:
45//!
46//! ```no_run
47//! # use coinbase_advanced::{Credentials, RestClient};
48//! let client = RestClient::builder()
49//! .credentials(Credentials::from_env().unwrap())
50//! .sandbox(true)
51//! .build()
52//! .unwrap();
53//! ```
54
55mod client;
56mod constants;
57mod credentials;
58mod error;
59mod jwt;
60
61pub mod rest;
62pub mod models;
63pub mod rate_limit;
64pub mod ws;
65
66// Re-export main types.
67pub use client::{RestClient, RestClientBuilder};
68pub use credentials::Credentials;
69pub use error::{Error, Result};
70
71// Re-export API types for convenience.
72pub use rest::{
73 AccountsApi, ConvertApi, DataApi, FeesApi, FuturesApi, OrdersApi, PaymentMethodsApi,
74 PerpetualsApi, PortfoliosApi, ProductsApi, PublicApi, ServerTime,
75};
76
77// Re-export constants for advanced usage.
78pub mod consts {
79 pub use crate::constants::*;
80}