> ## Documentation Index
> Fetch the complete documentation index at: https://docs.heyniblet.com/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTP, data, and caching

> Fetch external data responsibly and keep apps useful during upstream failures.

Apps can load the bundled HTTP module and request public data while rendering:

```starlark theme={null}
load("http.star", "http")

def fetch_status():
    response = http.get(
        "https://status.example.com/current.json",
        ttl_seconds = 300,
    )
    if response.status_code != 200:
        return None
    return response.json()
```

## Choose a sensible cache lifetime

Set `ttl_seconds` based on how quickly the source changes and how often users need a new frame. Caching reduces latency, avoids unnecessary upstream traffic, and helps protect an app from short outages.

## Design a fallback

Prefer this order when an upstream request fails:

1. reuse safe cached data;
2. show a clear stale or unavailable state;
3. log a concise diagnostic without user data; and
4. call `fail()` only for a permanent condition that prevents any useful frame.

## Hosted network policy

Approved apps run with network isolation. Private, loopback, link-local, metadata, internal service, and non-approved destinations are blocked. Redirects and DNS results are checked again before a request is allowed.

<Warning>
  Before publishing, confirm that the external service permits your use, display, caching, and expected request volume. An open-source client library does not grant rights to a third-party API or its data.
</Warning>
