1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Unofficial Rust SDK for the Polymarket US Retail API.
//!
//! The crate exposes a typed async REST client and a managed WebSocket stream.
//! Requests to authenticated endpoints are signed with Ed25519 and carry the
//! `X-PM-*` headers automatically.
//!
//! # Getting started
//!
//! Public endpoints need no credentials:
//!
//! ```no_run
//! use polymarket_us::PolymarketUsClient;
//!
//! # async fn run() -> Result<(), polymarket_us::PolymarketUsError> {
//! let client = PolymarketUsClient::builder().build()?;
//! let markets = client.markets().list().await?;
//! println!("{} markets", markets.markets.len());
//! # Ok(())
//! # }
//! ```
//!
//! Authenticated endpoints read credentials from `POLYMARKET_US_KEY_ID` and
//! `POLYMARKET_US_SECRET_KEY`:
//!
//! ```no_run
//! use polymarket_us::{PolymarketUsClient, UsAuth};
//!
//! # async fn run() -> Result<(), polymarket_us::PolymarketUsError> {
//! let client = PolymarketUsClient::builder()
//! .auth(UsAuth::from_env()?)
//! .build()?;
//!
//! let balances = client.account().balances().await?;
//! # Ok(())
//! # }
//! ```
//!
//! # Resources
//!
//! Endpoints are grouped behind accessors on the client: [`PolymarketUsClient::markets`],
//! [`PolymarketUsClient::events`], [`PolymarketUsClient::orders`],
//! [`PolymarketUsClient::account`], [`PolymarketUsClient::portfolio`], and
//! [`PolymarketUsClient::search`].
//!
//! # Retries
//!
//! Idempotent requests (`GET`, `DELETE`) are retried with exponential backoff and
//! jitter, honouring a server-supplied `Retry-After`. `POST` is **never** retried
//! automatically, so a submitted order cannot be duplicated by the transport
//! layer. See [`RetryConfig`].
//!
//! # Streaming
//!
//! [`PolymarketUsStreamClient`] maintains a WebSocket with automatic reconnect,
//! re-subscribing on every reconnect. Connections that go silent are torn down
//! after [`StreamConnectConfig::idle_timeout`] so a dead socket cannot stall the
//! stream indefinitely.
//!
//! ```no_run
//! use polymarket_us::{PolymarketUsStreamClient, StreamSubscription};
//!
//! # async fn run() -> Result<(), polymarket_us::PolymarketUsError> {
//! let stream = PolymarketUsStreamClient::from_gateway_base_url(
//! "https://gateway.polymarket.us",
//! None,
//! );
//!
//! let mut managed = stream
//! .connect(vec![StreamSubscription::market_data("BTC-USD")])
//! .await?;
//!
//! while let Some(message) = managed.next().await {
//! println!("{:?}", message.kind);
//! }
//! # Ok(())
//! # }
//! ```
pub use UsAuth;
pub use ;
pub use PolymarketUsError;
pub use ;
pub use RetryConfig;
pub use ;
pub use ;