Skip to main content
The Rust SDK gives you a typed, async client for the whole incident.io API. There’s a function for every endpoint and a type for every request and response, all generated from our OpenAPI specification. Forgetting a required parameter is a compile error, and the types are shaped so that the API adding a field or an enum value never is. It requires Rust 1.88 or later and an async runtime. The examples below use tokio, but any runtime works, since the client is built on reqwest.

Installing

Your first request

You’ll need an API key from Settings > API keys (see API keys). Then:

Parameters and payloads

Every endpoint is an async function that takes a &Configuration and a params struct, even endpoints with no parameters today. That’s deliberate: when the API adds a parameter, it becomes a new field on a struct you already use, rather than a change to the function’s signature. new() takes the endpoint’s required parameters. Optional ones are chainable set_* methods, which take the value directly rather than Some(value):
Request payloads work the same way:
Every generated type is #[non_exhaustive], so you can’t build one with a struct literal. Use new() and the set_* methods instead. This is what lets us add fields to the API without breaking your build.

Pagination

List endpoints are cursor-paginated. Read the next cursor from pagination_meta.after and pass it back:

Filtering

List endpoints filter on a map of operator to values, sent as created_at[gte]=2024-05-01. The operators each field accepts are in its docs, and are commonly one_of, not_in, gte, and lte.

Errors

Every endpoint returns Result<T, Error<SomethingError>>, where the inner enum has a variant per documented status code. Documenting another status code is a backwards-compatible change for us, so these enums need a wildcard arm:
Enums generated from the schema work the same way. Each has an Unknown(String) variant for values your version doesn’t know about, and a wildcard arm is required.

Configuration

Every field on Configuration is public, so change what you need:
There’s no default request timeout, which is reqwest’s behaviour. Set one unless you have a reason not to. The client makes a single attempt per request and doesn’t retry. When you hit the rate limit, the 429 response body tells you when to try again. The README shows how to read it. TLS uses rustls by default. To use OpenSSL instead, turn off default features and enable native-tls.

Deprecated endpoints

Endpoints we’ve deprecated stay available and carry #[deprecated], so rustc warns at the call site. Don’t go by the version in the name: some v2 endpoints are deprecated too.

Versioning

The SDK is kept up to date with the API automatically. Additions to the API are minor versions. A change that would break your code, like a removed field, is released as a new major version, and its release notes list what changed.

Resources

crates.io

The incident-io crate and its versions.

docs.rs

Every type and function, with their docs.

GitHub

Source, README, and issues for the Rust SDK.

All SDKs

Clients for Go, TypeScript, Python, Ruby, PHP, and .NET.