gitcode-api 1.0.0__tar.gz

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.
Files changed (28) hide show
  1. gitcode_api-1.0.0/LICENSE +21 -0
  2. gitcode_api-1.0.0/PKG-INFO +208 -0
  3. gitcode_api-1.0.0/README.md +185 -0
  4. gitcode_api-1.0.0/gitcode_api/__init__.py +23 -0
  5. gitcode_api-1.0.0/gitcode_api/_base_client.py +324 -0
  6. gitcode_api-1.0.0/gitcode_api/_client.py +235 -0
  7. gitcode_api-1.0.0/gitcode_api/_exceptions.py +39 -0
  8. gitcode_api-1.0.0/gitcode_api/_models.py +272 -0
  9. gitcode_api-1.0.0/gitcode_api/resources/__init__.py +77 -0
  10. gitcode_api-1.0.0/gitcode_api/resources/_shared.py +75 -0
  11. gitcode_api-1.0.0/gitcode_api/resources/account.py +766 -0
  12. gitcode_api-1.0.0/gitcode_api/resources/collaboration.py +1451 -0
  13. gitcode_api-1.0.0/gitcode_api/resources/misc.py +301 -0
  14. gitcode_api-1.0.0/gitcode_api/resources/repositories.py +1458 -0
  15. gitcode_api-1.0.0/gitcode_api.egg-info/PKG-INFO +208 -0
  16. gitcode_api-1.0.0/gitcode_api.egg-info/SOURCES.txt +26 -0
  17. gitcode_api-1.0.0/gitcode_api.egg-info/dependency_links.txt +1 -0
  18. gitcode_api-1.0.0/gitcode_api.egg-info/requires.txt +2 -0
  19. gitcode_api-1.0.0/gitcode_api.egg-info/top_level.txt +1 -0
  20. gitcode_api-1.0.0/pyproject.toml +66 -0
  21. gitcode_api-1.0.0/setup.cfg +4 -0
  22. gitcode_api-1.0.0/tests/test_base_client.py +72 -0
  23. gitcode_api-1.0.0/tests/test_client.py +35 -0
  24. gitcode_api-1.0.0/tests/test_models.py +16 -0
  25. gitcode_api-1.0.0/tests/test_resources_account.py +101 -0
  26. gitcode_api-1.0.0/tests/test_resources_collaboration.py +94 -0
  27. gitcode_api-1.0.0/tests/test_resources_misc.py +36 -0
  28. gitcode_api-1.0.0/tests/test_resources_repositories.py +59 -0
@@ -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,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,185 @@
1
+ # GitCode-API
2
+
3
+ [中文说明](README.zh.md)
4
+
5
+ `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.
6
+
7
+ ## Why This Project
8
+
9
+ - Community project for developers who want a practical GitCode Python library.
10
+ - Sync and async clients with a consistent API surface.
11
+ - Resource namespaces such as `client.repos`, `client.pulls`, and `client.users`.
12
+ - Repository defaults via `owner=` and `repo=` on the client.
13
+ - Sphinx docs plus a mirrored GitCode REST API reference in `docs/`.
14
+
15
+ ## Installation
16
+
17
+ Install from PyPI:
18
+
19
+ ```bash
20
+ pip install gitcode-api
21
+ ```
22
+
23
+ For local development from source:
24
+
25
+ ```bash
26
+ uv sync
27
+ ```
28
+
29
+ Install documentation dependencies:
30
+
31
+ ```bash
32
+ uv sync --group docs
33
+ ```
34
+
35
+ ## Authentication
36
+
37
+ Pass `api_key=` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
38
+
39
+ ```bash
40
+ export GITCODE_ACCESS_TOKEN="your-token"
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ### Sync client
46
+
47
+ ```python
48
+ from gitcode_api import GitCode
49
+
50
+ client = GitCode(
51
+ owner="SushiNinja",
52
+ repo="GitCode-API",
53
+ )
54
+
55
+ try:
56
+ repo = client.repos.get()
57
+ branches = client.branches.list(per_page=5)
58
+
59
+ print(repo.full_name)
60
+ for branch in branches:
61
+ print(branch.name)
62
+ finally:
63
+ client.close()
64
+ ```
65
+
66
+ ### Async client
67
+
68
+ ```python
69
+ import asyncio
70
+
71
+ from gitcode_api import AsyncGitCode
72
+
73
+
74
+ async def main() -> None:
75
+ client = AsyncGitCode(owner="SushiNinja", repo="GitCode-API")
76
+ try:
77
+ pulls = await client.pulls.list(state="open", per_page=20)
78
+ print(len(pulls))
79
+ finally:
80
+ await client.close()
81
+
82
+
83
+ asyncio.run(main())
84
+ ```
85
+
86
+ ## Common Workflows
87
+
88
+ Create a pull request:
89
+
90
+ ```python
91
+ from gitcode_api import GitCode
92
+
93
+ client = GitCode(owner="SushiNinja", repo="GitCode-API")
94
+
95
+ try:
96
+ pull = client.pulls.create(
97
+ title="Add feature",
98
+ head="feature-branch",
99
+ base="main",
100
+ body="Implements the new flow.",
101
+ )
102
+ print(pull.number)
103
+ finally:
104
+ client.close()
105
+ ```
106
+
107
+ Get the authenticated user:
108
+
109
+ ```python
110
+ from gitcode_api import GitCode
111
+
112
+ client = GitCode()
113
+
114
+ try:
115
+ user = client.users.me()
116
+ print(user.login)
117
+ finally:
118
+ client.close()
119
+ ```
120
+
121
+ Search repositories:
122
+
123
+ ```python
124
+ from gitcode_api import GitCode
125
+
126
+ client = GitCode()
127
+
128
+ try:
129
+ repos = client.search.repositories(q="sdk language:python", per_page=10)
130
+ for repo in repos:
131
+ print(repo.full_name)
132
+ finally:
133
+ client.close()
134
+ ```
135
+
136
+ ## Available Resources
137
+
138
+ Both `GitCode` and `AsyncGitCode` expose:
139
+
140
+ - `repos` and `contents`
141
+ - `branches` and `commits`
142
+ - `issues` and `pulls`
143
+ - `labels`, `milestones`, and `members`
144
+ - `releases`, `tags`, and `webhooks`
145
+ - `users`, `orgs`, `search`, and `oauth`
146
+
147
+ ## Examples
148
+
149
+ Runnable examples live in `examples/`:
150
+
151
+ - `get_current_user.py`
152
+ - `get_repository_overview.py`
153
+ - `list_pull_requests.py`
154
+ - `async_list_branches.py`
155
+
156
+ Example scripts load shared configuration from `examples/.env` using `python-dotenv`.
157
+
158
+ ```bash
159
+ uv run python examples/get_current_user.py
160
+ uv run python examples/get_repository_overview.py
161
+ uv run python examples/list_pull_requests.py
162
+ uv run python examples/async_list_branches.py
163
+ ```
164
+
165
+ See `examples/.env.example` for the expected variables.
166
+
167
+ ## Documentation
168
+
169
+ - Project docs entry: `docs/index.rst`
170
+ - SDK docs: `docs/sdk/index.rst`
171
+ - REST API mirror: `docs/rest_api/index.rst`
172
+
173
+ Build the docs locally with Sphinx:
174
+
175
+ ```bash
176
+ uv run --group docs sphinx-build -b html docs docs/_build/html
177
+ ```
178
+
179
+ ## Project Status
180
+
181
+ 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.
182
+
183
+ ## Contributing
184
+
185
+ 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,23 @@
1
+ """Public package exports for the GitCode SDK."""
2
+
3
+ from pathlib import Path
4
+
5
+ from ._client import AsyncGitCode, GitCode
6
+ from ._exceptions import (
7
+ GitCodeAPIError,
8
+ GitCodeConfigurationError,
9
+ GitCodeError,
10
+ GitCodeHTTPStatusError,
11
+ )
12
+
13
+ __version__ = (Path(__file__).parent / "version.txt").read_text().strip()
14
+
15
+ __all__ = [
16
+ "__version__",
17
+ "AsyncGitCode",
18
+ "GitCode",
19
+ "GitCodeAPIError",
20
+ "GitCodeConfigurationError",
21
+ "GitCodeError",
22
+ "GitCodeHTTPStatusError",
23
+ ]