supabase-management-rs

Crates.iosupabase-management-rs
lib.rssupabase-management-rs
version0.0.3
sourcesrc
created_at2025-03-12 21:01:11.65505+00
updated_at2025-03-24 18:57:28.881308+00
descriptionLightweight Rust client for Supabase's management API
homepage
repositoryhttps://github.com/tembo-io/supabase-management-rs
max_upload_size
id1590227
size24,072
Vinícius Miguel (vrmiguel)

documentation

README

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.

Commit count: 0

cargo fmt