Substances V4 (🧪Beta)
albert.collections.substance_v4.SubstanceV4Collection
Bases: BaseCollection
SubstanceV4Collection manages substance entities in the Albert platform (🧪Beta).
Beta Feature!
Please do not use in production or without explicit guidance from Albert. You might otherwise have a bad experience. This feature currently falls outside of the Albert support contract, but we'd love your feedback!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base URL for substance API requests. |
Methods:
| Name | Description |
|---|---|
get_by_ids |
Retrieves substances by CAS IDs, substance IDs, or external IDs. |
get_by_id |
Retrieves a single substance by CAS ID, substance ID, or external ID. |
search |
Searches substances by keyword or advanced filters. |
create |
Creates a new substance record. |
update_metadata |
Updates metadata fields on a substance. |
Source code in src/albert/collections/substance_v4.py
get_by_ids
get_by_ids(
*,
cas_ids: list[str] | None = None,
sub_ids: list[str] | None = None,
external_ids: list[str] | None = None,
region: str = "global",
catch_errors: bool | None = None,
language: str | None = None,
classification_type: str | None = None,
) -> list[SubstanceV4Info]
Retrieve substances by their identifiers.
At least one of cas_ids, sub_ids, or external_ids must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cas_ids
|
list[str] | None
|
CAS numbers to look up. |
None
|
sub_ids
|
list[str] | None
|
Substance IDs to look up. |
None
|
external_ids
|
list[str] | None
|
External IDs to look up. |
None
|
region
|
str
|
Region for hazard data. Common values: |
'global'
|
catch_errors
|
bool | None
|
Whether to suppress errors for unknown substances, by default None. |
None
|
language
|
str | None
|
BCP-47 language code for name translation (e.g. |
None
|
classification_type
|
str | None
|
Filter by classification type. Accepted values: |
None
|
Returns:
| Type | Description |
|---|---|
list[SubstanceV4Info]
|
The matching substances. |
Source code in src/albert/collections/substance_v4.py
get_by_id
get_by_id(
*,
cas_id: str | None = None,
sub_id: str | None = None,
external_id: str | None = None,
region: str = "global",
catch_errors: bool | None = None,
language: str | None = None,
classification_type: str | None = None,
) -> SubstanceV4Info
Retrieve a single substance by its identifier.
Provide exactly one of cas_id, sub_id, or external_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cas_id
|
str | None
|
The CAS number. |
None
|
sub_id
|
str | None
|
The substance ID. |
None
|
external_id
|
str | None
|
The external ID. |
None
|
region
|
str
|
Region for hazard data. Common values: |
'global'
|
catch_errors
|
bool | None
|
Whether to suppress errors for unknown substances, by default None. |
None
|
language
|
str | None
|
BCP-47 language code for name translation (e.g. |
None
|
classification_type
|
str | None
|
Filter by classification type. Accepted values: |
None
|
Returns:
| Type | Description |
|---|---|
SubstanceV4Info
|
The matching substance. |
Source code in src/albert/collections/substance_v4.py
search
search(
*,
search_key: str | None = None,
cas: str | None = None,
ec: str | None = None,
name: str | None = None,
region: str = "global",
classification_type: str | None = None,
start_key: int = 0,
max_items: int = 100,
) -> Iterator[SubstanceV4SearchItem]
Search for substances by keyword or advanced filters.
At least one of search_key, cas, ec, or name must be provided.
If both search_key and advanced filters are provided, the advanced filters
take precedence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_key
|
str | None
|
Free-text search term. |
None
|
cas
|
str | None
|
Filter by CAS identifier. |
None
|
ec
|
str | None
|
Filter by EC identifier. |
None
|
name
|
str | None
|
Filter by substance name. |
None
|
region
|
str
|
Region for hazard data. Common values: |
'global'
|
classification_type
|
str | None
|
Filter by classification type. Accepted values: |
None
|
start_key
|
int
|
Offset to resume pagination from, by default 0. |
0
|
max_items
|
int
|
Maximum number of items to yield, by default 100. |
100
|
Yields:
| Type | Description |
|---|---|
SubstanceV4SearchItem
|
Matching substance search records. |
Source code in src/albert/collections/substance_v4.py
create
create(
*, substance: SubstanceV4Create
) -> SubstanceV4CreateResult
Create a new substance record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
substance
|
SubstanceV4Create
|
The substance data to create. |
required |
Returns:
| Type | Description |
|---|---|
SubstanceV4CreateResult
|
The result containing created, failed, and existing items. |
Source code in src/albert/collections/substance_v4.py
update_metadata
update_metadata(
*,
id: str,
notes: str | _UnsetType = _UNSET,
description: str | _UnsetType = _UNSET,
cas_smiles: str | _UnsetType = _UNSET,
inchi_key: str | _UnsetType = _UNSET,
iupac_name: str | _UnsetType = _UNSET,
cactus_status: str | _UnsetType = _UNSET,
metadata: dict[str, MetadataItem | None]
| _UnsetType = _UNSET,
) -> None
Update metadata fields on a substance.
Only the keyword arguments you pass are updated — all others are left unchanged. The current state is fetched automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The substance ID to update. |
required |
notes
|
str
|
Free-text notes. |
_UNSET
|
description
|
str
|
Substance description. |
_UNSET
|
cas_smiles
|
str
|
SMILES notation for the structure. |
_UNSET
|
inchi_key
|
str
|
InChIKey identifier. |
_UNSET
|
iupac_name
|
str
|
IUPAC name. |
_UNSET
|
cactus_status
|
str
|
CACTUS resolver status. |
_UNSET
|
metadata
|
dict[str, MetadataItem | None]
|
Custom tenant metadata fields to update. Only the keys listed in this dict are touched; all other custom fields on the substance are left unchanged. Value types by field kind:
|
_UNSET
|
Notes
The following fields can be updated: notes, description, cas_smiles,
inchi_key, iupac_name, cactus_status, and any custom metadata fields
configured for the tenant.
Examples:
Update a scalar field and a custom string field:
client.substances_v4.update_metadata(
id="SUB123",
notes="new notes",
metadata={"solubility": "5 mg/mL"},
)
Set a single-select custom field:
client.substances_v4.update_metadata(
id="SUB123",
metadata={"cmr_eu": EntityLink(id="LST1253")},
)
Update a multi-select custom field (becomes exactly this set):
client.substances_v4.update_metadata(
id="SUB123",
metadata={"amide_category": [EntityLink(id="LST1256"), EntityLink(id="LST1257")]},
)
Delete a custom field:
client.substances_v4.update_metadata(id="SUB123", metadata={"old_key": None})
Source code in src/albert/collections/substance_v4.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |