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
Async Python client for the [Huntflow API](https://api.huntflow.ai/v2/docs). It wraps [httpx](https://www.python-httpx.org/), adds Bearer authentication, optional automatic token refresh, and typed helpers for major resources.
8
8
9
-
**Async-only:** every `request()` and entity method is `async` — call them from `async def` code (`asyncio.run`, FastAPI routes, your own event loop, etc.). There is no synchronous client.
10
-
11
9
## Installation
12
10
13
11
```bash
@@ -136,49 +134,47 @@ Seed the JSON file once with `access_token` and `refresh_token` from Huntflow be
136
134
The package does **not** depend on Redis; install it separately (`pip install "redis>=4.2"` so `redis.asyncio` and async locks behave consistently). Use one async Redis client for both storage and the lock. **Populate the token key** before the first API call (same JSON shape as the file storage).
137
135
138
136
```python
137
+
import asyncio
139
138
import json
139
+
import time
140
+
from typing import Any, Dict, Optional
140
141
141
142
from redis.asyncio import Redis
143
+
from redis.asyncio.lock import Lock
142
144
from redis.exceptions import LockError
143
145
144
146
from huntflow_api_client import HuntflowAPI
145
147
from huntflow_api_client.tokens.locker import AbstractLocker
146
-
from huntflow_api_client.tokens.proxy import HuntflowTokenProxy
147
-
from huntflow_api_client.tokens.storage import AbstractHuntflowTokenStorage
148
+
from huntflow_api_client.tokens.proxy import (
149
+
AbstractTokenProxy,
150
+
convert_refresh_result_to_hf_token,
151
+
get_auth_headers,
152
+
get_refresh_token_data,
153
+
)
148
154
from huntflow_api_client.tokens.token import ApiToken
Tune lock **`timeout`** / **`blocking_timeout`** for your network and refresh latency. Keep the **`Redis`** instance for the app lifetime and **`await redis.aclose()`** on shutdown. For fully custom behavior (e.g. KMS-wrapped secrets), subclass **`AbstractTokenProxy`** instead of `HuntflowTokenProxy`.
210
-
211
282
## Raw HTTP access
212
283
213
284
Every method on entities ultimately uses `HuntflowAPI.request`, which mirrors [`httpx.AsyncClient.request`](https://www.python-httpx.org/api/#asyncclient) (`json`, `params`, `files`, `timeout`, etc.). Entity methods usually serialize typed request models (for example `ApplicantCreateRequest.jsonable_dict(...)`); with `request()` you build the JSON yourself.
0 commit comments