openintents (Rust)
Rust SDK for OpenIntents, the agentic API to buy anything. Async (tokio + reqwest with rustls).
Preview: the API is still being built, so it may change before launch.
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
use ;
async
Also: get_intent, list_intents, cancel_intent, balance,
balance_for, create_customer, get_customer, update_customer,
list_customers, create_topup, get_topup, and
webhooks::verify_webhook for the OpenIntents-Signature header (session
events carry a session: see WebhookData). CreateIntent::customer buys
for one of your customers. Unknown fields and statuses from newer API
versions are tolerated. Error::Api has the API's code, and the lease
with profile_busy.
Live events and browser sessions
stream_intent_events follows an intent as it runs: an EventStream, read
with next() or as a futures Stream. It resumes by itself after a dropped
connection, and ends once the intent is over. list_intent_events pages
the same timeline.
A session opens a payer's browser profile without an intent: to sign them in to a shop once, so later intents find them signed in. A session never pays or places an order.
use ;
async
Also list_sessions, get_session, get_session_command,
list_session_events, and for profiles list_profiles, create_profile,
get_profile and forget_profile.
A CLI binary is included behind a feature:
|
login saves your key where the npm CLI does (~/.config/openintents/config.json)
and later commands read it; OPENINTENTS_API_KEY wins when set. The commands
and flags match the npm CLI's (openintents --help), except mcp, which only
the npm CLI has. Stored secrets are write-only: no command prints a value, and
secrets set --stdin takes the fields as a JSON object so they stay out of
the process list. Exit codes: 0 completed, 1 failed or error, 2 needs
payment, 3 cancelled, 4 needs the payer to sign in, 5 needs an answer.
Country, waiting and forms
.country() or .end_user_ip() on CreateIntent, CreateSession,
CreateSignIn and CreatePortalSession picks the country the browser goes
out from; the object says which in country and country_source.
create_intent_waiting(params, 30) and get_intent_waiting(id, 30) have the
API hold the request up to 50 seconds until the intent finishes or pauses.
A question in input_request can offer choices (answer with one's id) or
ask a form of fields (answer with AnswerInput::values(id, [("name", "value")]));
expects says what a plain answer looks like. A sensitive question (an
identity document) is answered only on input_request.url.
Secrets, sign-ins and live links
use ;
async
Secrets are write-only (list_secrets, get_secret, replace_secret,
delete_secret, list_secret_uses). Also create_secret_request,
create_portal_session and create_live_link.
Webhook endpoints
create_webhook_endpoint (its secret is shown there only),
list_webhook_endpoints, get_webhook_endpoint, update_webhook_endpoint,
delete_webhook_endpoint, rotate_webhook_secret (the old secret signs for
24 more hours; verify_webhook accepts a header that carries both),
test_webhook_endpoint, list_webhook_deliveries and redeliver_webhook.
A 429 Error::Api carries retry_after and rate_limit (from the
RateLimit-* headers).
Development
Docs: https://openintents.io/docs. License: GPL-3.0-or-later.