Skip to content

Commit 74d7be5

Browse files
authored
Merge pull request #66 from fa0311/docs/endpoint
docs: how to point the client at another endpoint
2 parents c8a17ef + 3f8ecfe commit 74d7be5

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ Learn more about the automatically generated Python package here.
3131

3232
[README-generated.md](README-generated.md)
3333

34+
## Related projects
35+
36+
- [twitter-openapi](https://github.com/fa0311/twitter-openapi) the OpenAPI specification both packages are generated from
37+
- [twitter_api_safe_relay](https://github.com/fa0311/twitter_api_safe_relay) an HTTP relay that runs requests through a logged-in browser; point the client's host at it
38+
- [twitter-openapi-typescript](https://github.com/fa0311/twitter-openapi-typescript) the same client for TypeScript
39+
3440
## License
3541

3642
This project is dual licensed. You can choose one of the following licenses:

‎twitter_openapi_python/README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ client.additional_api_headers = {
8181
};
8282
```
8383

84+
### Endpoint
85+
86+
The generated client accepts any host that keeps X's path shape (`/graphql/{queryId}/{operationName}`, `/1.1/...`, `/2/...` under `https://x.com/i/api`). Build the `ApiClient` yourself and hand it to `get_twitter_openapi_python_client`; the login helpers are not involved, so cookies and headers are then up to you (or to whatever answers at that host). For example, [twitter_api_safe_relay](https://github.com/fa0311/twitter_api_safe_relay) answers at `http://localhost:3000/i/api` with a logged-in browser session.
87+
88+
```python
89+
import twitter_openapi_python_generated as twitter
90+
from twitter_openapi_python import TwitterOpenapiPython
91+
92+
api_client = twitter.ApiClient(twitter.Configuration(host="http://localhost:3000/i/api"))
93+
client = TwitterOpenapiPython().get_twitter_openapi_python_client(api_client)
94+
response = client.get_user_api().get_user_by_screen_name(screen_name="elonmusk")
95+
```
96+
8497
## Development
8598

8699
```shell

0 commit comments

Comments
 (0)