Skip to content

API reference

Client

Glance

Top-level client for the ATLAS Glance/Fence API.

__init__

__init__(*, settings: StareSettings | None = None, token_manager: TokenManager | None = None, token: str | None = None) -> None

Build the httpx client, attach the cache transport, and wire up resource accessors.

__enter__

__enter__() -> Glance

Enter the context manager, opening the underlying HTTP connection.

__exit__

__exit__(exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None) -> None

Exit the context manager, closing the underlying HTTP connection.

Resource accessors

AnalysisResource

Accessor for /analyses/ and /searchAnalysis endpoints.

__init__

__init__(client: Client) -> None

Store the shared httpx client.

get

get(ref_code: str, *, verbose: bool = False) -> Analysis

Fetch a single analysis by reference code via /searchAnalysis.

search

search(*, query: str | Expression | None = None, offset: int = 0, limit: int = 50, sort_by: str | None = None, sort_desc: bool = False, validate_query: bool = True, verbose: bool = False) -> AnalysisSearchResult

Search analyses via GET /searchAnalysis.

PaperResource

Accessor for /papers/ and /searchPaper endpoints.

__init__

__init__(client: Client) -> None

Store the shared httpx client.

get

get(ref_code: str, *, verbose: bool = False) -> Paper

Fetch a single paper by reference code via /searchPaper.

search

search(*, query: str | Expression | None = None, offset: int = 0, limit: int = 50, sort_by: str | None = None, sort_desc: bool = False, validate_query: bool = True, verbose: bool = False) -> PaperSearchResult

Search papers via GET /searchPaper.

ConfNoteResource

Accessor for /confnotes/ endpoint.

__init__

__init__(client: Client) -> None

Store the shared httpx client.

get

get(ref_code: str, *, verbose: bool = False) -> ConfNote

Fetch a single CONF note by temporary reference code via /searchConfnote.

search

search(*, query: str | Expression | None = None, offset: int = 0, limit: int = 50, sort_by: str | None = None, sort_desc: bool = False, validate_query: bool = True, verbose: bool = False) -> ConfNoteSearchResult

Search conf notes via GET /searchConfnote.

PubNoteResource

Accessor for /searchPubnote endpoint.

__init__

__init__(client: Client) -> None

Store the shared httpx client.

get

get(ref_code: str, *, verbose: bool = False) -> PubNote

Fetch a single PUB note by temporary reference code via /searchPubnote.

search

search(*, query: str | Expression | None = None, offset: int = 0, limit: int = 50, sort_by: str | None = None, sort_desc: bool = False, validate_query: bool = True, verbose: bool = False) -> PubNoteSearchResult

Search pub notes via GET /searchPubnote.

PublicationResource

Accessor for the /searchPublication endpoint.

__init__

__init__(client: Client) -> None

Store the shared httpx client.

get

get(ref_code: str, *, verbose: bool = False) -> PublicationSummary

Fetch a single publication by reference code via /searchPublication.

search

search(*, query: str | Expression | None = None, offset: int = 0, limit: int = 50, sort_by: str | None = None, sort_desc: bool = False, validate_query: bool = True, verbose: bool = False) -> PublicationSearchResult

Search across all publication types via GET /searchPublication.

LeadgroupResource

Accessor for /searchLeadgroup endpoint.

__init__

__init__(client: Client) -> None

Store the shared httpx client.

search

search(*, query: str | Expression | None = None, offset: int = 0, limit: int = 50, sort_by: str | None = None, sort_desc: bool = False, validate_query: bool = True, verbose: bool = False) -> LeadgroupSearchResult

Search leading groups via GET /searchLeadgroup.

SubgroupResource

Accessor for /searchSubgroup endpoint.

__init__

__init__(client: Client) -> None

Store the shared httpx client.

search

search(*, query: str | Expression | None = None, offset: int = 0, limit: int = 50, sort_by: str | None = None, sort_desc: bool = False, validate_query: bool = True, verbose: bool = False) -> SubgroupSearchResult

Search subgroups via GET /searchSubgroup.

TriggerResource

Accessor for /searchTrigger endpoint.

__init__

__init__(client: Client) -> None

Store the shared httpx client.

search

search(*, query: str | Expression | None = None, offset: int = 0, limit: int = 50, sort_by: str | None = None, sort_desc: bool = False, validate_query: bool = True, verbose: bool = False) -> TriggerSearchResult

Search triggers via GET /searchTrigger.

Authentication

TokenManager

Manages OAuth2 tokens: PKCE login flow, storage, and refresh.

token_path property

token_path: Path

Path to the stored token JSON file.

__init__

__init__(settings: StareSettings | None = None, token_path: Path | None = None, storage: TokenStorage | None = None) -> None

Initialise the token manager with optional settings, path, and storage overrides.

login

login(*, on_url_ready: Callable[[str], None] | None = None, get_manual_code: Callable[[], str | None] | None = None) -> None

Start PKCE browser flow; blocks until redirect received or manual code entered.

Parameters:

Name Type Description Default
on_url_ready Callable[[str], None] | None

Called with the authorization URL before the browser is opened — use this to display the URL to the user.

None
get_manual_code Callable[[], str | None] | None

Called in a background thread to obtain a fallback authorization code (e.g. via user input) when the browser redirect cannot reach the local callback server.

None

logout

logout() -> None

Revoke tokens server-side (best-effort) then delete local storage.

get_token

get_token() -> str

Return a valid access token, refreshing and exchanging as needed.

If settings.exchange_audience is set, the PKCE access token is exchanged for an audience-scoped token via RFC 8693. The exchanged token is cached in memory to avoid a round-trip on every API call.

get_pkce_access_token

get_pkce_access_token() -> str

Return the PKCE base access token (refreshing if needed).

Never performs a token exchange regardless of exchange_audience. Raises :exc:~stare.exceptions.AuthenticationError if not logged in.

get_pkce_id_token

get_pkce_id_token() -> str | None

Return the stored PKCE id token, or None if absent or not logged in.

get_exchange_access_token

get_exchange_access_token() -> str | None

Return the raw RFC 8693 exchanged access token.

Returns None if exchange_audience is not configured. Performs the exchange if the cached token is absent or nearly expired. Raises :exc:~stare.exceptions.AuthenticationError if not logged in.

is_authenticated

is_authenticated() -> bool

Return True if a non-expired token is stored.

get_token_info

get_token_info() -> TokenInfo | None

Return token metadata and decoded JWT claims, or None if not stored.

The JWT payload is decoded without signature verification — suitable only for display purposes, not security decisions.

get_exchange_token_info

get_exchange_token_info() -> TokenInfo | None

Decode and return info for the RFC 8693 exchanged token.

Returns None if exchange_audience is not configured. Performs the exchange if the cached token is absent or nearly expired. Raises :exc:~stare.exceptions.AuthenticationError if not logged in.

TokenStorage

Bases: ABC

Abstract base class for token storage backends.

lock_path abstractmethod property

lock_path: Path

Path to the lock file for this storage backend.

load abstractmethod

load() -> _StoredToken | None

Return stored tokens, or None if absent.

save abstractmethod

save(token: _StoredToken) -> None

Persist tokens to storage.

delete abstractmethod

delete() -> None

Delete stored tokens; no-op if absent.

exists abstractmethod

exists() -> bool

Return True if tokens are currently stored.

FileTokenStorage

Bases: TokenStorage

Stores tokens as a JSON file on disk.

lock_path property

lock_path: Path

Return the path to the advisory lock file for this storage backend.

__init__

__init__(token_path: Path) -> None

Store the path where the token JSON file will be read and written.

load

load() -> _StoredToken | None

Return stored tokens, or None if the file does not exist.

save

save(token: _StoredToken) -> None

Write tokens to the JSON file, creating parent directories as needed.

delete

delete() -> None

Delete the token file; no-op if it does not exist.

exists

exists() -> bool

Return True if the token file exists.

KeyringTokenStorage

Bases: TokenStorage

Stores tokens as a JSON blob in the OS-native credential store.

Uses macOS Keychain, Linux Secret Service, or Windows Credential Locker depending on the platform. The entire :class:_StoredToken is persisted as a single JSON string to avoid partial-write races.

lock_path property

lock_path: Path

Return the path to the advisory lock file for this storage backend.

load

load() -> _StoredToken | None

Return stored tokens from the keyring, or None if absent.

save

save(token: _StoredToken) -> None

Persist tokens as a JSON blob in the OS-native credential store.

delete

delete() -> None

Delete the keyring entry; no-op if it does not exist.

exists

exists() -> bool

Return True if a token entry exists in the keyring.

migrate_from_file

migrate_from_file(file_path: Path) -> None

One-time migration from plaintext file to keyring. Idempotent.

Settings

StareSettings

Bases: BaseSettings

Runtime configuration, overridable via STARE_* environment variables.

get_cache_dir

get_cache_dir() -> Path

Return the effective cache directory, defaulting to the platform user-cache dir.

Exceptions

StareError

Bases: Exception

Base exception for all stare errors.

AuthenticationError

Bases: StareError

Authentication failed or no credentials available.

TokenExpiredError

Bases: AuthenticationError

Stored token is expired; re-run stare login.

ApiError

Bases: StareError

An error response from the Glance API.

__init__

__init__(status_code: int, title: str, detail: str) -> None

Store HTTP status code, title, and detail then delegate to Exception.

NotFoundError

Bases: ApiError

The requested resource was not found (404).

ForbiddenError

Bases: ApiError

The request is forbidden (403).

UnauthorizedError

Bases: ApiError

Authentication token is missing or invalid (401).

ResponseParseError

Bases: StareError

Raised when an API response cannot be parsed into the expected model.

Attributes:

Name Type Description
raw_data

The raw object that failed validation (typically the parsed JSON dict/list), attached so callers can display it alongside the error message.

__init__

__init__(message: str, raw_data: Any = None, details: list[EnrichedErrorResponse] | None = None) -> None

Store the raw API payload alongside the error message.

DSL

The query DSL is available for programmatic use. See Query DSL for the syntax reference.

parse_dsl

parse_dsl(source: str, *, mode: Mode) -> Expression

Parse a DSL query string and return a validated AST.

Raises DSLSyntaxError on grammar violations and DSLValidationError on unknown fields. Normalizes field names to camelCase.

Condition

Bases: BaseModel

A single field OP value predicate.

to_dsl

to_dsl() -> str

Serialize to DSL string.

Raises ValueError for values that cannot be represented in the grammar's STRING token (/"[^"\n\r\t\f\v]*"/): - embedded double-quotes are unsupported (escaped-quote support not yet implemented) - non-space whitespace (tabs, newlines, etc.) is excluded by the grammar

Wraps the value in double quotes when it is empty or contains spaces, parentheses, or square brackets; emits bare otherwise. Fields are always emitted bare after normalization.

And

Bases: BaseModel

Logical conjunction of exactly two sub-expressions.

to_dsl

to_dsl() -> str

Serialize to DSL string.

Or

Bases: BaseModel

Logical disjunction of exactly two sub-expressions.

to_dsl

to_dsl() -> str

Serialize to DSL string.

Operator

Bases: str, Enum

Valid comparison operators for DSL conditions.

__str__

__str__() -> str

Return the operator value, not the enum repr.

FieldRegistry

Catalogue of valid DSL field names for a given query mode.

__init__

__init__(fields: frozenset[str], boolean_fields: frozenset[str] = frozenset()) -> None

Initialise with camelCase field names and an optional boolean subset.

for_mode classmethod

for_mode(mode: Mode) -> FieldRegistry

Load the field catalogue for mode from the bundled TOML data file.

normalize

normalize(field: str) -> str

Convert each dot-separated segment from snake_case to camelCase.

fields

fields() -> list[str]

Return sorted list of valid camelCase field names.

validate

validate(field: str) -> None

Raise DSLValidationError if the (normalized) field is not in the catalogue.

validate_normalized

validate_normalized(normalized: str) -> None

Raise DSLValidationError if an already-normalized field is not in the catalogue.

validate_operator

validate_operator(normalized: str, operator: Operator) -> None

Raise DSLValidationError if operator is not valid for normalized field.

Boolean fields only accept = and !=; all other fields accept any operator.

DSLError

Bases: Exception

Base class for all DSL errors.

DSLSyntaxError

Bases: DSLError

Raised when the input cannot be parsed by the grammar.

DSLValidationError

Bases: DSLError

Raised when a field name or operator fails semantic validation.

Enums

All enums are also available in a lenient form via the Lenient* type aliases (e.g. LenientAnalysisStatus). Lenient aliases accept unknown strings gracefully — logging a warning and storing the raw value rather than raising a validation error.

AnalysisStatus

Bases: StrEnum

Auto-generated enum.

PaperStatus

Bases: StrEnum

Auto-generated enum.

ConfnoteStatus

Bases: StrEnum

Auto-generated enum.

AnalysisPhase0State

Bases: StrEnum

Auto-generated enum.

PaperPhase1State

Bases: StrEnum

Auto-generated enum.

PaperPhase2State

Bases: StrEnum

Auto-generated enum.

PaperPublicationphaseState

Bases: StrEnum

Auto-generated enum.

ConfnotePhase1State

Bases: StrEnum

Auto-generated enum.

CollisionType

Bases: StrEnum

Observed collision type identifiers.

RepositoryType

Bases: StrEnum

Observed repository type values.

PublicationType

Bases: StrEnum

Observed publication type values (cross-references between record types).

MeetingType

Bases: StrEnum

Phase0 meeting role tags (used internally after flattening the 4 meeting lists).

URLs

URL builders for the ATLAS Glance web UI. Used internally to generate clickable hyperlinks in CLI output; also available for library callers.

analysis_url

analysis_url(ref_code: str, *, web_base: str) -> str

Return the Glance web UI URL for an analysis.

paper_url

paper_url(ref_code: str, *, web_base: str) -> str

Return the Glance web UI URL for a paper.

confnote_url

confnote_url(ref_code: str, *, web_base: str) -> str

Return the Glance web UI URL for a CONF note.

pubnote_url

pubnote_url(ref_code: str, *, web_base: str) -> str

Return the Glance web UI URL for a PUB note.

Models

Shared

Bases: _Base

A labelled URL, optionally rendered as a Rich clickable hyperlink.

__rich__

__rich__() -> Text

Render as a Rich clickable hyperlink when a URL is present.

Meeting

Bases: _Base

A recorded meeting (EOI, editorial board request, pre-approval, approval, etc.).

The API sends a flat linkLabel / link pair; we fold them into a single nested Link object on ingestion.

Analysis

Analysis

Bases: _Base

A single ATLAS analysis record.

__rich__

__rich__() -> Panel

Return a Rich Panel summarising the analysis for terminal display.

AnalysisSearchResult

Bases: _SearchResultsBase[Analysis]

Top-level response from GET /searchAnalysis.

Papers and notes

Paper

Bases: _Base

A published ATLAS paper.

__rich__

__rich__() -> Panel

Return a Rich Panel summarising the paper for terminal display.

PaperSearchResult

Bases: _SearchResultsBase[Paper]

Top-level response from GET /searchPaper.

ConfNote

Bases: _Base

An ATLAS CONF note.

__rich__

__rich__() -> Panel

Return a Rich Panel summarising the CONF note for terminal display.

ConfNoteSearchResult

Bases: _SearchResultsBase[ConfNote]

Top-level response from GET /searchConfnote.

PubNote

Bases: _Base

An ATLAS PUB note.

__rich__

__rich__() -> Panel

Return a Rich Panel summarising the PUB note for terminal display.

PubNoteSearchResult

Bases: _SearchResultsBase[PubNote]

Top-level response from GET /searchPubnote.

Publications

PublicationSummary

Bases: _Base

A summary record returned by GET /searchPublication.

PublicationSearchResult

Bases: _SearchResultsBase[PublicationSummary]

Top-level response from GET /searchPublication.

Leading groups, subgroups, and triggers

Leadgroup

Bases: _Base

A leading physics group returned by GET /searchLeadgroup.

LeadgroupSearchResult

Bases: _SearchResultsBase[Leadgroup]

Top-level response from GET /searchLeadgroup.

Subgroup

Bases: _Base

A physics subgroup returned by GET /searchSubgroup.

SubgroupSearchResult

Bases: _SearchResultsBase[Subgroup]

Top-level response from GET /searchSubgroup.

Trigger

Bases: _Base

A trigger entry returned by GET /searchTrigger.

TriggerSearchResult

Bases: _SearchResultsBase[Trigger]

Top-level response from GET /searchTrigger.