Substances V4 (🧪 Beta)
albert.collections.substance_v4.SubstanceV4Collection
Bases: BaseCollection
Manage substances in the Albert platform (🧪 Beta).
This collection is accessed as client.substances_v4.
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 authenticated Albert session used for API calls. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base API route for substance requests. |
Methods:
| Name | Description |
|---|---|
get_by_ids |
Get substances by CAS IDs, substance IDs, or external IDs. |
get_by_id |
Get a single substance by CAS ID, substance ID, or external ID. |
search |
Search for substances matching the given filters. |
create |
Create a new substance record. |
update_metadata |
Update metadata fields on a substance. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
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,
) -> SubstanceV4Response
Get 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
|
When |
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 |
|---|---|
SubstanceV4Response
|
The matching substances and any per-substance errors. |
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 | None
Get 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
|
When |
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 | None
|
The fully populated substance, or |
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,
inciname: str | None = None,
cas_ids: str | None = None,
region: str = "global",
classification_type: str | None = None,
catch_errors: bool | None = None,
language: str | None = None,
fetch_structures: bool | None = None,
start_key: int = 0,
max_items: int | None = None,
) -> Iterator[SubstanceV4SearchItem]
Search for substances by keyword or advanced filters.
At least one of search_key, cas, ec, name, inciname, or
cas_ids 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
|
inciname
|
str | None
|
Filter by INCI name identifier. |
None
|
cas_ids
|
str | None
|
Comma-separated CAS IDs to filter by (for example |
None
|
region
|
str
|
Region for hazard data. Common values: |
'global'
|
classification_type
|
str | None
|
Filter by classification type. Accepted values: |
None
|
catch_errors
|
bool | None
|
When |
None
|
language
|
str | None
|
BCP-47 language code for name translation (e.g. |
None
|
fetch_structures
|
bool | None
|
When |
None
|
start_key
|
int
|
Offset to resume pagination from, by default 0. |
0
|
max_items
|
int
|
Maximum number of items to yield. Defaults to |
None
|
Yields:
| Type | Description |
|---|---|
SubstanceV4SearchItem
|
Matching substance search records. |
Source code in src/albert/collections/substance_v4.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 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 | |
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; omitted arguments are left unchanged.
Example
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.
Source code in src/albert/collections/substance_v4.py
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 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |