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, and separately bounds concurrent server-side async jobs so a large applyEdits can't queue every batch on the server at once.

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, max_concurrent_jobs=4, job_timeout=300.0, use_server_async=None, max_batch_bytes=DEFAULT_MAX_BATCH_BYTES)

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
max_concurrent_jobs int

Maximum number of async server-side jobs (e.g. async applyEdits batches) alive at once, shared across all callers and layers using this client. A job permit is held from the POST until the result is fetched, so this bounds the server's job queue rather than HTTP requests. Set it slightly above the number of jobs the target service runs in parallel; too high reintroduces queueing (and job_timeout expirations), too low leaves the server idle between jobs. Has no effect on batches sent synchronously (see use_server_async).

4
job_timeout float

Default maximum seconds to wait for one async job to complete once it holds a job permit. Queue time behind other jobs from this client is not counted. Individual operations may override it per call. Has no effect on batches sent synchronously.

300.0
use_server_async bool | None

Default for whether applyEdits batches use server-side async processing. None (the default) auto-detects: async only when an edit spans more than one batch and the layer advertises supportsAsyncApplyEdits. True sends every batch async; False always sends synchronously, which trades async's resilience on slow commits for definite per-batch outcomes. Individual calls may override it.

None
max_batch_bytes int

Default soft upper bound, in bytes, for each applyEdits POST body. Smaller batches commit faster and put fewer edits at stake when one fails. Individual calls may override it.

DEFAULT_MAX_BATCH_BYTES

Raises:

Type Description
ConfigurationError

If max_batch_bytes is not positive or exceeds MAX_BATCH_BYTES.

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=).

{}