Skip to content

Commit d05a334

Browse files
authored
📝 reorg getting started
1 parent c79293c commit d05a334

6 files changed

Lines changed: 36 additions & 35 deletions

File tree

docs/quickstart/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Quick Start
22

3-
Here are some common use cases to help you get started quickly. For more detailed usage, please refer to the [Usage](../usage/authentication.md) section.
3+
Here are some common use cases to help you get started quickly. For more detailed usage, please refer to the [Usage](../usage/getting-started/authentication.md) section.
44

55
!!! note
66

File renamed without changes.

docs/usage/configuration.md renamed to docs/usage/getting-started/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Available built-in throttlers:
177177

178178
### `auto_retry`
179179

180-
The `auto_retry` option enables request retrying when rate limit exceeded and server error encountered. See [Auto Retry](./auto-retry.md) for more infomation.
180+
The `auto_retry` option enables request retrying when rate limit exceeded and server error encountered. See [Auto Retry](../auto-retry.md) for more infomation.
181181

182182
### `rest_api_validate_body`
183183

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Reusing Client
2+
3+
You can make multiple requests with the same client instance in one context:
4+
5+
=== "Sync"
6+
7+
```python hl_lines="4"
8+
from githubkit import GitHub, Response
9+
from githubkit.versions.latest.models import FullRepository
10+
11+
with GitHub("<your_token_here>") as github:
12+
resp: Response[FullRepository] = github.rest.repos.get(owner="owner", repo="repo")
13+
repo: FullRepository = resp.parsed_data
14+
```
15+
16+
=== "Async"
17+
18+
```python hl_lines="4"
19+
from githubkit import GitHub, Response
20+
from githubkit.versions.latest.models import FullRepository
21+
22+
async with GitHub("<your_token_here>") as github:
23+
resp: Response[FullRepository] = await github.rest.repos.async_get(owner="owner", repo="repo")
24+
repo: FullRepository = resp.parsed_data
25+
```
26+
27+
!!! warning
28+
29+
Repeatedly creating new client instances may lead to memory leaks. We recommend reusing the same client instance within a single context to avoid this issue.

docs/usage/rest-api.md

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ If you are calling an API that requires request body parameters, you can pass th
6666

6767
!!! tip
6868

69-
By default, githubkit will validate the request body against the API schema. If you want to skip the validation, you can set the client config `rest_api_validate_body` to `False`. See [Configuration](./configuration.md#rest_api_validate_body) for more information.
69+
By default, githubkit will validate the request body against the API schema. If you want to skip the validation, you can set the client config `rest_api_validate_body` to `False`. See [Configuration](./getting-started/configuration.md#rest_api_validate_body) for more information.
7070

7171
Or you can pass the json request body as a dictionary:
7272

@@ -179,36 +179,6 @@ In some cases, you may need to pass additional headers to the API request. You c
179179
content = resp.text
180180
```
181181

182-
## Reusing Client
183-
184-
You can make multiple requests with the same client instance in one context:
185-
186-
=== "Sync"
187-
188-
```python hl_lines="4"
189-
from githubkit import GitHub, Response
190-
from githubkit.versions.latest.models import FullRepository
191-
192-
with GitHub("<your_token_here>") as github:
193-
resp: Response[FullRepository] = github.rest.repos.get(owner="owner", repo="repo")
194-
repo: FullRepository = resp.parsed_data
195-
```
196-
197-
=== "Async"
198-
199-
```python hl_lines="4"
200-
from githubkit import GitHub, Response
201-
from githubkit.versions.latest.models import FullRepository
202-
203-
async with GitHub("<your_token_here>") as github:
204-
resp: Response[FullRepository] = await github.rest.repos.async_get(owner="owner", repo="repo")
205-
repo: FullRepository = resp.parsed_data
206-
```
207-
208-
!!! warning
209-
210-
Repeatedly creating new client instances may lead to memory leaks. We recommend reusing the same client instance within a single context to avoid this issue.
211-
212182
## Data Validation
213183

214184
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. The loaded json data is also typed but not validated. For example:

mkdocs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ nav:
131131
- OAuth APP Device Flow: quickstart/oauth-device-flow.md
132132
- GitHub APP: quickstart/github-app.md
133133
- Usage:
134-
- Authentication: usage/authentication.md
135-
- Configuration: usage/configuration.md
134+
- Getting Started:
135+
- Authentication: usage/getting-started/authentication.md
136+
- Configuration: usage/getting-started/configuration.md
137+
- Reusing Client: usage/getting-started/reusing-client.md
136138
- REST API: usage/rest-api.md
137139
- GraphQL: usage/graphql.md
138140
- Auto Retry: usage/auto-retry.md

0 commit comments

Comments
 (0)