polymarket_client_sdk/data/mod.rs
1//! Polymarket Data API client and types.
2//!
3//! **Feature flag:** `data` (required to use this module)
4//!
5//! This module provides a client for interacting with the Polymarket Data API,
6//! which offers HTTP endpoints for querying user positions, trades, activity,
7//! market holders, open interest, volume data, and leaderboards.
8//!
9//! # Overview
10//!
11//! The Data API is a read-only HTTP API that provides access to Polymarket data.
12//! It is separate from the CLOB (Central Limit Order Book) API which handles trading.
13//!
14//! ## Available Endpoints
15//!
16//! | Endpoint | Description |
17//! |----------|-------------|
18//! | `/` | Health check |
19//! | `/positions` | Get current positions for a user |
20//! | `/trades` | Get trades for a user or markets |
21//! | `/activity` | Get on-chain activity for a user |
22//! | `/holders` | Get top holders for markets |
23//! | `/value` | Get total value of a user's positions |
24//! | `/closed-positions` | Get closed positions for a user |
25//! | `/traded` | Get total markets a user has traded |
26//! | `/oi` | Get open interest for markets |
27//! | `/live-volume` | Get live volume for an event |
28//! | `/v1/leaderboard` | Get trader leaderboard rankings |
29//! | `/v1/builders/leaderboard` | Get builder leaderboard rankings |
30//! | `/v1/builders/volume` | Get daily builder volume time-series |
31//!
32//! # Example
33//!
34//! ```no_run
35//! use polymarket_client_sdk::types::address;
36//! use polymarket_client_sdk::data::{Client, types::request::PositionsRequest};
37//!
38//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
39//! // Create a client with the default endpoint
40//! let client = Client::default();
41//!
42//! // Build a request for user positions
43//! let request = PositionsRequest::builder()
44//! .user(address!("56687bf447db6ffa42ffe2204a05edaa20f55839"))
45//! .build();
46//!
47//! // Fetch positions
48//! let positions = client.positions(&request).await?;
49//!
50//! for position in positions {
51//! println!("{}: {} tokens at ${:.2}",
52//! position.title,
53//! position.size,
54//! position.current_value
55//! );
56//! }
57//! # Ok(())
58//! # }
59//! ```
60//!
61//! # API Base URL
62//!
63//! The default API endpoint is `https://data-api.polymarket.com`.
64
65pub mod client;
66pub mod types;
67
68pub use client::Client;