nautechsystems/nautilus_trader · error · anyhow::Error

failed to create Data API HTTP client

Error message

failed to create Data API HTTP client

What it means

Alongside the CLOB client, `new` constructs a `PolymarketDataApiHttpClient` pointed at `config.data_api_url()`. Failure to build that client (bad URL, timeout, or proxy) is wrapped with this context. The execution client cannot initialize without it since account-state and market data fetches depend on the Data API.

Source

Thrown at crates/adapters/polymarket/src/execution/mod.rs:157

            &signer_address,
            secrets.funder.as_deref(),
        )?;
        let http_client = PolymarketClobHttpClient::new_with_proxy(
            secrets.credential.clone(),
            signer_address.clone(),
            config.base_url_http.clone(),
            config.http_timeout_secs,
            proxy_url.clone(),
        )
        .map_err(|e| anyhow::anyhow!("{e}"))
        .context("failed to create CLOB HTTP client")?;

        let data_api_client = PolymarketDataApiHttpClient::new_with_proxy(
            Some(config.data_api_url()),
            config.http_timeout_secs,
            proxy_url.clone(),
        )
        .map_err(|e| anyhow::anyhow!("{e}"))
        .context("failed to create Data API HTTP client")?;

        let order_signer =
            OrderSigner::new(&secrets.private_key).context("failed to create order signer")?;
        let order_builder = Arc::new(PolymarketOrderBuilder::new(
            order_signer,
            signer_address,
            maker_address,
            config.signature_type,
        ));

        let retry_config = RetryConfig {
            max_retries: config.max_retries,
            initial_delay_ms: config.retry_delay_initial_ms,
            max_delay_ms: config.retry_delay_max_ms,
            backoff_factor: 2.0,
            jitter_ms: 1_000,
            operation_timeout_ms: Some(config.http_timeout_secs * 1_000),

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Verify the data API base URL config is a valid absolute URL (e.g. https://data-api.polymarket.com)
  2. Check proxy_url validity (scheme + host + port) or disable the proxy
  3. Validate http_timeout_secs is positive
  4. Compare against the default data_api_url to find the bad override
  5. Read the inner `{e}` for the precise parse failure

Example fix

// before
data_api_url: "data-api.polymarket.com".into(), // no scheme
// after
data_api_url: "https://data-api.polymarket.com".into(),
Defensive patterns

Strategy: validation

Validate before calling

fn validate_data_api_url(cfg: &PolymarketExecConfig) -> Result<(), String> {
    let url = cfg.data_api_url();
    if !url.starts_with("https://") { return Err(format!("data API URL invalid: {url}")); }
    Ok(())
}

Try / catch

let client = PolymarketExecutionClient::new(...)
    .map_err(|e| { tracing::error!("data api init: {e:#}"); e })?;

Prevention

When it happens

Trigger: Invalid data_api_url produced by config.data_api_url() (misconfigured data API base URL); invalid http_timeout_secs; unparseable proxy_url passed to new_with_proxy.

Common situations: Wrong POLYMARKET_DATA_API_URL config value or typo in the default; proxy misconfiguration affecting only the data API path; env-specific override pointing to a non-URL string.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/dd6be1f0e01b8c18. Report an issue: GitHub.