Python client library for the ACE (Analysis Correlation Engine) API v2
Project description
aceapi-v2-client
A Python client library for the ACE (Analysis Correlation Engine) API v2.
The client is generated from the API's OpenAPI schema with
openapi-python-client,
so every endpoint and model is fully typed. A small hand-written auth module
adds convenience helpers for ACE's API-key authentication.
Installation
pip install aceapi-v2-client
Or install from a checkout of this directory:
pip install .
Requires Python 3.9+.
Quickstart (API key)
ACE's primary machine-to-machine authentication is an API key sent in the
x-ace-auth header. Use the authenticated_client helper to build a client
with that header pre-populated:
from aceapi_v2_client.auth import authenticated_client
from aceapi_v2_client.api.common import ping_common_ping_get
from aceapi_v2_client.api.observables import (
list_observable_types_observable_types_get,
)
client = authenticated_client(
base_url="https://localhost:8443/api/v2",
api_key="YOUR-API-KEY",
verify_ssl=False, # development instances use a self-signed certificate
)
# a simple authenticated health check
pong = ping_common_ping_get.sync(client=client)
print(pong.result) # "pong"
# call a data endpoint — responses are parsed into typed models
types = list_observable_types_observable_types_get.sync(client=client)
print(types)
Every endpoint module under aceapi_v2_client.api.* exposes four functions:
| function | returns |
|---|---|
sync(...) |
the parsed body (or None) |
sync_detailed(...) |
a Response with status + parsed body |
asyncio(...) |
the parsed body, async |
asyncio_detailed(...) |
a Response, async |
All take client= as a keyword argument plus any path/query/body parameters
the operation defines.
Async usage
import asyncio
from aceapi_v2_client.auth import authenticated_client
from aceapi_v2_client.api.common import ping_common_ping_get
client = authenticated_client("https://localhost:8443/api/v2", "YOUR-API-KEY",
verify_ssl=False)
async def main():
async with client as c:
print(await ping_common_ping_get.asyncio(client=c))
asyncio.run(main())
Authentication with a JWT token
ACE also supports user login via OAuth2 password flow. Obtain a token from the
/auth/token endpoint, then use the token_client helper:
from aceapi_v2_client.auth import token_client
client = token_client(
base_url="https://localhost:8443/api/v2",
access_token="eyJhbGci...", # from POST /auth/token
verify_ssl=False,
)
token_client sends the token as Authorization: Bearer <token>.
Base URL and TLS notes
- The base URL must include the
/api/v2prefix. The generated client appends operation paths (e.g./common/ping) directly tobase_url.- From inside the docker compose network:
https://ace-http/api/v2 - From the docker host:
https://localhost:8443/api/v2
- From inside the docker compose network:
- Development instances serve a self-signed certificate. Pass
verify_ssl=False(as above) or pointverify_sslat a CA bundle path for production.
Keeping the client up to date
The generated code is committed to this repository. When the ACE API v2 changes, regenerate it from the live schema:
# against the default instance (https://ace-http/api/v2/openapi.json)
scripts/regenerate.sh
# or against a specific instance
scripts/regenerate.sh https://localhost:8443/api/v2/openapi.json
The script:
- fetches the latest
openapi.jsoninto this directory (the build-time source of truth), - installs
openapi-python-clientinto a throwaway virtualenv (so it never touches your main environment), - regenerates the package, preserving the hand-maintained files
(
aceapi_v2_client/auth.pyandaceapi_v2_client/py.typed).
After running it:
- Review the diff:
git diff aceapi_v2_client/ - Bump the version if the API changed — update
versioninpyproject.tomlandpackage_version_overrideinopenapi-python-client-config.yaml. The client version mirrors the API's major version (2.x.y); bump the patch/minor for client-only changes. - Rebuild and verify (below).
Only
auth.pyandpy.typedare hand-maintained. Do not add other custom code insideaceapi_v2_client/— it would be overwritten on regeneration.
Building and publishing to PyPI
pip install -r requirements-dev.txt
python -m build # produces dist/*.whl and dist/*.tar.gz
twine check dist/* # validate metadata for PyPI
twine upload dist/* # publish (requires PyPI credentials)
Running the smoke test
The smoke test only runs when pointed at a live instance:
ACE_API_BASE_URL=https://ace-http/api/v2 \
ACE_API_KEY=YOUR-API-KEY \
ACE_API_VERIFY_SSL=false \
pytest tests/test_smoke.py -v
License
Apache-2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aceapi_v2_client-2.0.0.tar.gz.
File metadata
- Download URL: aceapi_v2_client-2.0.0.tar.gz
- Upload date:
- Size: 31.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84ff383f14a6c6804896be17e69540c7ffb800a59bb5c1cecebc5526d50cbc62
|
|
| MD5 |
551009a09661463172ef96c4a188afc1
|
|
| BLAKE2b-256 |
0d52052721c09a467a59e3e9a23f7a6edb195aca72243c6b4fe50dfb731954a6
|
File details
Details for the file aceapi_v2_client-2.0.0-py3-none-any.whl.
File metadata
- Download URL: aceapi_v2_client-2.0.0-py3-none-any.whl
- Upload date:
- Size: 83.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2497bcf530dc57ba2e3db06503daf0c9077787d595da62f787c8c491d078a394
|
|
| MD5 |
2068e4f1a76d0365b960f496019c8def
|
|
| BLAKE2b-256 |
6e5e9fcc3d461a846004de9a64718b2c76ef68c0d228a7b2663f2977cee509c8
|