Skip to content

Substances

albert.collections.substance

BaseCollection

BaseCollection(*, session: AlbertSession)

BaseCollection is the base class for all collection classes.

Parameters:

Name Type Description Default
session AlbertSession

The Albert API Session instance.

required
Source code in src/albert/collections/base.py
def __init__(self, *, session: AlbertSession):
    self.session = session

session

session = session

SubstanceInfo

Bases: BaseAlbertModel

SubstanceInfo is a Pydantic model representing information about a chemical substance.

Attributes:

Name Type Description
acute_dermal_tox_info list[ToxicityInfo] | None

Information about acute dermal toxicity.

acute_inhalation_tox_info list[ToxicityInfo] | None

Information about acute inhalation toxicity.

acute_oral_tox_info list[ToxicityInfo] | None

Information about acute oral toxicity.

acute_tox_info list[ToxicityInfo] | None

General acute toxicity information.

bio_accumulative_info list[BioAccumulativeInfo] | None

Information about bioaccumulation.

boiling_point_info list[BoilingPointInfo] | None

Information about boiling points.

cas_id str

The CAS ID of the substance.

classification str | None

The classification of the substance.

classification_type str

The type of classification.

degradability_info list[DegradabilityInfo] | None

Information about degradability.

dnel_info list[DNELInfo] | None

Information about the Derived No Effect Level (DNEL).

ec_list_no str

The EC list number.

exposure_controls_acgih list[ExposureControl] | None

ACGIH exposure controls.

hazards list[Hazard] | None

List of hazards associated with the substance.

iarc_carcinogen str | None

IARC carcinogen classification.

ntp_carcinogen str | None

NTP carcinogen classification.

osha_carcinogen bool | None

OSHA carcinogen classification.

health_effects str | None

Information about health effects.

name list[SubstanceName] | None

Names of the substance.

page_number int | None

Page number for reference.

aicis_notified bool | None

Indicates if AICIS has been notified.

approved_legal_entities Any | None

Approved legal entities for the substance.

aspiration_tox_info list[Any] | None

Information about aspiration toxicity.

basel_conv_list bool | None

Indicates if the substance is on the Basel Convention list.

bei_info list[Any] | None

Information related to BEI.

caa_cfr40 bool | None

Indicates compliance with CAA CFR 40.

caa_hpa bool | None

Indicates compliance with CAA HPA.

canada_inventory_status str | None

Status in the Canadian inventory.

carcinogen_info list[Any] | None

Information about carcinogenicity.

chemical_category list[str] | None

Categories of the chemical.

dermal_acute_toxicity float | None

Acute dermal toxicity value.

inhalation_acute_toxicity float | None

Acute inhalation toxicity value.

oral_acute_toxicity float | None

Acute oral toxicity value.

lethal_dose_and_concentrations list[LethalDoseConcentration] | None

Information about lethal doses and concentrations.

m_factor int | None

M factor for acute toxicity.

m_factor_chronic int | None

M factor for chronic toxicity.

molecular_weight list[MolecularWeight] | None

Molecular weight information.

rsl RSL | None

Risk-based screening level.

specific_conc_eu list[SpecificConcentration] | None

Specific concentration information for the EU.

specific_conc_source str | None

Source of specific concentration information.

sustainability_status_lbc str | None

Sustainability status under LBC.

tsca_8b bool | None

Indicates compliance with TSCA 8(b).

cdsa_list bool | None

Indicates if the substance is on the CDSA list.

cn_csdc_regulations bool | None

Compliance with CN CSDC regulations.

cn_pcod_list bool | None

Indicates if the substance is on the CN PCOD list.

cn_priority_list bool | None

Indicates if the substance is on the CN priority list.

ec_notified str | None

Notification status in the EC.

eu_annex_14_substances_list bool | None

Indicates if the substance is on the EU Annex 14 list.

eu_annex_17_restrictions_list bool | None

Indicates if the substance is on the EU Annex 17 restrictions list.

eu_annex_17_substances_list bool | None

Indicates if the substance is on the EU Annex 17 substances list.

eu_candidate_list bool | None

Indicates if the substance is on the EU candidate list.

eu_dang_chem_annex_1_part_1_list bool | None

Indicates if the substance is on the EU dangerous chemicals Annex 1 Part 1 list.

eu_dang_chem_annex_1_part_2_list bool | None

Indicates if the substance is on the EU dangerous chemicals Annex 1 Part 2 list.

eu_dang_chem_annex_1_part_3_list bool | None

Indicates if the substance is on the EU dangerous chemicals Annex 1 Part 3 list.

eu_dang_chem_annex_5_list bool | None

Indicates if the substance is on the EU dangerous chemicals Annex 5 list.

eu_directive_ec_list bool | None

Indicates if the substance is on the EU directive EC list.

eu_explosive_precursors_annex_1_list bool | None

Indicates if the substance is on the EU explosive precursors Annex 1 list.

eu_explosive_precursors_annex_2_list bool | None

Indicates if the substance is on the EU explosive precursors Annex 2 list.

eu_ozone_depletion_list bool | None

Indicates if the substance is on the EU ozone depletion list.

eu_pollutant_annex_2_list bool | None

Indicates if the substance is on the EU pollutant Annex 2 list.

eu_pop_list bool | None

Indicates if the substance is on the EU POP list.

export_control_list_phrases bool | None

Indicates if the substance is on the export control list.

green_gas_list bool | None

Indicates if the substance is on the green gas list.

iecsc_notified bool | None

Indicates if the substance is IECSc notified.

index_no str | None

Index number for the substance.

jpencs_notified bool | None

Indicates if the substance is JPENCS notified.

jpishl_notified bool | None

Indicates if the substance is JPISHL notified.

koecl_notified bool | None

Indicates if the substance is KOECL notified.

kyoto_protocol bool | None

Indicates compliance with the Kyoto Protocol.

massachusetts_rtk bool | None

Indicates if the substance is on the Massachusetts RTK list.

montreal_protocol bool | None

Indicates compliance with the Montreal Protocol.

new_jersey_rtk bool | None

Indicates if the substance is on the New Jersey RTK list.

new_york_rtk bool | None

Indicates if the substance is on the New York RTK list.

nzioc_notified bool | None

Indicates if the substance is NZIOC notified.

pcr_regulated bool | None

Indicates if the substance is PCR regulated.

pennsylvania_rtk bool | None

Indicates if the substance is on the Pennsylvania RTK list.

peroxide_function_groups int | None

Number of peroxide function groups.

piccs_notified bool | None

Indicates if the substance is PICCS notified.

rhode_island_rtk bool | None

Indicates if the substance is on the Rhode Island RTK list.

rotterdam_conv_list bool | None

Indicates if the substance is on the Rotterdam Convention list.

sdwa bool | None

Indicates compliance with the SDWA.

source str | None

Source of the substance information.

specific_concentration_limit str | None

Specific concentration limit for the substance.

stockholm_conv_list bool | None

Indicates if the substance is on the Stockholm Convention list.

stot_affected_organs str | None

Organs affected by STOT.

stot_route_of_exposure str | None

Route of exposure for STOT.

tcsi_notified bool | None

Indicates if the substance is TCSI notified.

trade_secret str | None

Information about trade secrets.

tw_ghs_clas_list bool | None

Indicates if the substance is on the TW GHS classification list.

tw_handle_priority_chem bool | None

Indicates if the substance is a priority chemical.

tw_handle_toxic_chem bool | None

Indicates if the substance is a toxic chemical.

tw_ind_waste_standards bool | None

Indicates compliance with TW industrial waste standards.

vinic_notified bool | None

Indicates if the substance is VINIC notified.

exposure_controls_osha list[ExposureControl] | None

OSHA exposure controls.

exposure_controls_aiha list[ExposureControl] | None

AIHA exposure controls.

exposure_controls_niosh list[ExposureControl] | None

NIOSH exposure controls.

snur bool | dict | None

Significant new use rule information.

tsca_12b_concentration_limit float | None

TSCA 12(b) concentration limit.

cercla_rq float | None

CERCLA reportable quantity.

california_prop_65 list[str] | None

Information related to California Prop 65.

sara_302 bool | None

Indicates compliance with SARA 302.

sara_313_concentration_limit float | None

SARA 313 concentration limit.

cfr_marine_pollutant dict | None

Information about marine pollutants under CFR.

cfr_reportable_quantity dict | None

Information about reportable quantities under CFR.

rohs_concentration float | None

ROHS concentration limit.

skin_corrosion_info list[SkinCorrosionInfo] | None

Information about skin corrosion.

serious_eye_damage_info list[SeriousEyeDamageInfo] | None

Information about serious eye damage.

respiratory_skin_sens_info list[RespiratorySkinSensInfo] | None

Information about respiratory skin sensitization.

is_known bool

Indicates if the substance is known (i.e. has known regulatory or hazard information in the database) (note this is an alias for the isCas field which behaves in a non intuitive way in the API so we have opted to use is_known for usability instead)

type

type: Literal['Substance'] = 'Substance'

acute_dermal_tox_info

acute_dermal_tox_info: list[ToxicityInfo] | None = Field(
    None, alias="acuteDermalToxInfo"
)

acute_inhalation_tox_info

acute_inhalation_tox_info: list[ToxicityInfo] | None = (
    Field(None, alias="acuteInhalationToxInfo")
)

acute_oral_tox_info

acute_oral_tox_info: list[ToxicityInfo] | None = Field(
    None, alias="acuteOralToxInfo"
)

acute_tox_info

acute_tox_info: list[ToxicityInfo] | None = Field(
    None, alias="acuteToxInfo"
)

bio_accumulative_info

bio_accumulative_info: list[BioAccumulativeInfo] | None = (
    Field(None, alias="bioAccumulativeInfo")
)

boilingpoint_info

boilingpoint_info: list[BoilingPointInfo] | None = Field(
    None, alias="boilingpointInfo"
)

cas_id

cas_id: str = Field(..., alias='casID')

classification

classification: str | None = None

classification_type

classification_type: str | None = Field(
    default=None, alias="classificationType"
)

degradability_info

degradability_info: list[DegradabilityInfo] | None = Field(
    None, alias="degradabilityInfo"
)

dnel_info

dnel_info: list[DNELInfo] | None = Field(
    None, alias="dnelInfo"
)

ec_list_no

ec_list_no: str | None = Field(
    default=None, alias="ecListNo"
)

exposure_controls_acgih

exposure_controls_acgih: list[ExposureControl] | None = (
    Field(None, alias="exposureControlsACGIH")
)

hazards

hazards: list[Hazard] | None = None

iarc_carcinogen

iarc_carcinogen: str | None = Field(
    None, alias="iarcCarcinogen"
)

ntp_carcinogen

ntp_carcinogen: str | None = Field(
    None, alias="ntpCarcinogen"
)

osha_carcinogen

osha_carcinogen: bool | None = Field(
    None, alias="oshaCarcinogen"
)

health_effects

health_effects: str | None = Field(
    None, alias="healthEffects"
)

name

name: list[SubstanceName] | None = None

page_number

page_number: int | None = Field(None, alias='pageNumber')

aicis_notified

aicis_notified: bool | None = Field(
    None, alias="aicisNotified"
)
approved_legal_entities: Any | None = Field(
    None, alias="approvedLegalEntities"
)

aspiration_tox_info

aspiration_tox_info: list[Any] | None = Field(
    None, alias="aspirationToxInfo"
)

basel_conv_list

basel_conv_list: bool | None = Field(
    None, alias="baselConvList"
)

bei_info

bei_info: list[Any] | None = Field(None, alias='beiInfo')

caa_cfr_40

caa_cfr_40: bool | None = Field(None, alias='caaCFR40')

caa_hpa

caa_hpa: bool | None = Field(None, alias='caaHPA')

canada_inventory_status

canada_inventory_status: str | None = Field(
    None, alias="canadaInventoryStatus"
)

carcinogen_info

carcinogen_info: list[Any] | None = Field(
    None, alias="carcinogenInfo"
)

chemical_category

chemical_category: list[str] | None = Field(
    None, alias="chemicalCategory"
)

dermal_acute_toxicity

dermal_acute_toxicity: float | None = Field(
    None, alias="dermalAcuteToxicity"
)

inhalation_acute_toxicity

inhalation_acute_toxicity: float | None = Field(
    None, alias="inhalationAcuteToxicity"
)

oral_acute_toxicity

oral_acute_toxicity: float | None = Field(
    None, alias="oralAcuteToxicity"
)

lethal_dose_and_concentrations

lethal_dose_and_concentrations: (
    list[LethalDoseConcentration] | None
) = Field(None, alias="lethalDoseAndConcentrations")

m_factor

m_factor: int | None = Field(None, alias='mFactor')

m_factor_chronic

m_factor_chronic: int | None = Field(
    None, alias="mFactorChronic"
)

molecular_weight

molecular_weight: list[MolecularWeight] | None = Field(
    None, alias="molecularWeight"
)

rsl

rsl: RSL | None = Field(None, alias='rsl')

specific_conc_eu

specific_conc_eu: list[SpecificConcentration] | None = (
    Field(None, alias="specificConcEU")
)

specific_conc_source

specific_conc_source: str | None = Field(
    None, alias="specificConcSource"
)

sustainability_status_lbc

sustainability_status_lbc: str | None = Field(
    None, alias="sustainabilityStatusLBC"
)

tsca_8b

tsca_8b: bool | None = Field(None, alias='tsca8B')

cdsa_list

cdsa_list: bool | None = Field(None, alias='cdsaList')

cn_csd_c_regulations

cn_csd_c_regulations: bool | None = Field(
    None, alias="cnCSDCRegulations"
)

cn_pcod_list

cn_pcod_list: bool | None = Field(None, alias='cnPCODList')

cn_priority_list

cn_priority_list: bool | None = Field(
    None, alias="cnPriorityList"
)

ec_notified

ec_notified: str | None = Field(None, alias='ecNotified')

eu_annex_14_substances_list

eu_annex_14_substances_list: bool | None = Field(
    None, alias="euAnnex14SubstancesList"
)

eu_annex_17_restrictions_list

eu_annex_17_restrictions_list: bool | None = Field(
    None, alias="euAnnex17RestrictionsList"
)

eu_annex_17_substances_list

eu_annex_17_substances_list: bool | None = Field(
    None, alias="euAnnex17SubstancesList"
)

eu_candidate_list

eu_candidate_list: bool | None = Field(
    None, alias="euCandidateList"
)

eu_dang_chem_annex_1_part_1_list

eu_dang_chem_annex_1_part_1_list: bool | None = Field(
    None, alias="euDangChemAnnex1Part1List"
)

eu_dang_chem_annex_1_part_2_list

eu_dang_chem_annex_1_part_2_list: bool | None = Field(
    None, alias="euDangChemAnnex1Part2List"
)

eu_dang_chem_annex_1_part_3_list

eu_dang_chem_annex_1_part_3_list: bool | None = Field(
    None, alias="euDangChemAnnex1Part3List"
)

eu_dang_chem_annex_5_list

eu_dang_chem_annex_5_list: bool | None = Field(
    None, alias="euDangChemAnnex5List"
)

eu_directive_ec_list

eu_directive_ec_list: bool | None = Field(
    None, alias="euDirectiveEcList"
)

eu_explosive_precursors_annex_1_list

eu_explosive_precursors_annex_1_list: bool | None = Field(
    None, alias="euExplosivePrecursorsAnnex1List"
)

eu_explosive_precursors_annex_2_list

eu_explosive_precursors_annex_2_list: bool | None = Field(
    None, alias="euExplosivePrecursorsAnnex2List"
)

eu_ozone_depletion_list

eu_ozone_depletion_list: bool | None = Field(
    None, alias="euOzoneDepletionList"
)

eu_pollutant_annex_2_list

eu_pollutant_annex_2_list: bool | None = Field(
    None, alias="euPollutantAnnex2List"
)

eu_pop_list

eu_pop_list: bool | None = Field(None, alias='euPopList')

export_control_list_phrases

export_control_list_phrases: bool | None = Field(
    None, alias="exportControlListPhrases"
)

green_gas_list

green_gas_list: bool | None = Field(
    None, alias="greenGasList"
)

iecsc_notified

iecsc_notified: bool | None = Field(
    None, alias="iecscNotified"
)

index_no

index_no: str | None = Field(None, alias='indexNo')

jpencs_notified

jpencs_notified: bool | None = Field(
    None, alias="jpencsNotified"
)

jpishl_notified

jpishl_notified: bool | None = Field(
    None, alias="jpishlNotified"
)

koecl_notified

koecl_notified: bool | None = Field(
    None, alias="koeclNotified"
)

kyoto_protocol

kyoto_protocol: bool | None = Field(
    None, alias="kyotoProtocol"
)

massachusetts_rtk

massachusetts_rtk: bool | None = Field(
    None, alias="massachusettsRTK"
)

montreal_protocol

montreal_protocol: bool | None = Field(
    None, alias="montrealProtocol"
)

new_jersey_rtk

new_jersey_rtk: bool | None = Field(
    None, alias="newJerseyRTK"
)

new_york_rtk

new_york_rtk: bool | None = Field(None, alias='newYorkRTK')

nzioc_notified

nzioc_notified: bool | None = Field(
    None, alias="nziocNotified"
)

pcr_regulated

pcr_regulated: bool | None = Field(
    None, alias="pcrRegulated"
)

pennsylvania_rtk

pennsylvania_rtk: bool | None = Field(
    None, alias="pennsylvaniaRTK"
)

peroxide_function_groups

peroxide_function_groups: int | None = Field(
    None, alias="peroxideFunctionGroups"
)

piccs_notified

piccs_notified: bool | None = Field(
    None, alias="piccsNotified"
)

rhode_island_rtk

rhode_island_rtk: bool | None = Field(
    None, alias="rhodeIslandRTK"
)

rotterdam_conv_list

rotterdam_conv_list: bool | None = Field(
    None, alias="rotterdamConvList"
)

sdwa

sdwa: bool | None = Field(None, alias='sdwa')

source

source: str | None = Field(None, alias='source')

specific_concentration_limit

specific_concentration_limit: str | None = Field(
    None, alias="specificConcentrationLimit"
)

stockholm_conv_list

stockholm_conv_list: bool | None = Field(
    None, alias="stockholmConvList"
)

stot_affected_organs

stot_affected_organs: str | None = Field(
    None, alias="stotAffectedOrgans"
)

stot_route_of_exposure

stot_route_of_exposure: str | None = Field(
    None, alias="stotRouteOfExposure"
)

tcsi_notified

tcsi_notified: bool | None = Field(
    None, alias="tcsiNotified"
)

trade_secret

trade_secret: bool | None = Field(None, alias="tradeSecret")

tw_ghs_clas_list

tw_ghs_clas_list: bool | None = Field(
    None, alias="twGHSClasList"
)

tw_handle_priority_chem

tw_handle_priority_chem: bool | None = Field(
    None, alias="twHandlePriorityChem"
)

tw_handle_toxic_chem

tw_handle_toxic_chem: bool | None = Field(
    None, alias="twHandleToxicChem"
)

tw_ind_waste_standards

tw_ind_waste_standards: bool | None = Field(
    None, alias="twIndWasteStandards"
)

vinic_notified

vinic_notified: bool | None = Field(
    None, alias="vinicNotified"
)

exposure_controls_osha

exposure_controls_osha: list[ExposureControl] | None = (
    Field(None, alias="exposureControlsOSHA")
)

exposure_controls_aiha

exposure_controls_aiha: list[ExposureControl] | None = (
    Field(None, alias="exposureControlsAIHA")
)

exposure_controls_niosh

exposure_controls_niosh: list[ExposureControl] | None = (
    Field(None, alias="exposureControlsNIOSH")
)

snur

snur: bool | dict | None = None

tsca_12b_concentration_limit

tsca_12b_concentration_limit: float | None = Field(
    None, alias="tsca12BConcentrationLimit"
)

cercla_rq

cercla_rq: float | None = Field(None, alias='cerclaRQ')

california_prop_65

california_prop_65: list[str] | None = Field(
    None, alias="californiaProp65"
)

sara_302

sara_302: bool | None = Field(None, alias='sara302')

sara_313_concentration_limit

sara_313_concentration_limit: float | None = Field(
    None, alias="sara313ConcentrationLimit"
)

cfr_marine_pollutant

cfr_marine_pollutant: dict | None = Field(
    None, alias="CFRmarinePollutant"
)

cfr_reportable_quantity

cfr_reportable_quantity: dict | None = Field(
    None, alias="CFRreportableQuantity"
)

rohs_concentration

rohs_concentration: float | None = Field(
    None, alias="rohsConcentration"
)

skin_corrosion_info

skin_corrosion_info: list[SkinCorrosionInfo] | None = Field(
    None, alias="skinCorrosionInfo"
)

serious_eye_damage_info

serious_eye_damage_info: (
    list[SeriousEyeDamageInfo] | None
) = Field(None, alias="seriousEyeDamageInfo")

respiratory_skin_sens_info

respiratory_skin_sens_info: (
    list[RespiratorySkinSensInfo] | None
) = Field(None, alias="respiratorySkinSensInfo")

is_known

is_known: bool = Field(default=True, alias='isCas')

SubstanceResponse

Bases: BaseAlbertModel

SubstanceResponse is a Pydantic model representing the response containing substance information.

Attributes:

Name Type Description
substances list[Substance]

A list of substances.

substance_errors list[Any] | None

A list of errors related to substances, if any.

substances

substances: list[SubstanceInfo]

substance_errors

substance_errors: list[dict[str, Any]] | None = Field(
    None, alias="substanceErrors"
)

AlbertSession

AlbertSession(
    *,
    base_url: str,
    token: str | None = None,
    client_credentials: ClientCredentials | None = None,
    retries: int | None = None,
)

Bases: Session

A session that has a base URL, which is prefixed to all request URLs.

Parameters:

Name Type Description Default
base_url str

The base URL to prefix to all requests. (e.g., "https://sandbox.albertinvent.com")

required
retries int

The number of retries for failed requests. Defaults to 3.

None
client_credentials ClientCredentials | None

The client credentials for programmatic authentication. Optional if token is provided.

None
token str | None

The JWT token for authentication. Optional if client credentials are provided.

None
Source code in src/albert/session.py
def __init__(
    self,
    *,
    base_url: str,
    token: str | None = None,
    client_credentials: ClientCredentials | None = None,
    retries: int | None = None,
):
    super().__init__()
    self.base_url = base_url
    self.headers.update(
        {
            "Content-Type": "application/json",
            "Accept": "application/json",
            "User-Agent": f"albert-SDK V.{albert.__version__}",
        }
    )

    if token is None and client_credentials is None:
        raise ValueError("Either client credentials or token must be specified.")

    self._provided_token = token
    self._token_manager = (
        TokenManager(base_url, client_credentials) if client_credentials is not None else None
    )

    # Set up retry logic
    retries = retries if retries is not None else 3
    retry = Retry(
        total=retries,
        read=retries,
        connect=retries,
        backoff_factor=0.3,
        status_forcelist=(500, 502, 503, 504, 403),
        raise_on_status=False,
    )
    adapter = HTTPAdapter(max_retries=retry)
    self.mount("http://", adapter)
    self.mount("https://", adapter)

base_url

base_url = base_url

request

request(
    method: str, path: str, *args, **kwargs
) -> Response
Source code in src/albert/session.py
def request(self, method: str, path: str, *args, **kwargs) -> requests.Response:
    self.headers["Authorization"] = f"Bearer {self._access_token}"
    full_url = urljoin(self.base_url, path) if not path.startswith("http") else path
    with handle_http_errors():
        response = super().request(method, full_url, *args, **kwargs)
        response.raise_for_status()
        return response

SubstanceCollection

SubstanceCollection(*, session: AlbertSession)

Bases: BaseCollection

SubstanceCollection is a collection class for managing Substance entities in the Albert platform.

Parameters:

Name Type Description Default
session AlbertSession

An instance of the Albert session used for API interactions.

required

Attributes:

Name Type Description
base_path str

The base URL for making API requests related to substances.

Methods:

Name Description
get_by_ids

Retrieves a list of substances by their CAS IDs and optional region.

get_by_id

Retrieves a single substance by its CAS ID and optional region.

Source code in src/albert/collections/substance.py
def __init__(self, *, session: AlbertSession):
    super().__init__(session=session)
    self.base_path = f"/api/{SubstanceCollection._api_version}/substances"

base_path

base_path = f'/api/{_api_version}/substances'

get_by_ids

get_by_ids(
    *,
    cas_ids: list[str],
    region: str = "US",
    catch_errors: bool | None = None,
) -> list[SubstanceInfo]

Get substances by their CAS IDs.

If catch_errors is set to False, the number of substances returned may be less than the number of CAS IDs provided if any of the CAS IDs result in an error.

Parameters:

Name Type Description Default
cas_ids list[str]

A list of CAS IDs to retrieve substances for.

required
region str

The region to filter the subastance by, by default "US"

'US'
catch_errors bool

Whether to catch errors for unknown CAS, by default True.

None

Returns:

Type Description
list[SubstanceInfo]

A list of substances with the given CAS IDs.

Source code in src/albert/collections/substance.py
def get_by_ids(
    self,
    *,
    cas_ids: list[str],
    region: str = "US",
    catch_errors: bool | None = None,
) -> list[SubstanceInfo]:
    """Get substances by their CAS IDs.

    If `catch_errors` is set to False, the number of substances returned
    may be less than the number of CAS IDs provided if any of the CAS IDs result in an error.

    Parameters
    ----------
    cas_ids : list[str]
        A list of CAS IDs to retrieve substances for.
    region : str, optional
        The region to filter the subastance by, by default "US"
    catch_errors : bool, optional
        Whether to catch errors for unknown CAS, by default True.

    Returns
    -------
    list[SubstanceInfo]
        A list of substances with the given CAS IDs.
    """
    params = {
        "casIDs": ",".join(cas_ids),
        "region": region,
        "catchErrors": json.dumps(catch_errors) if catch_errors is not None else None,
    }
    params = {k: v for k, v in params.items() if v is not None}
    response = self.session.get(self.base_path, params=params)
    return SubstanceResponse.model_validate(response.json()).substances

get_by_id

get_by_id(
    *,
    cas_id: str,
    region: str = "US",
    catch_errors: bool | None = None,
) -> SubstanceInfo

Get a substance by its CAS ID.

Parameters:

Name Type Description Default
cas_id str

The CAS ID of the substance to retrieve.

required
region str

The region to filter the substance by, by default "US".

'US'
catch_errors bool

Whether to catch errors for unknown CAS, by default False.

None

Returns:

Type Description
SubstanceInfo

The retrieved substance or raises an error if not found.

Source code in src/albert/collections/substance.py
def get_by_id(
    self,
    *,
    cas_id: str,
    region: str = "US",
    catch_errors: bool | None = None,
) -> SubstanceInfo:
    """
    Get a substance by its CAS ID.

    Parameters
    ----------
    cas_id : str
        The CAS ID of the substance to retrieve.
    region : str, optional
        The region to filter the substance by, by default "US".
    catch_errors : bool, optional
        Whether to catch errors for unknown CAS, by default False.

    Returns
    -------
    SubstanceInfo
        The retrieved substance or raises an error if not found.
    """
    return self.get_by_ids(cas_ids=[cas_id], region=region, catch_errors=catch_errors)[0]