Repos
Repos are created programmatically and referenced by slug or stable ID.
Quickstart
Section titled “Quickstart”from githosted import Client
client = Client()
# Create a reporepo = client.create_repo("my-new-project")print(repo.id) # "rp_8f3k2m1q9t6w4z7c5n2h"
# Write immediately — no setup neededrepo.write("README.md", "# My Project", "Initial commit")Referencing Repos
Section titled “Referencing Repos”By slug
Section titled “By slug”repo = client.repo("my-project")By stable ID
Section titled “By stable ID”repo = client.repo(id="rp_8f3k2m1q9t6w4z7c5n2h")Store IDs, not slugs. Repo IDs (rp_ prefix) are globally unique and stable even if the repo is renamed. Slugs are human-readable but can change.
API Reference
Section titled “API Reference”client.create_repo(name, *, slug)
Section titled “client.create_repo(name, *, slug)”Create a new repo in a workspace. Returns a Repo handle with a stable ID.
repo = client.create_repo("session-data")
# The repo is immediately ready for reads and writesprint(repo.id) # "rp_..."print(repo.info.slug) # "session-data"client.repo(slug, *, id)
Section titled “client.repo(slug, *, id)”Get a handle to an existing repo. Does not make a network call — the handle is created locally.
# These are equivalent ways to get a repo handlerepo = client.repo("my-project")repo = client.repo(id="rp_8f3k2m1q9t6w4z7c5n2h")Repo IDs
Section titled “Repo IDs”| Property | Value |
|---|---|
| Format | rp_ prefix + 20-char NanoID (0-9a-z) |
| Unique | Globally unique across all workspaces |
| Stable | Doesn’t change if repo is renamed |
client.list_repos(*, page_size, page_token)
Section titled “client.list_repos(*, page_size, page_token)”List all repos in the workspace. Requires a workspace token (gw_).
result = client.list_repos()for r in result.repos: print(f"{r.id} {r.slug} ({r.default_branch})")
# Paginatedpage = client.list_repos(page_size=10)next_page = client.list_repos(page_token=page.next_page_token)Common Patterns
Section titled “Common Patterns”Store repo ID in your database
Section titled “Store repo ID in your database”# When creating a project for a userrepo = client.create_repo(f"{user_id}-{project_name}")db.users.update(user_id, repo_id=repo.id)
# Later — resume from stored IDrepo_id = db.users.get(user_id).repo_idrepo = client.repo(id=repo_id)