gitcode-api 1.0.0__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/__init__.py +23 -0
- gitcode_api/_base_client.py +324 -0
- gitcode_api/_client.py +235 -0
- gitcode_api/_exceptions.py +39 -0
- gitcode_api/_models.py +272 -0
- gitcode_api/resources/__init__.py +77 -0
- gitcode_api/resources/_shared.py +75 -0
- gitcode_api/resources/account.py +766 -0
- gitcode_api/resources/collaboration.py +1451 -0
- gitcode_api/resources/misc.py +301 -0
- gitcode_api/resources/repositories.py +1458 -0
- gitcode_api-1.0.0.dist-info/METADATA +208 -0
- gitcode_api-1.0.0.dist-info/RECORD +16 -0
- gitcode_api-1.0.0.dist-info/WHEEL +5 -0
- gitcode_api-1.0.0.dist-info/licenses/LICENSE +21 -0
- gitcode_api-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gitcode-api
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Project-URL: github, https://github.com/Trenza1ore/GitCode-API
|
|
5
|
+
Project-URL: gitcode, https://gitcode.com/SushiNinja/GitCode-API
|
|
6
|
+
Classifier: Development Status :: 4 - Beta
|
|
7
|
+
Classifier: Programming Language :: Python
|
|
8
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Python: <4,>=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: httpx
|
|
21
|
+
Requires-Dist: python-dotenv
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# GitCode-API
|
|
25
|
+
|
|
26
|
+
[中文说明](README.zh.md)
|
|
27
|
+
|
|
28
|
+
`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.
|
|
29
|
+
|
|
30
|
+
## Why This Project
|
|
31
|
+
|
|
32
|
+
- Community project for developers who want a practical GitCode Python library.
|
|
33
|
+
- Sync and async clients with a consistent API surface.
|
|
34
|
+
- Resource namespaces such as `client.repos`, `client.pulls`, and `client.users`.
|
|
35
|
+
- Repository defaults via `owner=` and `repo=` on the client.
|
|
36
|
+
- Sphinx docs plus a mirrored GitCode REST API reference in `docs/`.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
Install from PyPI:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install gitcode-api
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For local development from source:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
uv sync
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Install documentation dependencies:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv sync --group docs
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Authentication
|
|
59
|
+
|
|
60
|
+
Pass `api_key=` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
export GITCODE_ACCESS_TOKEN="your-token"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### Sync client
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from gitcode_api import GitCode
|
|
72
|
+
|
|
73
|
+
client = GitCode(
|
|
74
|
+
owner="SushiNinja",
|
|
75
|
+
repo="GitCode-API",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
repo = client.repos.get()
|
|
80
|
+
branches = client.branches.list(per_page=5)
|
|
81
|
+
|
|
82
|
+
print(repo.full_name)
|
|
83
|
+
for branch in branches:
|
|
84
|
+
print(branch.name)
|
|
85
|
+
finally:
|
|
86
|
+
client.close()
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Async client
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
import asyncio
|
|
93
|
+
|
|
94
|
+
from gitcode_api import AsyncGitCode
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
async def main() -> None:
|
|
98
|
+
client = AsyncGitCode(owner="SushiNinja", repo="GitCode-API")
|
|
99
|
+
try:
|
|
100
|
+
pulls = await client.pulls.list(state="open", per_page=20)
|
|
101
|
+
print(len(pulls))
|
|
102
|
+
finally:
|
|
103
|
+
await client.close()
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
asyncio.run(main())
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Common Workflows
|
|
110
|
+
|
|
111
|
+
Create a pull request:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from gitcode_api import GitCode
|
|
115
|
+
|
|
116
|
+
client = GitCode(owner="SushiNinja", repo="GitCode-API")
|
|
117
|
+
|
|
118
|
+
try:
|
|
119
|
+
pull = client.pulls.create(
|
|
120
|
+
title="Add feature",
|
|
121
|
+
head="feature-branch",
|
|
122
|
+
base="main",
|
|
123
|
+
body="Implements the new flow.",
|
|
124
|
+
)
|
|
125
|
+
print(pull.number)
|
|
126
|
+
finally:
|
|
127
|
+
client.close()
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Get the authenticated user:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from gitcode_api import GitCode
|
|
134
|
+
|
|
135
|
+
client = GitCode()
|
|
136
|
+
|
|
137
|
+
try:
|
|
138
|
+
user = client.users.me()
|
|
139
|
+
print(user.login)
|
|
140
|
+
finally:
|
|
141
|
+
client.close()
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Search repositories:
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from gitcode_api import GitCode
|
|
148
|
+
|
|
149
|
+
client = GitCode()
|
|
150
|
+
|
|
151
|
+
try:
|
|
152
|
+
repos = client.search.repositories(q="sdk language:python", per_page=10)
|
|
153
|
+
for repo in repos:
|
|
154
|
+
print(repo.full_name)
|
|
155
|
+
finally:
|
|
156
|
+
client.close()
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Available Resources
|
|
160
|
+
|
|
161
|
+
Both `GitCode` and `AsyncGitCode` expose:
|
|
162
|
+
|
|
163
|
+
- `repos` and `contents`
|
|
164
|
+
- `branches` and `commits`
|
|
165
|
+
- `issues` and `pulls`
|
|
166
|
+
- `labels`, `milestones`, and `members`
|
|
167
|
+
- `releases`, `tags`, and `webhooks`
|
|
168
|
+
- `users`, `orgs`, `search`, and `oauth`
|
|
169
|
+
|
|
170
|
+
## Examples
|
|
171
|
+
|
|
172
|
+
Runnable examples live in `examples/`:
|
|
173
|
+
|
|
174
|
+
- `get_current_user.py`
|
|
175
|
+
- `get_repository_overview.py`
|
|
176
|
+
- `list_pull_requests.py`
|
|
177
|
+
- `async_list_branches.py`
|
|
178
|
+
|
|
179
|
+
Example scripts load shared configuration from `examples/.env` using `python-dotenv`.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
uv run python examples/get_current_user.py
|
|
183
|
+
uv run python examples/get_repository_overview.py
|
|
184
|
+
uv run python examples/list_pull_requests.py
|
|
185
|
+
uv run python examples/async_list_branches.py
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
See `examples/.env.example` for the expected variables.
|
|
189
|
+
|
|
190
|
+
## Documentation
|
|
191
|
+
|
|
192
|
+
- Project docs entry: `docs/index.rst`
|
|
193
|
+
- SDK docs: `docs/sdk/index.rst`
|
|
194
|
+
- REST API mirror: `docs/rest_api/index.rst`
|
|
195
|
+
|
|
196
|
+
Build the docs locally with Sphinx:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
uv run --group docs sphinx-build -b html docs docs/_build/html
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Project Status
|
|
203
|
+
|
|
204
|
+
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.
|
|
205
|
+
|
|
206
|
+
## Contributing
|
|
207
|
+
|
|
208
|
+
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.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
gitcode_api/__init__.py,sha256=NvLp28D9brVbmv2ROSZ8mxKDuIamE9xeutBKGl9pra8,497
|
|
2
|
+
gitcode_api/_base_client.py,sha256=zI1WXrCsnjTl5iypee3C878WElZuEr7V8icYhiWa5IE,12346
|
|
3
|
+
gitcode_api/_client.py,sha256=j4Kh1gKH_pJFJC5ppR0jaQ2Xfr1KSrhCwStYzmbeulg,7630
|
|
4
|
+
gitcode_api/_exceptions.py,sha256=KnhyXuSVDhqG8LiCxBDGnztqJi4SJz4Q0EuGU2b8OuU,1127
|
|
5
|
+
gitcode_api/_models.py,sha256=IU4IBkadmQFoJ0rE1iOc7qHHu9GcpO5lB1NtdP3C7oc,6074
|
|
6
|
+
gitcode_api/resources/__init__.py,sha256=nsCKW0bFDZ5ombJZxLThmO82sOuF7o4OKUMRkAmwbwk,1725
|
|
7
|
+
gitcode_api/resources/_shared.py,sha256=uDxrJC18ILm2t7r7-Wx-8Lf5iRFZvXKVgWLwdOBz1D8,2989
|
|
8
|
+
gitcode_api/resources/account.py,sha256=gNS9G4PUulXbJ4p6MDbMyvaGOMst3Ptwg6_jz9wWXA8,29070
|
|
9
|
+
gitcode_api/resources/collaboration.py,sha256=0RDEiQfiRyoTuwSJvwmoMcyUaMnWhcqeCAkWhqM1ND0,54764
|
|
10
|
+
gitcode_api/resources/misc.py,sha256=9it01m_G4KDW39Un2bedjsRqDLS9sgOFF5Z6tnY0xLc,11950
|
|
11
|
+
gitcode_api/resources/repositories.py,sha256=yJ9wytCnODfdBhJmDvSTD0PPzfQHIWvZeccO8yqSofQ,56887
|
|
12
|
+
gitcode_api-1.0.0.dist-info/licenses/LICENSE,sha256=gOACXuWhMu6PJKVLr9RQbxX3HULnZIGNXCaMFJIXhoA,1067
|
|
13
|
+
gitcode_api-1.0.0.dist-info/METADATA,sha256=aU9ldKN-Egu0IQQ3ZeWnSk6__2x6B7I_fq0KLUz-yfg,4878
|
|
14
|
+
gitcode_api-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
15
|
+
gitcode_api-1.0.0.dist-info/top_level.txt,sha256=gIlg0ptyOUHJT64ajOjWIhRPYgIQnMIvnhhnesw9fxU,12
|
|
16
|
+
gitcode_api-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hugo Huang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gitcode_api
|