Install
openclaw skills install gitcode-apiProvides Python SDK access to GitCode REST API with sync/async clients, repo helpers, and CLI scripts for managing repos, pulls, users, and searches.
openclaw skills install gitcode-apiUse the published Python package:
pip install -U gitcode-api
Authentication defaults to the GITCODE_ACCESS_TOKEN environment variable, or pass api_key=... explicitly. If either value is encrypted, pass decrypt=... so the client can decode it before authenticating.
Consult user for confirmation before installation:
gitcode-api may introduce change to global environment.GITCODE_ACCESS_TOKEN environment variable, preferably encrypted:
decrypt argument can be passed into GitCode clients' constructor to decrypt an encrypted api_key value or encrypted GITCODE_ACCESS_TOKEN at runtime.This SDK is structured similarly to OpenAI's Python clients:
GitCode(...) or AsyncGitCode(...).client.repos, client.pulls, client.users, and client.search.client.repos.get() or await client.pulls.list().methods (public callable names in stable SDK order via a segment-based sorting) and method_signature(name) (a cached inspect.signature string for one callable) for runtime introspection; see the "Resource introspection" section in references/api-reference.md.with GitCode(...) as client: or async with AsyncGitCode(...) as client: so the SDK closes the underlying httpx client automatically, including a custom http_client.Unlike OpenAI's typed request/response shapes, this SDK focuses on GitCode REST resources and returns lightweight response objects with attribute access.
Sync:
from gitcode_api import GitCode
with GitCode(
api_key="your-token",
owner="SushiNinja",
repo="GitCode-API",
) as client:
repo = client.repos.get()
pulls = client.pulls.list(state="open", per_page=5)
print(repo.full_name)
for pull in pulls:
print(pull.number, pull.title)
Async:
import asyncio
from gitcode_api import AsyncGitCode
async def main() -> None:
async with AsyncGitCode(
api_key="your-token",
owner="SushiNinja",
repo="GitCode-API",
) as client:
branches = await client.branches.list(per_page=5)
for branch in branches:
print(branch.name)
asyncio.run(main())
Encrypted token:
from gitcode_api import GitCode
from trusted_library import decryption_method
with GitCode(
api_key="encrypted-token",
owner="SushiNinja",
repo="GitCode-API",
decrypt=decryption_method,
) as client:
repo = client.repos.get()
pulls = client.pulls.list(state="open", per_page=5)
print(repo.full_name)
for pull in pulls:
print(pull.number, pull.title)
If owner= and repo= are set on the client, repository resources can omit them per call. If not, pass owner= and repo= on repository-scoped methods.
client.repos and client.contentsclient.branches and client.commitsclient.issues and client.pullsclient.labels, client.milestones, and client.membersclient.releases, client.tags, and client.webhooksclient.users, client.orgs, client.search, and client.oauthclient.repos.get(), client.contents.get(), client.contents.create(), client.contents.update()client.branches.list(), client.commits.list(), client.commits.compare()client.issues.list(), client.issues.create(), client.pulls.list(), client.pulls.create(), client.pulls.merge()client.users.me(), client.orgs.list_authenticated(), client.search.repositories()client.oauth.build_authorize_url(), client.oauth.exchange_token()For the broader method inventory, use references/api-reference.md
Responses are lightweight objects, not plain dicts.
Typical usage:
pull = client.pulls.get(number=42)
print(pull.title)
print(pull.get("source_branch"))
payload = pull.to_dict()
Bundled helpers:
scripts/check_env.py verifies Python, package import, and token setup.scripts/gitcode_api_cli.py is a legacy example CLI (deprecated; it warns on use). Prefer the package's experimental built-in CLI (gitcode-api or python -m gitcode_api); see https://gitcode-api.readthedocs.io/en/latest/sdk/cli.html. For production, keep tokens out of argv and use env vars or your own wrapper.Q: In company network, access to GitCode failed with SSL errors mentioning "self-signed certificate".
A: Typically, a custom CA bundle needs to be set, user may pass in a custom httpx client with verify set to the certificate path, this is similar to REQUESTS_CA_BUNDLE environment variable for requests library.
from gitcode_api import GitCode
from httpx import Client
with GitCode(
owner="SushiNinja",
repo="GitCode-API",
http_client=Client(verify="path/to/my/certificate.crt"),
) as client:
repo = client.repos.get()
pulls = client.pulls.list(state="open", per_page=5)
...