grit-requester
grit-requester-python is a python library to abstract requests to microservices built using Grit.
Features:
- 🔁 Automatic retry on
401 Unauthorized - 🔐 Per-service token cache with concurrency safety
- 💉 Config and HTTP client injection (perfect for testing)
- 📦 Full support for generics (
any) in request/response - 🧠 Context-aware: all requests support context.Context for cancellation, timeouts, and APM tracing
✨ Installation
pip install grit_requester
🚀 Usage Example
Configure and do a request
from grit_requester import GritService, GritConfig
# configure grit requester
config = GritConfig(
base_url=os.getenv("SERVICE_BASE_URL"),
auth_url=os.getenv("SERVICE_AUTH_URL"),
token=os.getenv("SERVICE_TOKEN"),
secret=os.getenv("SERVICE_SECRET"),
context=os.getenv("SERVICE_CONTEXT"),
)
ms = GritService(config)
# doing a request
resp = ms.request(
"GET",
"/user/list",
)
Make crud requests from a domain
Here you can call a domain passing the type and path to access the following base routers:
| Path | Description |
|---|---|
| add | Create a new record |
| bulk | Fetch specific records by IDs |
| bulk_add | Create up to 25 records in the same request |
| dead_detail | Get a deleted record by ID |
| dead_list | List deleted records (paginated) |
| delete | Soft-delete a record by ID |
| detail | Get an active record by ID |
| edit | Update specific fields |
| list | List active records (paginated) |
| list_one | List one record based on params |
| select_raw | Execute a predefined raw SQL query safely |
from grit_requester import GritService, GritConfig
# configure grit requester
config = GritConfig(
base_url=os.getenv("SERVICE_BASE_URL"),
auth_url=os.getenv("SERVICE_AUTH_URL"),
token=os.getenv("SERVICE_TOKEN"),
secret=os.getenv("SERVICE_SECRET"),
context=os.getenv("SERVICE_CONTEXT"),
)
ms = GritService(config)
# make a request from domain
users = ms.domain("user").list_all(
filters=[{ "field": "name", "type": "eql", "value": "Admin" }]
)
# you can save the domain context to reuse
user_ms = ms.domain("user")
user = user_ms.detail(users[0]["id"])
Field selection and ordering
list, dead_list, list_all, and list_one accept fields and order to control which columns are returned and how results are sorted.
users = ms.domain("user").list(
fields=["id", "name", "created_at"],
order={"field": "name", "type": "asc"},
)
# → GET /user/list?order_by=name&order=asc&fields=id,name,created_at
🔧 License
MIT © Not Empty
Not Empty Foundation - Free codes, full minds
Metadata
Release files for grit-requester 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| grit_requester-1.0.3.tar.gz | 5.7 kB | Without provenance | Details for grit_requester-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grit_requester-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for grit_requester-1.0.3-py3-none-any.whl |
Total release size: 12.6 kB
Release files / grit_requester-1.0.3.tar.gz
| Download URL | grit_requester-1.0.3.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9dcb6daaab0d0a0784bb6c101aa11a66f562e5c54b32bb42b4be4c03806b9319
|
|
BLAKE2b-256 checksum How to use checksums |
1faedc1ba4d683d4cdc8b5ea53167bf373468835557d173cf2ea4736e91e4a60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / grit_requester-1.0.3-py3-none-any.whl
| Download URL | grit_requester-1.0.3-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e0ea06a7267ad4249c1d63a560cf73b98eea53fc44cfe8cf4461874d56efa1e
|
|
BLAKE2b-256 checksum How to use checksums |
31f248d943cff3c6c719fe408eb91cc40c0c81c203272eb110a20cd524ed1f24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for grit-requester 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.