Console SDK(Python)
The Python management-surface SDK (pip package agentbase-console-python-sdk, import namespace agentbase_console) covers the Console / management-surface API: organization and project governance, Key issuance, cross-project operations, and can coexist in the same environment with the Server package (../server-sdk/python.md). For the Node / Java / Go surfaces, see nodejs.md / java.md / go.md in the same directory.
Artifacts and installation
The artifact has not been published to PyPI: extract the Console wheel from the agentbase-sdks release ZIP and install it with pip; for the complete commands, see the "Obtaining and Installing" section of ../examples/python.md.
Initialization and auth mounting
The Console login response body does not contain the session secret (it is only in the a_session_console cookie); first log in via raw HTTP to get the cookie, then attach it to the Console SDK client:
import re
import requests
from agentbase_console.client import Client as ConsoleClient
resp = requests.post(
'https://appbuild.oceanbase.com/v1/account/sessions/email',
headers={'X-Appwrite-Project': 'console', 'Content-Type': 'application/json'},
json={'email': CONSOLE_EMAIL, 'password': CONSOLE_PASSWORD},
)
secret = re.search(r'a_session_console=([^;]+)', resp.headers['set-cookie']).group(1)
console_client = (
ConsoleClient()
.set_endpoint('https://appbuild.oceanbase.com/v1')
.set_project('console')
)
console_client.add_header('origin', 'https://appbuild.oceanbase.com')
console_client.add_header('x-forwarded-host', 'appbuild.oceanbase.com')
console_client.add_header('Cookie', f'a_session_console={secret}')Typical governance calls
The service plane (agentbase_console.services) includes account, teams, projects, users, proxy, migrations, etc.; method names are snake_case, the same as the Server package:
from agentbase_console.services.projects import Projects
from agentbase_console.services.teams import Teams
teams = Teams(console_client)
projects = Projects(console_client)
teams.create(team_id='my-team', name='My Team', roles=['owner'])
project = projects.create(project_id='unique()', name='My Project', team_id='my-team')
key = projects.create_key(
project_id=project.id,
name='server key',
scopes=['users.read', 'users.write', 'teams.read', 'teams.write'],
key_id='unique()',
)
print(key.secret) # API Key used by the Server SDK, appears only once in the creation responseConsole-only operations such as organizations, members, and platform registration cannot use a project API Key.
Feature surface navigation
For the complete mapping of governance domains to services see nodejs.md "Feature surface navigation"; feature pages per domain: Organizations, Projects and Keys, Quotas, Usage, Sites and Domains, Platform Operations.
Errors and boundaries
The Console Session cookie and OAuth test Sessions are mutually isolated; in short-lived JWT scenarios
set_jwt(token), writing to logs is forbidden.For SQL scenarios, you can point the Client to the application project and configure a project API Key (../databases/sql-proxy.md).
Examples by language
The following presents examples by language for each functional domain; each card can switch languages (synced across the full page).
Create a team, project, and issue a Key
Python method names are snake_case, Go uses a facade New* constructor + With* options. This domain has no direct REST call tab; for direct REST calls, see the "Quotas and rate limits" card below.
- Console (Node.js)
- Java
- Python
- Go
import { Client, Teams, Projects, ID, Scopes } from 'agentbase-console-sdk';
const client = new Client()
.setEndpoint(process.env.APPBASE_ENDPOINT!) // https://appbuild.oceanbase.com/v1
.setProject(process.env.APPBASE_CONSOLE_PROJECT_ID!); // Console project, usually console
const teams = new Teams(client);
const team = await teams.create({ teamId: ID.unique(), name: 'My Team' });
const projects = new Projects(client);
const project = await projects.create({
projectId: ID.unique(),
name: 'todo-app',
teamId: team.$id,
region: 'default' // Region enum not used by Appwrite Cloud
});
const key = await projects.createKey({
projectId: project.$id,
name: 'setup-script',
scopes: [Scopes.UsersRead, Scopes.UsersWrite] // minimize scope
});
// key.secret is returned only once at creation// Organization = Team: Teams.create(teamId, name, roles) (positional parameters, POST /teams),
// Fill team.getId() into the 3-th positional parameter of projects.create below; for the full list of create positional parameters, see “Quick Start” in java.md in the same directory
io.agentbase.console.services.Teams teams = new io.agentbase.console.services.Teams(consoleClient);
var team = teams.create(
io.agentbase.console.ID.unique(), "My Team", java.util.List.of("owner"));
Projects projects = new Projects(consoleClient);
var project = projects.create(
io.agentbase.console.ID.unique(), "billing-service", team.getId(),
io.agentbase.console.enums.Region.DEFAULT, null, // poolTag is nullable
null, null, null, null, null, null, null, null, null, null);
var key = projects.createKey(project.getId(), "ci-deploy",
java.util.List.of(io.agentbase.console.enums.Scopes.USERS_READ,
io.agentbase.console.enums.Scopes.USERS_WRITE),
null, null, null);
System.out.println(key.getSecret()); // secret appears only once in the creation response# console_client initialization see "Initialization and auth loading" above; full steps see "Quick start" above
from agentbase_console.services.projects import Projects
from agentbase_console.services.teams import Teams
teams = Teams(console_client)
projects = Projects(console_client)
teams.create(team_id='my-team', name='My Team', roles=['owner']) # In the Console, Organization = Team
project = projects.create(project_id='unique()', name='My Project', team_id='my-team')
key = projects.create_key(
project_id=project.id, name='server key',
scopes=['users.read', 'users.write', 'teams.read', 'teams.write'],
key_id='unique()')
print(key.secret) # Appears only once, in the create response// consolefacade "agentbase-console-go-sdk/agentbase"; for consoleClient initialization, see go.md in the same directory
consoleTeams := consolefacade.NewTeams(consoleClient)
consoleProjects := consolefacade.NewProjects(consoleClient)
_, _ = consoleTeams.Create("my-team", "My Team", consoleTeams.WithCreateRoles([]string{"owner"}))
project, _ := consoleProjects.Create("unique()", "My Project", "my-team")
key, _ := consoleProjects.CreateKey(project.Id, "server key", []string{
"users.read", "users.write", "teams.read", "teams.write",
})
fmt.Println(key.Secret) // Appears only once, in the create responseUsage queries
Three-level aggregation (the most recent 30 UTC days) and the legacy scheme are two separate systems; method names cannot be guessed from each other (see usage).
- Console (Node.js)
- Java
- Python
- Go
// account / organizations / projects are Console SDK service instances
await account.listUsageAggregates();
await organizations.listUsageAggregates({ organizationId: '<organizationId>' });
await projects.listUsageAggregates({ projectId: '<projectId>' });// The Java Console SDK generated name is getUsageAggregates (different from JS's listUsageAggregates)
new io.agentbase.console.services.Projects(consoleClient)
.getUsageAggregates("<projectId>"); // Project level
new io.agentbase.console.services.SelfHostedOrganizations(consoleClient)
.getUsageAggregates("<organizationId>"); // Organization level (same endpoints as the JS organizations surface)
// Account level (/account/usage/aggregates) has no typed method in console-java; use a direct REST call
// Legacy: applies to the project set by setProject (period enum ONE_HOUR / ONE_DAY)
new io.agentbase.console.services.Project(consoleClient)
.getUsage(null, null, io.agentbase.console.enums.ProjectUsageRange.ONE_DAY);# This document does not provide a Python SDK example for three-level usage aggregation.
# Examples in this section can use Node / Java / REST; for Python calls, check the Console SDK in use
# Use the published package's service classes, methods and parameters; do not guess from JS naming conventions.// server-go@release-2.6.0 has no three-level aggregate methods
// side; the only legacy pattern is selfhostedorganizations.GetUsage(organizationId, WithGetUsageRange).
// The Console Go face has been delivered since 2.7.0; this document does not cover its three-level aggregation usage—use Node / Java / REST instead, and do not infer from JS naming.Quotas and rate limits (direct REST calls)
The Python Console plane likewise has no typed quota/ratelimit evidence; use the unified REST endpoints:
- REST (curl)
# Query current quota and rate limits:
curl -sS "$APPBASE_ENDPOINT/projects/<projectId>/limits" \
-H "X-Appwrite-Project: $APPBASE_CONSOLE_PROJECT_ID" \
-H "X-Appwrite-Key: $APPBASE_CONSOLE_API_KEY"
# Settings: PATCH the same path, body is flat rate-limit + quota fields; Quota 0 = unlimited, RateLimit must be a positive integer
curl -sS -X PATCH "$APPBASE_ENDPOINT/projects/<projectId>/limits" \
-H 'Content-Type: application/json' \
-H "X-Appwrite-Project: $APPBASE_CONSOLE_PROJECT_ID" \
-H "X-Appwrite-Key: $APPBASE_CONSOLE_API_KEY" \
-d '{"databaseStorageLimit": 0}'
# See limits.mdx for the full field set and field-name pitfallsExample Guide
Complete Python (Server / Console) call syntax: ../examples/python.md