You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/usage/rest-api.md
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -319,3 +319,61 @@ You can also provide a custom map function to handle complex pagination (such as
319
319
accessible_repo: Repository
320
320
print(accessible_repo.full_name)
321
321
```
322
+
323
+
## Calling API Directly
324
+
325
+
In some cases, you may want to call the API directly without using the generated methods. You can use the `github.request` / `github.arequest` method to make a raw request.
326
+
327
+
For example, to upload a release asset:
328
+
329
+
=== "Sync"
330
+
331
+
```python hl_lines="11-18"
332
+
from githubkit import GitHub
333
+
from githubkit.versions.latest.models import Release, ReleaseAsset
334
+
335
+
github = GitHub()
336
+
337
+
resp = github.rest.repos.get_release_by_tag(
338
+
"owner", "repo", "tag_name"
339
+
)
340
+
release: Release = resp.parsed_data
341
+
342
+
resp = github.request(
343
+
"POST",
344
+
release.upload_url.split("{?")[0], # (1)!
345
+
params={"name": "test", "label": "description"},
346
+
content=b"file content",
347
+
headers={"Content-Type": "application/zip"},
348
+
response_model=ReleaseAsset,
349
+
)
350
+
asset: ReleaseAsset = resp.parsed_data
351
+
```
352
+
353
+
1. The release `upload_url` is a template URL. In this example, we simply remove the template part.
354
+
355
+
=== "Async"
356
+
357
+
```python hl_lines="11-18"
358
+
from githubkit import GitHub
359
+
from githubkit.versions.latest.models import Release, ReleaseAsset
0 commit comments