GitCode API Usage Guide
Paste the following prompt into your AI chat to install this skill:
Please follow https://skillhub.cn/install/skillhub.md and install @user_f6d71f82/gitcode-api.
About this skill
The Specific Problem
In engineering teams, calling GitCode REST APIs usually faces two pain points: hand-writing httpx or requests calls often results in inconsistent response structures and cumbersome attribute access; and API keys (like GITCODE_ACCESS_TOKEN) are prone to leakage during transit, lacking unified async/sync support. This skill provides a Python SDK usage standard, helping developers operate core GitCode resources like repos, branches, issues, and PRs in a structured way, while handling token encryption and decryption logic.
Core Capabilities & Key Steps
- Resource Group Invocation: The SDK adopts a layered design similar to OpenAI clients. Starting from the top-level
GitCodeorAsyncGitCodeobject, developers call specific methods (e.g.,client.repos.get()) via resource groups likeclient.repos. - Dual-Stack & Context Management: Supports both sync and async calls. Using
withcontext managers is recommended to ensure the underlyinghttpxclient closes automatically, preventing connection leaks. - Response Objects: APIs return lightweight response objects with attribute access, rather than plain dictionaries, simplifying data parsing.
- Token Security: Defaults to reading the
GITCODE_ACCESS_TOKENenvironment variable. If the token is encrypted, passing adecryptkey to the client constructor allows the SDK to decode it before authentication, avoiding plaintext exposure. - Corporate Network Adaptation: For SSL self-signed certificate errors, it supports passing a custom
httpxclient with averifyparameter, similar to configuringREQUESTS_CA_BUNDLE.
Boundaries & Cautions
- Untyped Requests/Responses: Unlike the OpenAI SDK, this SDK focuses on GitCode REST resources and lacks strongly typed request/response objects. Developers should rely on documentation or
method_signature(name)for runtime introspection. - Repository Scope: If
ownerandrepoare not set on the global client, these parameters must be explicitly passed to every repository-scoped method. - Script Deprecation: The bundled
scripts/gitcode_api_cli.pyis deprecated. In production, prioritize the built-in CLI or manage tokens via environment variables, avoiding exposing secrets in command-line arguments.
Use Cases
- In CI, read GitCode repository and file contents to verify build config.
- Before release, query branches, commits, and diffs to check merge readiness.
- Automate listing, creating, and merging GitCode issues and PRs in Python.
- Configure a custom `httpx` CA for self-signed SSL errors in corporate networks.
Best For
- Engineers scripting GitCode repository, issue, and PR queries.
- Backend developers using OpenAI-style GitCode API clients.
- Ops engineers protecting encrypted `GITCODE_ACCESS_TOKEN` in CI.
- SREs fixing corporate self-signed SSL access to GitCode.
Related Skills
A QQ bot messaging framework based on qq-botpy, covering guild, C2C, and group message flows, scheduled pushes, and troubleshooting.
Explains how to calculate N+1 severance, including service-year rounding, monthly wage base, caps, taxes, and notice pay.
Takes a name input and returns a simple hello greeting.
A BPU quantization tool for Horizon RDK S100 that handles PyTorch/ONNX calibration, stride alignment, post-processing, and board-side validation.