This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud. Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from previous releases when APIs differ.
Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Rust SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs
Add this to your Cargo.toml:
[dependencies]
appwrite = "0.20.0"
tokio = { version = "1.48", features = ["full"] }Or using cargo add:
cargo add appwrite
cargo add tokio --features fullThe SDK is async and runs on the Tokio runtime.
Create a client with your Appwrite API endpoint, project ID and an API key. You can find the project ID in your project settings, and create an API key with the scopes you need in your project's API keys section.
use appwrite::Client;
let client = Client::new()
.set_endpoint("https://<REGION>.cloud.appwrite.io/v1")
.set_project("<YOUR_PROJECT_ID>")
.set_key("<YOUR_API_KEY>");If you self-host Appwrite, use your own endpoint, such as https://<HOSTNAME_OR_IP>/v1. Add .set_self_signed(true) only in development, when your server uses a self-signed certificate.
Create a service from the client and call any of its methods. Every method is async and returns appwrite::Result<T>. Optional parameters take an Option; pass None to skip one.
use appwrite::id::ID;
use appwrite::services::Users;
use appwrite::Client;
#[tokio::main]
async fn main() -> appwrite::Result<()> {
let client = Client::new()
.set_endpoint("https://<REGION>.cloud.appwrite.io/v1")
.set_project("<YOUR_PROJECT_ID>")
.set_key("<YOUR_API_KEY>");
let users = Users::new(&client);
let user = users
.create(
ID::unique(),
Some("email@example.com"),
None,
Some("password"),
Some("Walter O'Brien"),
)
.await?;
println!("{} {} {}", user.id, user.name, user.email);
Ok(())
}Failed requests return an AppwriteError with the HTTP status code, the message, the error type and the raw response body.
match users
.create(ID::unique(), Some("email@example.com"), None, None, None)
.await
{
Ok(user) => println!("{}", user.name),
Err(error) => eprintln!(
"Appwrite error {} ({}): {}",
error.code,
error.get_type().unwrap_or("unknown"),
error.message
),
}This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.
Please see the BSD-3-Clause license file for more information.
