AI Agent Hub
Back to skills
GitCode API Usage Guide icon

GitCode API Usage Guide

Development Updated 2026.08.30

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 GitCode or AsyncGitCode object, developers call specific methods (e.g., client.repos.get()) via resource groups like client.repos.
  • Dual-Stack & Context Management: Supports both sync and async calls. Using with context managers is recommended to ensure the underlying httpx client 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_TOKEN environment variable. If the token is encrypted, passing a decrypt key 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 httpx client with a verify parameter, similar to configuring REQUESTS_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 owner and repo are 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.py is 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.