https://github.com/johnagan/glean-requests
A minimal wrapper of the requests library for Glean's API
https://github.com/johnagan/glean-requests
Last synced: 4 months ago
JSON representation
A minimal wrapper of the requests library for Glean's API
- Host: GitHub
- URL: https://github.com/johnagan/glean-requests
- Owner: johnagan
- License: mit
- Created: 2025-03-06T03:47:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-06T14:49:54.000Z (over 1 year ago)
- Last Synced: 2025-06-12T19:46:21.909Z (about 1 year ago)
- Language: Python
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# glean-requests
A minimal wrapper of the requests library for Glean's API.
## Installation
```bash
pip install glean-requests
```
## Usage
### REST API Client
For more information on the REST API, see the [Glean documentation](https://developers.glean.com/client/overview/#section/Introduction).
```python
from glean_requests import GleanRestClient
# Initialize the client
client = GleanRestClient(
api_token="your_api_token",
subdomain="your_subdomain",
)
# Example Search
# https://developers.glean.com/client/operation/search/
payload = { "query": "your_query" }
response = client.post("search", json=payload)
```
### Indexing API Client
For more information on the Indexing API, see the [Glean documentation](https://developers.glean.com/docs/indexing_api/indexing_api_getting_started/).
```python
from glean_requests import GleanIndexingClient
# Initialize the client
client = GleanIndexingClient(
api_token="your_api_token",
subdomain="your_subdomain",
)
# Example Get Datasource Configuration
# https://developers.glean.com/indexing/tag/Datasources/paths/~1getdatasourceconfig/post/
payload = {"datasource": "testing"}
response = client.post("getdatasourceconfig", json=payload)
```
### Authentication
For more information on Authentication, see the [Glean documentation](https://developers.glean.com/docs/client_api/client_api_scopes/).
```python
client = GleanRestClient(
api_token="your_api_token",
subdomain="your_subdomain",
act_as="optional_user_to_act_as", # For Global Tokens
auth_type="OAUTH" # Optional
)
```
## Features
- Simple interface for making authenticated requests to Glean's API endpoints
- Support for both REST and Indexing APIs
- Automatic handling of authentication headers and urls
- Support for [global tokens](https://developers.glean.com/docs/client_api/client_api_scopes/#global)
## License
MIT