2 releases
new 0.0.2 | Mar 20, 2025 |
---|---|
0.0.1 | Mar 12, 2025 |
#305 in Development tools
410 downloads per month
20KB
351 lines
supabase-management-rs
A Rust client library for the Supabase Management API.
⚠️ Note: This crate is still a work in progress and not all API endpoints are implemented yet.
Usage
use supabase_management_rs::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with your Supabase management API key
let client = Client::new("your-api-key".to_string());
// List all projects
let projects = client.list_projects().await?;
// Get the first project
if let Some(project) = projects.first() {
println!("Project name: {}", project.name);
// Check project health
let health = client.get_project_health(&project.id).await?;
println!("Project health: {:?}", health);
// Execute a query
let results: serde_json::Value = client
.query(&project.id, "SELECT now()")
.await?;
println!("Query result: {:?}", results);
// Pause a project
client.pause_project(&project.id).await?;
}
Ok(())
}
Executing Queries
You can execute PostgreSQL queries on your project and deserialize the results into your own types:
use serde::Deserialize;
#[derive(Deserialize, Debug)]
struct Row {
id: i32,
hash_value: String,
}
let rows: Vec<Row> = client
.query(
project_id,
"SELECT generate_series(1, 3) AS id, \
md5(generate_series(1, 3)::text) AS hash_value",
)
.await?;
println!("{:?}", rows);
API Key
To obtain an API key for the Supabase Management API, refer to the official documentation.
Dependencies
~7–22MB
~237K SLoC