Use the Go and Rust SDKs
Install the Go and Rust clients and run a first call with each, then find auth, mail, storage and actions.
Go
Install:
go get github.com/PGBHub/pgb-sdk-go
A first call, running an action:
package main
import (
"context"
"fmt"
"log"
"github.com/PGBHub/pgb-sdk-go"
)
func main() {
client := pgbhub.NewClient(pgbhub.Config{
APIKey: "your_api_key",
ProjectID: "my-project",
})
res, err := client.InvokeAction(context.Background(), "approveOrder", map[string]any{
"orderId": "ord_102",
}, false) // false = not a dry run
if err != nil {
log.Fatalf("Action failed: %v", err)
}
fmt.Printf("Status: %s (took %.2f ms)\n", res.Status, res.DurationMS)
}
ProjectID alone targets https://my-project.pgbhub.app. Each field can come from the environment: PGBHUB_API_KEY, PGBHUB_PROJECT_ID, PGBHUB_ENDPOINT. Config also takes Timeout (30 seconds), MaxRetries (2) and RetryDelay.
Other areas:
login, _ := client.Auth.SignIn(ctx, "[email protected]", "a-long-password")
if login.MFARequired { client.Auth.VerifyMFA(ctx, login.ChallengeToken, "123456") }
res, err := client.Mail.Send(ctx, pgbhub.SendMailOptions{
To: "[email protected]", Subject: "Your receipt", Text: "Thanks for your order.",
})
Failures are *pgbhub.APIError with StatusCode, Code and RetryAfter. Check them with errors.As.
Rust
Add to Cargo.toml:
[dependencies]
pgbhub = { git = "https://github.com/PGBHub/pgb-sdk-rs" }
tokio = { version = "1", features = ["full"] }
serde_json = "1"
A first call, running an action:
use pgbhub::{PGBHubClient, PGBHubConfig};
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = PGBHubClient::new(PGBHubConfig {
api_key: Some("your_api_key".to_string()),
project_id: Some("my-project".to_string()),
..PGBHubConfig::default()
});
let mut params = HashMap::new();
params.insert("orderId".to_string(), serde_json::json!("ord_102"));
let res = client.invoke_action("approveOrder", params, false).await?;
println!("Status: {} (took {:.2} ms)", res.status, res.duration_ms);
Ok(())
}
PGBHubConfig::default() reads PGBHUB_API_KEY, PGBHUB_PROJECT_ID and the endpoint from the environment. Errors are PGBHubError::Api { status, message, code, retry_after }.
let login = client.auth.sign_in("[email protected]", Some("a-long-password")).await?;
if login.mfa_required {
client.auth.verify_mfa(&login.challenge_token.unwrap(), "123456").await?;
}
Both SDKs
- Reads retry on
502,503,504and connection errors. Writes never retry. - Both support auth (including one-time codes, magic links, two-factor and social login), actions with effects, mail, and storage with private buckets and signed URLs.
- Mail and storage admin calls need your secret key, so use them on a server.
- Actions registered with
effectscan send mail, queue work and more after the SQL commits. See Actions.
More guides in Console: APIs, SDKs & tools
The REST API: query your data over HTTPS
Read and write rows, run SQL and call actions with plain HTTP requests to your project address.
Use the TypeScript SDK
Install @pgb/sdk, create a client, run a first query, and find the calls for each service.
Use the Python SDK
Install pgbhub, create a sync or async client, run a first query, and use auth, mail, storage and actions.
Connect AI coding tools with the MCP server
Let tools such as Claude Code, Cursor and Windsurf inspect your schema and run your actions through the PGB MCP server.
Webhooks: receiving and sending
Receive webhooks in a function, send them from event rules, cron jobs, jobs and actions, and verify signatures.
API keys
Publishable and secret project keys, account-level keys, how to create, scope, rotate and revoke them.