12 breaking releases
| 0.14.0+20251008.0.0 | Nov 7, 2025 |
|---|---|
| 0.12.0+20250604.0.0 | Jun 10, 2025 |
| 0.10.0+20250212.0.0 | Feb 24, 2025 |
| 0.9.0+20241204.0.0 | Dec 18, 2024 |
| 0.1.0 |
|
#920 in Web programming
167 downloads per month
Used in oxide-httpmock
3.5MB
68K
SLoC
The Oxide Rust SDK
SDK for the Oxide API.
Installation
The oxide crate is available on crates.io. You'll probably want to use
tokio as well. Add them to your Cargo.toml file or use cargo add:
$ cargo add oxide
$ cargo add tokio
Authentication
To connect to the Oxide API, the SDK needs a host URL and a token. There are several ways to specify these:
- Configuration files: the CLI's
oxide auth logincommand generatesconfig.tomlandcredentials.tomlin$HOME/.config/oxide/. The credentials file contains sensitive information such as tokens and user IDs. - Environment variables: You can set the
OXIDE_HOSTandOXIDE_TOKENenvironment variables. - Explicit host URL and token.
The simplest way to create an authenticated client is to use
oxide::Client::new_authenticated(), which uses the same credentials and
authentication logic as the CLI. By default, it reads data from configuration
files in $HOME/.config/oxide.
Example
Create a new oxide::Client like this:
use futures::StreamExt;
use oxide::{Client, prelude::*};
#[tokio::main]
async fn main() {
// Make a client from the on-disk configuration.
let client = Client::new_authenticated()
.expect("unable to create an authenticated client");
// Start using the client!
// For example we can look at the projects in our silo:
let mut projects = client.project_list().stream();
loop {
match projects.next().await {
// No more items.
None => break,
// Print the name of a project.
Some(Ok(project)) => println!("project {}", *project.name),
// Something went wrong
Some(Err(err)) => println!("error {}", err),
}
}
}
Dependencies
~14–35MB
~449K SLoC