Skip to content

Hazards

albert.collections.hazards.HazardsCollection

HazardsCollection(*, session: AlbertSession)

Bases: BaseCollection

Fetch the platform's reference lists of GHS hazard symbols and statements.

Hazards are GHS (Globally Harmonized System) classifications used to describe the dangers of a substance. This collection returns the two static reference lists Albert maintains: the hazard pictogram symbols and the hazard statements. These are the master lists you draw from when classifying materials; the specific hazards recorded on a substance appear on its CAS record (see Hazard).

This collection is read-only and accessed as client.hazards.

Example

from albert import Albert

client = Albert()
symbols = client.hazards.get_symbols()
[s.name for s in symbols]

Parameters:

Name Type Description Default
session AlbertSession

The authenticated Albert session used for API calls.

required

Attributes:

Name Type Description
base_path str

The base API route for the static reference endpoints.

Methods:

Name Description
get_symbols

Get all available hazard pictogram symbols.

get_statements

Get all available hazard statements.

Parameters:

Name Type Description Default
session AlbertSession

The authenticated Albert session used for API calls.

required
Source code in src/albert/collections/hazards.py
def __init__(self, *, session: AlbertSession):
    """Initialize a HazardsCollection.

    Parameters
    ----------
    session : AlbertSession
        The authenticated Albert session used for API calls.
    """
    super().__init__(session=session)
    self.base_path = f"/api/{self._api_version}/static"

base_path

base_path = f'/api/{self._api_version}/static'

get_symbols

get_symbols() -> list[HazardSymbol]

Get all available hazard pictogram symbols.

Example

symbols = client.hazards.get_symbols()
symbols[0].name

Returns:

Type Description
list[HazardSymbol]

The full reference list of hazard symbols.

Source code in src/albert/collections/hazards.py
@validate_call
def get_symbols(self) -> list[HazardSymbol]:
    """Get all available hazard pictogram symbols.

    !!! example
        ```python
        symbols = client.hazards.get_symbols()
        symbols[0].name
        ```

    Returns
    -------
    list[HazardSymbol]
        The full reference list of hazard symbols.
    """

    response = self.session.get(f"{self.base_path}/hazardsymbols")
    response = response.json()
    symbols = response.get("HazardSymbols", []) if isinstance(response, dict) else []
    return [HazardSymbol(**symbol) for symbol in symbols]

get_statements

get_statements() -> list[HazardStatement]

Get all available hazard statements.

Example

statements = client.hazards.get_statements()
statements[0].name

Returns:

Type Description
list[HazardStatement]

The full reference list of hazard statements.

Source code in src/albert/collections/hazards.py
@validate_call
def get_statements(self) -> list[HazardStatement]:
    """Get all available hazard statements.

    !!! example
        ```python
        statements = client.hazards.get_statements()
        statements[0].name
        ```

    Returns
    -------
    list[HazardStatement]
        The full reference list of hazard statements.
    """

    response = self.session.get(f"{self.base_path}/hazardstatements")
    response = response.json()
    return [HazardStatement(**item) for item in response]