Skip to content

Client

archibald.client.ArchieClient

Async HTTP client for ESRI REST APIs.

Manages an internal httpx.AsyncClient with lazy initialization. Enforces f=json on all requests (preserving f=geojson when explicitly set), handles token refresh on 498/499 responses, and raises for HTTP-level errors before ESRI envelope errors are inspected. Bounds the number of concurrent in-flight requests so fan-out callers (batched applyEdits, paged query, bulk attachment operations) can't overrun the connection pool.

Can be used as an async context manager or instantiated directly; in the latter case call aclose() manually when done.

__aenter__() async

Enter the async context manager.

__aexit__(*args) async

Exit the async context manager, closing the internal client.

__init__(base_url, auth, timeout=60.0, max_concurrent_requests=20)

Construct an ArchieClient.

Parameters:

Name Type Description Default
base_url str

Base URL ending in 'rest/services'.

required
auth ArcGISAuth

Authentication handler for token injection.

required
timeout float | Timeout | None

Default request timeout in seconds, an explicit httpx.Timeout for fine-grained control, or None for no timeout. Applied to all requests unless overridden per-request via kwargs.

60.0
max_concurrent_requests int

Maximum number of requests in flight at once, shared across all callers (query paging, attachment fan-out, applyEdits batching, ...). Defaults to 20, matching httpx's own max_keepalive_connections default — comfortably under its max_connections=100 pool ceiling, so this cannot reproduce a PoolTimeout regardless of how many batches/pages/ attachments a caller fans out. Raise or lower it based on what the target ArcGIS Server instance's own service concurrency is known to tolerate.

20

aclose() async

Close the underlying httpx.AsyncClient if it was created.

get(endpoint=None, *, url=None, params=None, **kwargs) async

Send a GET request.

Parameters:

Name Type Description Default
endpoint str | None

Path appended to the client's base_url (or url).

None
url str | None

Override base URL for this request only.

None
params dict | None

Query parameters. f=json is enforced (f=geojson is preserved).

None
**kwargs

Forwarded to httpx.AsyncClient.request().

{}

post(endpoint=None, *, url=None, params=None, data=None, **kwargs) async

Send a POST request with a form-encoded body.

Parameters:

Name Type Description Default
endpoint str | None

Path appended to the client's base_url (or url).

None
url str | None

Override base URL for this request only.

None
params dict | None

Query parameters (not form data).

None
data dict | None

Form body. f=json is enforced here (f=geojson is preserved).

None
**kwargs

Forwarded to httpx.AsyncClient.request() (e.g. files=).

{}