gitcode-api 1.2.4__py3-none-any.whl → 1.2.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gitcode_api/_cli_banner.py +1 -1
- gitcode_api/cli.py +67 -9
- gitcode_api/llm/__init__.py +49 -0
- gitcode_api/llm/_tool.py +368 -0
- gitcode_api/llm/mcp.py +96 -0
- gitcode_api/llm/openai.py +56 -0
- gitcode_api/py.typed +1 -0
- gitcode_api/version.txt +1 -1
- gitcode_api-1.2.6.dist-info/METADATA +371 -0
- {gitcode_api-1.2.4.dist-info → gitcode_api-1.2.6.dist-info}/RECORD +14 -9
- gitcode_api-1.2.4.dist-info/METADATA +0 -237
- {gitcode_api-1.2.4.dist-info → gitcode_api-1.2.6.dist-info}/WHEEL +0 -0
- {gitcode_api-1.2.4.dist-info → gitcode_api-1.2.6.dist-info}/entry_points.txt +0 -0
- {gitcode_api-1.2.4.dist-info → gitcode_api-1.2.6.dist-info}/licenses/LICENSE +0 -0
- {gitcode_api-1.2.4.dist-info → gitcode_api-1.2.6.dist-info}/top_level.txt +0 -0
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: gitcode-api
|
|
3
|
-
Version: 1.2.4
|
|
4
|
-
Summary: Easy to use Python SDK for the GitCode REST API, community-maintained.
|
|
5
|
-
Author-email: Hugo Huang <hugo@hugohuang.com>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: documentation, https://gitcode-api.readthedocs.io
|
|
8
|
-
Project-URL: gitcode, https://gitcode.com/SushiNinja/GitCode-API
|
|
9
|
-
Project-URL: github, https://github.com/Trenza1ore/GitCode-API
|
|
10
|
-
Keywords: gitcode,git,devops,api,sdk,python,httpx,client
|
|
11
|
-
Classifier: Development Status :: 4 - Beta
|
|
12
|
-
Classifier: Programming Language :: Python
|
|
13
|
-
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
-
Requires-Python: <4,>=3.9
|
|
23
|
-
Description-Content-Type: text/markdown
|
|
24
|
-
License-File: LICENSE
|
|
25
|
-
Requires-Dist: httpx
|
|
26
|
-
Dynamic: license-file
|
|
27
|
-
|
|
28
|
-
# GitCode-API
|
|
29
|
-
|
|
30
|
-
[](https://pypi.org/project/gitcode-api) [](https://github.com/Trenza1ore/GitCode-API) [](https://gitcode.com/SushiNinja/GitCode-API) [](https://pepy.tech/projects/gitcode-api)
|
|
31
|
-
|
|
32
|
-
[](https://gitcode-api.readthedocs.io) [](README.zh.md)
|
|
33
|
-
|
|
34
|
-
`gitcode-api` is a community-maintained Python SDK for the GitCode REST API. It provides easy-to-use synchronous and asynchronous clients, repository-scoped helpers, and lightweight response models so you can work with GitCode from Python without hand-writing raw HTTP requests.
|
|
35
|
-
|
|
36
|
-
## Why This Project
|
|
37
|
-
|
|
38
|
-
- Community project for developers who want a practical GitCode Python library.
|
|
39
|
-
- Sync and async clients with a consistent API surface.
|
|
40
|
-
- Resource groups such as `client.repos`, `client.pulls`, and `client.users`.
|
|
41
|
-
- Repository defaults via `owner=` and `repo=` on the client.
|
|
42
|
-
- Sphinx docs plus a mirrored GitCode REST API reference in `docs/`.
|
|
43
|
-
|
|
44
|
-
## Installation
|
|
45
|
-
|
|
46
|
-
Install from PyPI:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
pip install -U gitcode-api
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Authentication
|
|
53
|
-
|
|
54
|
-
Pass `api_key=` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
export GITCODE_ACCESS_TOKEN="your-token"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
If your token is stored in encrypted form, pass `decrypt=` to decode either an
|
|
61
|
-
encrypted `api_key=` value or an encrypted `GITCODE_ACCESS_TOKEN` value before
|
|
62
|
-
the client uses it.
|
|
63
|
-
|
|
64
|
-
```python
|
|
65
|
-
from gitcode_api import GitCode
|
|
66
|
-
from trusted_library import decrypt_token
|
|
67
|
-
|
|
68
|
-
client = GitCode(
|
|
69
|
-
api_key="encrypted-token",
|
|
70
|
-
decrypt=decrypt_token,
|
|
71
|
-
)
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## CLI
|
|
75
|
-
|
|
76
|
-
After installation, you can invoke the SDK directly from the command line:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
gitcode-api repos get --api-key "$GITCODE_ACCESS_TOKEN" --owner SushiNinja --repo GitCode-API
|
|
80
|
-
python -m gitcode_api pulls list --api-key "$GITCODE_ACCESS_TOKEN" --owner SushiNinja --repo GitCode-API --state open
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Commands mirror the synchronous resource methods on `GitCode`, using the pattern
|
|
84
|
-
`gitcode-api <resource> <method> ...`. For methods that accept extra `**params`
|
|
85
|
-
or `**payload`, pass repeated `--set key=value` flags or `--set-json '{"key": "value"}'`.
|
|
86
|
-
|
|
87
|
-
## Quick Start
|
|
88
|
-
|
|
89
|
-
### Sync client
|
|
90
|
-
|
|
91
|
-
```python
|
|
92
|
-
from gitcode_api import GitCode
|
|
93
|
-
|
|
94
|
-
client = GitCode(
|
|
95
|
-
owner="SushiNinja",
|
|
96
|
-
repo="GitCode-API",
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
repo = client.repos.get()
|
|
100
|
-
branches = client.branches.list(per_page=5)
|
|
101
|
-
|
|
102
|
-
print(repo.full_name)
|
|
103
|
-
for branch in branches:
|
|
104
|
-
print(branch.name)
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Async client
|
|
108
|
-
|
|
109
|
-
```python
|
|
110
|
-
import asyncio
|
|
111
|
-
from gitcode_api import AsyncGitCode
|
|
112
|
-
|
|
113
|
-
async def main() -> None:
|
|
114
|
-
client = AsyncGitCode(owner="SushiNinja", repo="GitCode-API")
|
|
115
|
-
pulls = await client.pulls.list(state="open", per_page=20)
|
|
116
|
-
print(len(pulls))
|
|
117
|
-
|
|
118
|
-
asyncio.run(main())
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Context managers
|
|
122
|
-
|
|
123
|
-
`GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in. `close()` also clears the LRU cache used by each resource group's `method_signature(...)` helper (see the [Available Resources](#available-resources) section).
|
|
124
|
-
|
|
125
|
-
```python
|
|
126
|
-
from gitcode_api import GitCode
|
|
127
|
-
|
|
128
|
-
with GitCode(owner="SushiNinja", repo="GitCode-API") as client:
|
|
129
|
-
repo = client.repos.get()
|
|
130
|
-
print(repo.full_name)
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
```python
|
|
134
|
-
import asyncio
|
|
135
|
-
from gitcode_api import AsyncGitCode
|
|
136
|
-
|
|
137
|
-
async def main() -> None:
|
|
138
|
-
async with AsyncGitCode(owner="SushiNinja", repo="GitCode-API") as client:
|
|
139
|
-
pulls = await client.pulls.list(state="open", per_page=20)
|
|
140
|
-
print(len(pulls))
|
|
141
|
-
|
|
142
|
-
asyncio.run(main())
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## Common Workflows
|
|
146
|
-
|
|
147
|
-
Create a pull request:
|
|
148
|
-
|
|
149
|
-
```python
|
|
150
|
-
from gitcode_api import GitCode
|
|
151
|
-
|
|
152
|
-
client = GitCode(owner="SushiNinja", repo="GitCode-API")
|
|
153
|
-
|
|
154
|
-
pull = client.pulls.create(
|
|
155
|
-
title="Add feature",
|
|
156
|
-
head="feature-branch",
|
|
157
|
-
base="main",
|
|
158
|
-
body="Implements the new flow.",
|
|
159
|
-
)
|
|
160
|
-
print(pull.number)
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Get the authenticated user:
|
|
164
|
-
|
|
165
|
-
```python
|
|
166
|
-
from gitcode_api import GitCode
|
|
167
|
-
|
|
168
|
-
client = GitCode()
|
|
169
|
-
|
|
170
|
-
user = client.users.me()
|
|
171
|
-
print(user.login)
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Search repositories:
|
|
175
|
-
|
|
176
|
-
```python
|
|
177
|
-
from gitcode_api import GitCode
|
|
178
|
-
|
|
179
|
-
client = GitCode()
|
|
180
|
-
|
|
181
|
-
repos = client.search.repositories(q="sdk language:python", per_page=10)
|
|
182
|
-
for repo in repos:
|
|
183
|
-
print(repo.full_name)
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
## Available Resources
|
|
187
|
-
|
|
188
|
-
Both `GitCode` and `AsyncGitCode` expose:
|
|
189
|
-
|
|
190
|
-
- `repos` and `contents`
|
|
191
|
-
- `branches` and `commits`
|
|
192
|
-
- `issues` and `pulls`
|
|
193
|
-
- `labels`, `milestones`, and `members`
|
|
194
|
-
- `releases`, `tags`, and `webhooks`
|
|
195
|
-
- `users`, `orgs`, `search`, and `oauth`
|
|
196
|
-
|
|
197
|
-
Every resource group inherits a cached `methods` property from the shared resource base: a `tuple` of public callable names in stable SDK order (underscore-segment sort key, not plain A–Z on the full identifier). Private names and the introspection helpers `methods` and `method_signature` are omitted. For example, `client.pulls.methods` helps with discovery or tooling without reading the full manual list. For one method’s parameters and return type, call `client.pulls.method_signature("list_issues")` (a cached string from `inspect.signature`, with `gitcode_api._models.` stripped from annotations).
|
|
198
|
-
|
|
199
|
-
## Examples
|
|
200
|
-
|
|
201
|
-
Runnable examples live in `examples/`:
|
|
202
|
-
|
|
203
|
-
- `get_current_user.py`
|
|
204
|
-
- `get_repository_overview.py`
|
|
205
|
-
- `list_pull_requests.py`
|
|
206
|
-
- `async_list_branches.py`
|
|
207
|
-
|
|
208
|
-
Example scripts load shared configuration from `examples/.env` using `python-dotenv`.
|
|
209
|
-
|
|
210
|
-
```bash
|
|
211
|
-
uv run python examples/get_current_user.py
|
|
212
|
-
uv run python examples/get_repository_overview.py
|
|
213
|
-
uv run python examples/list_pull_requests.py
|
|
214
|
-
uv run python examples/async_list_branches.py
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
See `examples/.env.example` for the expected variables.
|
|
218
|
-
|
|
219
|
-
## Documentation
|
|
220
|
-
|
|
221
|
-
- Project docs entry: `docs/index.rst`
|
|
222
|
-
- SDK docs: `docs/sdk/index.rst`
|
|
223
|
-
- REST API mirror: `docs/rest_api/index.rst`
|
|
224
|
-
|
|
225
|
-
Build the docs locally with Sphinx:
|
|
226
|
-
|
|
227
|
-
```bash
|
|
228
|
-
uv run --group docs sphinx-build -b html docs docs/_build/html
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
## Project Status
|
|
232
|
-
|
|
233
|
-
This is a community project and is still evolving. API coverage is already broad, but some endpoints and behaviors may continue to be refined as the SDK grows.
|
|
234
|
-
|
|
235
|
-
## Contributing
|
|
236
|
-
|
|
237
|
-
Issues, bug reports, API coverage improvements, docs fixes, and pull requests are welcome. If you are using GitCode heavily and notice missing endpoints or awkward ergonomics, contributions are especially appreciated.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|