Daita Agents · Guide
Let the agent pull data from a web API you declare. Responses are saved as files it can query.
An HTTP API source lets the agent fetch from a web API and query what comes back. You declare which host it may reach. The agent chooses the path, the query values and a JSON body.
Each response is saved as a data file, with a receipt beside it, in a folder Daita manages for the source. Detaching the source deletes that folder. The agent reads the files with data_query, file_read and file_search, and the catalog lists them like an attached folder. Nothing lands in your own files or artifacts unless you or the agent saves it.
from daita import HttpSource
source = await agent.attach(
HttpSource(
"https://api.usaspending.gov/api/v2",
name="USAspending",
post_paths=("/bulk_download/awards/",),
download_hosts=("files.usaspending.gov",),
)
)daita attach atlas http \
--url https://api.usaspending.gov/api/v2 \
--post-path /bulk_download/awards/ \
--download-host files.usaspending.gov \
--source-name USAspendingIn the terminal app, type /source add and choose HTTP API.
Store the key in your keychain or an environment variable, and give Daita a reference. Daita saves only the reference.
from daita import HttpAuth, HttpSource
from daita.security import SecretReference
HttpSource(
"https://api.example.com/v1",
credential=SecretReference.keychain("example-api"),
auth=HttpAuth.HEADER,
auth_name="X-Api-Key",
)daita attach atlas http --url https://api.example.com/v1 \
--auth header --auth-name X-Api-Key --secret-ref keychain:example-apiauth is bearer (an Authorization: Bearer header), header (the header named by auth_name) or query (the query parameter named by auth_name). The background host does not see your shell environment, so prefer a keychain reference there. The terminal app stores a pasted key in your keychain for you.
| Setting | Meaning |
|---|---|
base_url | An https URL. Plain http is allowed only for localhost. Requests stay under its path |
post_paths | Paths that may take a POST. Declare only endpoints whose POST reads, such as a search or an export request |
download_hosts | Other hosts where the API links files. GET only, and they never get the credential |
requests_per_minute | Pacing, 1 to 600. Default 60 |
sensitivity | How sensitive the responses are. Default internal |
maximum_outbound_sensitivity | The most sensitive conversation data a request may come from. Default internal |
folder | Python only. Your own absolute folder for responses, outside Daita's state. It is kept on detach |
The agent uses one tool, api_fetch:
| Argument | Use |
|---|---|
path or url | A path under base_url, or a link the API returned, such as a next page or a file |
method and body | GET (default), or POST to a declared path with a JSON body |
query | Query values |
records_path | A JSON pointer such as /results. Also saves those records as NDJSON so data_query can read them as rows |
save_as | A file name, when the default does not suit |
wait_seconds | Up to 60, to wait before polling a job |
Each result reports the status, content type, saved files with size and SHA-256, and an outline of the JSON keys. Pages are separate fetches. A path_pattern such as awards/*.ndjson queries them together. Supported responses are CSV, TSV, JSON, NDJSON, Parquet and ZIP. A ZIP is kept and its data files are extracted. Anything else, such as an HTML page, is refused and not saved.
The .fetch receipt records the URL without any credential, the method, the body hash, the status and the hash of each file.
| Limit | Value |
|---|---|
| One response | 256 MiB |
| ZIP extraction | 1 GiB and 200 data files |
JSON read for records_path | 64 MiB |
| Request body | 64 KiB |
| One fetch, including waits and redirects | 5 minutes |
| Redirects | 5, each checked against declared hosts |
A folder query reads at most 256 MiB. For bigger data, load it into a database and attach that.
maximum_outbound_sensitivity, api_fetch refuses. Fetch in a separate conversation, or raise the limit if the API may see that data.Scheduled routines and jobs can fetch within the same limits, for example to check an API on a schedule.
You do not have to attach an API first.
A public API with no key. Name it in your request: "using the USAspending API at https://api.usaspending.gov/api/v2, list the top-tier agencies". The agent reads it with api_fetch in that turn. The first request to each host shows an approval card, and approving covers further requests to that host for the rest of the request. Nothing is attached or saved. Responses come back as text, 16 KiB at a time. Only https URLs without keys are allowed.
An API with a key. Describe it: "use the awards API at https://api.example.com/v1, the key goes in the X-Api-Key header". The agent declares it with source_connect, and you get one approval card showing the base URL, how the key is sent and any POST paths or download hosts. The card asks for the key in a private field, and it goes straight to your keychain. The model never sees it. You can instead name an environment variable that holds the key.
After you approve, the agent ends that turn and runs your request again in a follow-up turn that can use the new source. PostgreSQL connects the same way, and the card asks for the password.
If you paste a key into the chat, it has already reached the model. Rotate it.
Only runs you start can connect a source or fetch a URL without one. Routines and jobs cannot.
Related: Data Sources, Querying, Files and Folders.