GitCode Python SDK
gitcode_api provides synchronous and asynchronous httpx clients for the
GitCode REST API. The public entry points are GitCode and
AsyncGitCode.
Highlights
OpenAI-style resource groups such as
client.reposandclient.pulls.Shared repository context via
owner=andrepo=on the client.Lightweight response wrappers that expose JSON fields as attributes.
Matching sync and async resource surfaces.
Each resource group exposes a cached
methodsproperty (public callable names in stable SDK order) andmethod_signature(name)for a single method’s signature string, for runtime introspection.
Install
Install the package from PyPI:
pip install -U gitcode-api
For local development, install the project and optional documentation
dependencies with uv:
uv sync
uv sync --group docs
Authentication
Pass api_key= directly or set GITCODE_ACCESS_TOKEN in your environment.
If either value is stored in encrypted form, pass decrypt= so the client can
decode it before authenticating.
export GITCODE_ACCESS_TOKEN="your-token"
from gitcode_api import GitCode
from trusted_library import decrypt_token
client = GitCode(api_key="encrypted-token", decrypt=decrypt_token)
Client lifecycle
Both clients accept shared defaults for owner, repo, base_url, and
timeout.
GitCode manages a synchronous httpx.Client and supports close().
AsyncGitCode manages an asynchronous httpx.AsyncClient and supports
await close().
Closing the SDK client also closes a supplied http_client instance.
from gitcode_api import GitCode
client = GitCode(owner="SushiNinja", repo="GitCode-API")
try:
repo = client.repos.get()
print(repo.full_name)
finally:
client.close()
Available resource groups
The SDK exposes these resource groups on both sync and async clients:
reposandcontentsbranchesandcommitsissuesandpullslabels,milestones, andmembersreleases,tags, andwebhooksusers,orgs,search, andoauth
On any of the groups above, read client.<group>.methods for a stable tuple
of public method names (excluding private helpers and the methods /
method_signature utilities). Order follows the SDK’s segment-based sort key, not plain alphabetical
order on each full name. The value is built once per resource instance. Use
client.<group>.method_signature("method_name") for parameters and return type of one callable.
Next steps
See Quickstart for common usage patterns.
See CLI for the command-line entry point and examples.
See Client API Reference for the client-oriented chained API reference.
See SDK Reference for the autodoc-generated module reference.