Skip to main content

Alarm and Events SDK

Read-only Python library for the Equinor IOC IIOT Alarm and Events API, using delegated user_impersonation authentication through eq-api-connector. Python 3.10 or later is required by the connector.

Install

pip install "git+https://github.com/equinor/ioc-ae-sdk.git"

GitHub access to this internal repository is required. This package is not published to PyPI yet; its intended distribution name is alarm-events-client.

Authentication

Setting Default
API application omnia-iiot-ae-api-production
API resource ID 6df18f43-f499-4470-9d94-52b01698620d
Delegated scope 6df18f43-f499-4470-9d94-52b01698620d/user_impersonation
Calling public-client application IOC-monitoring-sdk
Calling client ID 98fe146b-2687-4db9-9c84-45f4cd9063af
Tenant ID 3aa4a235-b6e2-48d5-9195-7fcf05b459b0
Base URL https://api.gateway.equinor.com/iiot/ae/v1

The application names, IDs and enabled delegated permission were checked against Entra service-principal metadata on 2026-10-29. IDs are configuration, not secrets. The calling app declares this exact delegated permission and includes http://localhost among its public-client redirect URIs. The calling app needs delegated permission/consent for this API, a suitable public-client redirect configuration, and the user needs authorized API access (including AE.Read where required). Metadata discovery alone does not verify consent or user access.

eq-api-connector owns MSAL login, token renewal and its credential cache. The first request may open interactive browser login; subsequent requests reuse the connector's authentication. No client secret, application-token fallback, Azure CLI token, or APIM subscription key is used by this SDK. Do not print tokens or commit credential caches. Do not enable HTTP debug logging where Authorization headers could be captured.

Usage

from alarm_events import AlarmEventsClient

with AlarmEventsClient() as client:
    facilities = client.list_facilities()
    events = client.get_all_events(
        "TROA",
        source_name="*",
        start="2026-10-28T00:00:00Z",
        end="2026-10-28T01:00:00Z",
    )
    print(len(events))

Facility and event demo

Run the demo to check STID facility codes against GET /sources and save matching event records to a JSON file:

uv run python examples/facility_events_demo.py

By default, it checks JCA, JSV, and GRA, then retrieves events from the last 24 hours for supported facilities. The example uses a wildcard source, priorities 1 and 2, unacknowledged and active state filters, descending sort, and includes other event fields. It follows continuation tokens and verifies completeness before writing ae_events.json. A supported facility can have zero events matching the selected time window and filters.

Override the facility codes, time window, or output path with command-line options:

uv run python examples/facility_events_demo.py \
  --facilities JCA JSV GRA --hours 48 --output output/ae_events.json

Edit EVENT_FILTERS in examples/facility_events_demo.py to change the event filters.

Override client_id, tenant_id, scope, or user_name at construction if needed. Only explicit /user_impersonation scopes are accepted. Optional base_url and timeout overrides support alternate HTTPS deployments. Only set base_url to a trusted API: it receives the delegated bearer token. TLS verification remains enabled, redirects are rejected, and every request has a timeout (default 60 s).

Single-page filtering

with AlarmEventsClient() as client:
    page = client.get_events(
        "TROA",
        start="2026-10-28T00:00:00Z",
        end="2026-10-28T01:00:00Z",
        source_name="*",
        priority=[1, 2],
        acked_state=False,
        sort="Desc",
        include_other_fields=True,
        limit=1000,
    )
    # page.items, page.total_count, page.continuation_token

All three event-reading methods accept description, event_type, event_category, message, severity, priority, condition, alarm_state, acked_state, active_state, suppressed_or_shelved, node, process_area, actiontime, include_other_fields, and sort, mapping to the API's parameters. Filters other than sort and include_other_fields accept a scalar or a list/tuple of values; sequences are sent as repeated query parameters, not comma-separated strings. Priority and severity accept int32 values (numeric strings remain supported); state flags require booleans. actiontime values require timezone offsets and are normalized to UTC. sort is sent as the schema's Asc or Desc enum; lowercase input is also accepted. Filters are preserved on every page.

Single-page results may be incomplete. get_events additionally accepts continuation_token for manual paging.

The read surface was checked against the supplied iiot-ae-api-v1.yaml OpenAPI 3.0.1 definition. Its limit schema allows 1 through 100,000, despite a shorter conflicting description. The SDK follows that schema and retains the conservative completeness checks below. A missing or null totalCount is treated as unknown; in that case, retrieval completeness is verified by following continuation tokens through the terminal page. Invalid counts or a count smaller than the page's item list raise InvalidResponseError.

Both time bounds are required and must be timezone-aware datetime objects or ISO-8601 strings with an offset; they are normalized to UTC. The facility is a path code, and sourceName is always supplied (* by default). Unknown keyword arguments raise TypeError, preventing misspelled time filters from silently reading the wrong period. Events retain the API's original fields and nulls; no alarm interpretation or personal-data transformation is performed.

Completeness and errors

  • list_facilities() calls GET /sources, not /facilities.
  • get_events() calls GET /events/{facility} and returns an EventPage.
  • get_all_events() follows continuation tokens, verifies totalCount when supplied, and returns a complete list or raises IncompleteResultError.
  • iter_event_pages() verifies completeness only if consumed to exhaustion.
  • Repeated tokens, changing counts, missing items, the max_pages bound, and the service's 100,000-event ceiling raise IncompleteResultError. Narrow the window or source filter rather than assuming a capped result is complete.
  • HTTP errors (including redirects) raise AlarmEventsAPIError with status_code and trace_id when available. Error bodies and credentials are not included in exception messages.
  • HTTP 401 requires checking login, scope and consent; HTTP 403 requires checking access. Neither is silently converted into an empty result.
  • Network errors/timeouts propagate from the connector. Malformed JSON or response envelopes raise InvalidResponseError. Requests are not automatically retried; retry transient failures at the caller's policy boundary.

Streaming subscriptions are intentionally excluded: the service does not allow delegated user_impersonation tokens for realtime subscriptions. The published server-side count route has been observed returning 404 and is not exposed here. Count the completely retrieved list when needed.

Development

uv sync --locked
uv run pytest --cov=alarm_events --cov-report=term-missing
uv run black --check src tests
uv run isort --check-only src tests
uv run flake8 src tests
uv run mypy
uv build

All automated tests use fake authentication and HTTP responses. They do not require sign-in or call the API. A successful offline test run is not proof of live access; validate login and a bounded facilities/event read in your own authorized environment. Keep real event data and tokens out of the repository.

Metadata

Release files for alarm-events-client 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alarm-events-client 0.1.1
File Size Uploaded Provenance Actions
alarm_events_client-0.1.1.tar.gz 9.2 kB Without provenance Details for alarm_events_client-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for alarm-events-client 0.1.1
File Interpreter ABI Platform Actions
alarm_events_client-0.1.1-py3-none-any.whl Python 3 none any Details for alarm_events_client-0.1.1-py3-none-any.whl

Total release size: 19.4 kB

Release files / alarm_events_client-0.1.1.tar.gz

Download URL alarm_events_client-0.1.1.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8b855b03350edf729ea78fa310fbc839cc22f9a2e17cc62c3fc3ab7facd4e58c
BLAKE2b-256 checksum
How to use checksums
5b1f2eae9993980f6ad32e97346584e6c8a67b443f9f658ff35872c4002dc040
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.3 CPython/3.13.7 Darwin/27.2.0

Release files / alarm_events_client-0.1.1-py3-none-any.whl

Download URL alarm_events_client-0.1.1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4c5536767607f0f843fa29e2a006349049c5b00a2d3df817a60f3fc6b989990
BLAKE2b-256 checksum
How to use checksums
79899099254399527e2a9d3ba6b9f66f94604b1318d37aa5ecf5b1ba11383a5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.3 CPython/3.13.7 Darwin/27.2.0

Security for alarm-events-client 0.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page