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
@@ -148,6 +148,28 @@ from githubkit import GitHub, ActionAuthStrategy
148
148
github = GitHub(ActionAuthStrategy())
149
149
```
150
150
151
+
### Config
152
+
153
+
githubkit is highly configurable, you can change the default config by passing config options to `GitHub`:
154
+
155
+
```python
156
+
from githubkit import GitHub
157
+
158
+
github = GitHub(
159
+
base_url="https://api.github.com/",
160
+
accept_format="full+json",
161
+
previews=["starfox"],
162
+
user_agent="GitHubKit/Python",
163
+
follow_redirects=True,
164
+
timeout=None,
165
+
http_cache=True
166
+
)
167
+
```
168
+
169
+
The `accept_format` and `previews` are used to set the default `Accept` header, you can find more details in [GitHub API docs](https://docs.github.com/en/rest/overview/media-types).
170
+
171
+
The `http_cache` option enables the http caching feature powered by [Hishel](https://hishel.com/) for HTTPX. GitHub API limits the number of requests that you can make within a specific amount of time. This feature is useful to reduce the number of requests to GitHub API and avoid hitting the rate limit.
172
+
151
173
### Calling Rest API
152
174
153
175
> APIs are fully typed. Typing in the following examples is just for reference only.
@@ -156,7 +178,7 @@ Simple sync call:
156
178
157
179
```python
158
180
from githubkit import Response
159
-
from githubkit.restimport FullRepository
181
+
from githubkit.versions.latest.modelsimport FullRepository
As shown above, the response data is parsed and validated by accessing the `response.parsed_data` property. This ensures that the data type returned by the API is as expected and your code is safe to use it (with static type checking). But sometimes you may want to get the raw data returned by the API, such as when the schema is not correct. You can use the `response.text` property or `response.json()` method to get the raw data:
event = parse_obj_without_name(request.json()) # NOT RECOMMENDED
363
+
```
364
+
365
+
The `parse` and `parse_obj` function supports type overload, if you provide static value for the `event_name` parameter, the return type will be inferred automatically.
366
+
367
+
Webhook also supports versioning, you can switch between versions as follows:
0 commit comments