Skip to content

Getting Started

ThetaDataDx connects directly to ThetaData's servers — no Java terminal process to install or babysit. Pick a language, install, save your credentials, and make a request.

1. Install

toml
# Cargo.toml
[dependencies]
thetadatadx = "12"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

The historical client is async; tokio provides the runtime.

2. Save credentials

Create a creds.txt in your working directory: your ThetaData account email on line 1, password on line 2.

you@example.com
your-password

No subscription yet? Create an account at thetadata.net — several endpoints work on the free tier (look for the Free badge on reference pages).

3. First request

rust
use thetadatadx::{Credentials, DirectConfig, ThetaDataDxClient};

#[tokio::main]
async fn main() -> Result<(), thetadatadx::Error> {
    let creds = Credentials::from_file("creds.txt")?;
    let tdx = ThetaDataDxClient::connect(&creds, DirectConfig::production()).await?;

    let rows = tdx.stock_history_eod("AAPL", "20250303", "20250306").await?;
    for t in &rows {
        println!("{}: open={} close={} volume={}", t.date, t.open, t.close, t.volume);
    }
    Ok(())
}

Every endpoint follows this shape. Browse the API Reference — each page carries the signature and a runnable sample in all five surfaces.

Good to knows

  • Dates are YYYYMMDD strings in the SDKs ("20250303"); the HTTP server also accepts ISO YYYY-MM-DD. Timestamps come back as milliseconds since midnight Eastern Time — see Symbology & Contract Identity.
  • Connect once, reuse the client. One client multiplexes any number of historical requests and an optional streaming session; per-request connections waste the authentication round trip.
  • Markets closed? Connect with Config.dev() / DirectConfig::dev() to stream a replayed historical session, and prefer historical endpoints over snapshots on weekends.

Released under the Apache-2.0 License.