# HTTP Fetch Timeouts

## HTTP fetch timeouts

**Canonical page:** <https://docs.seda.xyz/home/for-agents/modules/12-http-fetch-timeouts>

Authoritative reference:

* <https://docs.seda.xyz/home/for-developers/define-your-data-source/accessing-a-public-api/http-fetch-timeouts>

This page exists to prevent flaky Oracle Programs caused by slow upstream APIs.

***

### Default values (do not assume otherwise)

* Per-request timeout: **2,000ms**
* Global timeout budget across all HTTP requests: **20,000ms**

**Meaning:**

* Each individual HTTP request defaults to failing after \~2 seconds.
* Across the entire Oracle Program execution, all HTTP requests share a combined maximum budget of \~20 seconds.

***

### Why this matters

If your upstream frequently takes longer than 2 seconds, requests will fail unless you explicitly set a per-request timeout.

However, increasing timeouts too much can cause you to hit the global 20s budget if you make multiple requests.

***

### How to set a per-request timeout (Rust)

Copy/paste example:

```rust
use seda_sdk_rs::{http::http_fetch, HttpFetchOptions};

let response = http_fetch(
    "https://httpbin.org/get",
    Some(HttpFetchOptions {
        timeout_ms: Some(3_000), // 3 seconds timeout
        ..Default::default()
    })
);
```

### When to increase timeout

Increase `timeout_ms` when the upstream is expected to be slower, for example:

* AI/ML services (often 3–5 seconds)
* heavy data processing APIs
* slow but reliable providers

***

### Agent action (do this every time you add an HTTP call)

**Action checklist:**

1. Estimate upstream p95 latency (rough guess is fine).
2. Set `timeout_ms` slightly above that p95 (e.g., p95=2.4s → timeout=3.0s).
3. Count how many HTTP calls the Oracle Program makes in one execution.
4. Ensure the total worst-case time across calls stays within the 20,000ms global budget.

**Checkpoint:**

* You can state the chosen `timeout_ms` and why.
* You can justify that the number of HTTP calls will not exceed the global 20s budget.

#### Authoritative references:

**- Operating and Running a Data Proxy:** <https://docs.seda.xyz/home/for-data-providers/operating-a-data-proxy/operating-and-running-a-data-proxy>

**- Data Proxy overview:** <https://docs.seda.xyz/home/for-data-providers/operating-a-data-proxy/introduction-to-data-proxy>

**- Enabling SEDA Fast on a Data Proxy:** <https://docs.seda.xyz/home/for-data-providers/operating-a-data-proxy/enabling-seda-fast-on-a-data-proxy>

**- Advanced:** API-key Gated Data (proxyHttpFetch): <https://docs.seda.xyz/home/for-data-providers/operating-a-data-proxy/advanced-api-key-gated-data>

**- System requirements:** <https://docs.seda.xyz/home/for-data-providers/operating-a-data-proxy/system-requirements>

**- Scaling up:** <https://docs.seda.xyz/home/for-data-providers/operating-a-data-proxy/scaling-up>

**- Debugging:** <https://docs.seda.xyz/home/for-data-providers/operating-a-data-proxy/debugging>

<br>
