Privileged API Reference¶
Warning
Classes on this page target privileged endpoints and require valid NMDCAuth credentials.
They are intended for authorized users who need metadata submission, identifier minting, or staging workflows.
Authentication Support¶
NMDCAuth is required for all privileged classes on this page.
NMDCAuth
¶
NMDCAuth(client_id: str | None = None, client_secret: str | None = None, username: str | None = None, password: str | None = None, api_base_url: str = 'https://api.microbiomedata.org', env: str = '')
Bases: nmdc_client.api_client.NMDCAPIClient
Authentication handler for NMDC API operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_id
|
str | None
|
The client ID for NMDC API authentication. See Notes for further details. |
None
|
client_secret
|
str | None
|
The client secret for NMDC API authentication. See Notes for further details. |
None
|
username
|
str | None
|
The username for NMDC API authentication. See Notes for further details. |
None
|
password
|
str | None
|
The password for NMDC API authentication. See Notes for further details. |
None
|
api_base_url
|
str
|
The base URL of an instance of the NMDC Runtime API. By default, this is the base URL of the production instance. |
'https://api.microbiomedata.org'
|
env
|
str
|
Deprecated. Use |
''
|
Notes
Security Warning - your credentials should be stored in a secure location. Do not hard-code these values in your code; we recommend using environment variables.
You must provide either:
client_idandclient_secret(for client credentials grant), ORusernameandpassword(for password grant).
Warnings
The env parameter is deprecated. Use api_base_url instead.
Source code in nmdc_client/auth.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
get_token
¶
get_token() -> str
Get a valid access token, refreshing if necessary.
Source code in nmdc_client/auth.py
86 87 88 89 90 91 | |
has_credentials
¶
has_credentials() -> bool
Check if the credentials are passed in properly.
Source code in nmdc_client/auth.py
78 79 80 81 82 83 84 | |
Authentication Requirement¶
Instantiate NMDCAuth and pass it to privileged classes:
from nmdc_client.auth import NMDCAuth
from nmdc_client.metadata import Metadata
auth = NMDCAuth(client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET")
metadata_client = Metadata(auth=auth)
Metadata Submission¶
Metadata
¶
Metadata(api_base_url: str = 'https://api.microbiomedata.org', auth: NMDCAuth | None = None, env: str = '')
Bases: nmdc_client.api_client.NMDCAPIClient
Class to interact with the NMDC API metadata endpoints.
This class includes methods for interacting with endpoints for metadata management, including validation and submission. It is not intended for general/public use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_base_url
|
str
|
The base URL of the NMDC API. |
'https://api.microbiomedata.org'
|
auth
|
NMDCAuth | None
|
An instance of the NMDCAuth class for authentication. |
None
|
Warnings
The env parameter is deprecated. Use api_base_url instead.
Source code in nmdc_client/metadata.py
31 32 33 34 35 36 37 38 39 40 41 | |
submit_json
¶
submit_json(json_records: list[dict] | str) -> int
Submits a json file to the NMDC metadata database via the NMDC Runtime API's json_submit endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_records
|
list[dict] | str
|
The json records to be submitted. Can be passed in as a file path or list of dictionaries. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The HTTP status code of the submission request. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the submission fails. |
Source code in nmdc_client/metadata.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
validate_json
¶
validate_json(json_records: list[dict] | str) -> int
Validates a json file using the NMDC json validate endpoint.
If the validation passes, the method returns without any side effects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_records
|
list[dict] | str
|
The json records to be validated. Can be passed in as a file path or list of dictionaries. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The HTTP status code of the validation request. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the validation fails. |
Source code in nmdc_client/metadata.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
Identifier Minting¶
Minter
¶
Minter(api_base_url: str = 'https://api.microbiomedata.org', auth: NMDCAuth | None = None, env: str = '')
Bases: nmdc_client.api_client.NMDCAPIClient
Class to interact with the NMDC API to mint new identifiers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_base_url
|
str
|
The base URL of the NMDC API. |
'https://api.microbiomedata.org'
|
auth
|
NMDCAuth | None
|
An instance of the NMDCAuth class for authentication. |
None
|
Warnings
The env parameter is deprecated. Use api_base_url instead.
Source code in nmdc_client/minter.py
28 29 30 31 32 33 34 35 36 37 38 | |
mint
¶
mint(nmdc_type: str, count: int = 1, client_id: str | None = None, client_secret: str | None = None) -> str | list[str]
Mint new identifier(s) for a specified type of record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nmdc_type
|
str
|
The type of NMDC ID to mint (e.g., 'nmdc:MassSpectrometry', 'nmdc:DataObject'). |
required |
count
|
int
|
The number of identifiers to mint. |
1
|
client_id
|
str | None
|
The client ID for authentication. Kept for backwards compatibility. |
None
|
client_secret
|
str | None
|
The client secret for authentication. Kept for backwards compatibility. |
None
|
Returns:
| Type | Description |
|---|---|
str or list[str]
|
If count is 1, returns a single minted identifier as a string. If count is greater than 1, returns a list of minted identifiers. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the API request fails. |
ValueError
|
If count is less than 1. |
Notes
If client_id and client_secret are provided, a new instance of the NMDCAuth class will be created. The newest and preferred method for authentication is to use the NMDCAuth class directly.
Source code in nmdc_client/minter.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
Data Staging and Workflow Management¶
JGISequencingProjectAPI
¶
JGISequencingProjectAPI(auth: NMDCAuth, api_base_url: str = 'https://api.microbiomedata.org', env: str = '')
Bases: nmdc_client.api_client.NMDCAPIClient
Class to interact with the NMDC API to get JGI samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
NMDCAuth
|
The NMDCAuth instance containing the credentials and API base URL for authentication. |
required |
api_base_url
|
str
|
The base URL of an instance of the NMDC Runtime API. By default, this is the base URL of the production instance. |
'https://api.microbiomedata.org'
|
env
|
str
|
Deprecated. Use |
''
|
Warnings
The env parameter is deprecated. Use api_base_url instead.
Source code in nmdc_client/data_staging.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
create_jgi_sequencing_project
¶
create_jgi_sequencing_project(jgi_sequencing_project: dict) -> dict
Create a new JGI sequencing project in the NMDC database. For more information on available keys, visit the NMDC API Docs https://api.microbiomedata.org/docs#/Workflow%20management/create_sequencing_record_wf_file_staging_jgi_sequencing_projects_post
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jgi_sequencing_project
|
dict
|
The JGI sequencing project data to be created. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The created JGI sequencing project record. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the creation fails. |
Source code in nmdc_client/data_staging.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
get_jgi_sequencing_project_by_name
¶
get_jgi_sequencing_project_by_name(project_name: str) -> dict
Get a specific JGI sequencing project by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
The name of the JGI sequencing project to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The JGI sequencing project record. |
Source code in nmdc_client/data_staging.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
list_jgi_sequencing_projects
¶
list_jgi_sequencing_projects(filter: str | None = None, max_page_size: int = 20, fields: str = '', all_pages: bool = False) -> list[dict[str, Any]]
List JGI sequencing projects from the NMDC database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter
|
str | None
|
Filter to apply to the API call. |
None
|
max_page_size
|
int
|
The maximum number of items to return per page. |
20
|
fields
|
str
|
The fields to return. |
''
|
all_pages
|
bool
|
True to return all pages. False to return the first page. |
False
|
Returns:
| Type | Description |
|---|---|
list
|
The list of JGI sequencing projects. |
Source code in nmdc_client/data_staging.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
JGISampleSearchAPI
¶
JGISampleSearchAPI(auth: NMDCAuth, api_base_url: str = 'https://api.microbiomedata.org', env: str = '')
Bases: nmdc_client.api_client.NMDCAPIClient
Class to interact with the NMDC API to get JGI samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
NMDCAuth
|
The NMDCAuth instance containing the credentials and API base URL for authentication. |
required |
api_base_url
|
str
|
The base URL of an instance of the NMDC Runtime API. By default, this is the base URL of the production instance. |
'https://api.microbiomedata.org'
|
env
|
str
|
Deprecated. Use |
''
|
Warnings
The env parameter is deprecated. Use api_base_url instead.
Source code in nmdc_client/data_staging.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
insert_jgi_sample
¶
insert_jgi_sample(jgi_sample: dict) -> dict
Insert JGI samples into the NMDC database. For more information on keys, visit the NMDC API Docs https://api.microbiomedata.org/docs#/Workflow%20management/create_jgi_sample_wf_file_staging_jgi_samples_post
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jgi_sample
|
dict
|
The JGI sample data to be inserted. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The response from the insertion operation. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the insertion fails. |
Source code in nmdc_client/data_staging.py
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 | |
list_jgi_samples
¶
list_jgi_samples(filter: str | None = None, max_page_size: int = 20, fields: str = '', all_pages: bool = False) -> list[dict]
Get a specific JGI sample by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter
|
str | None
|
Filter to apply to the API call. |
None
|
max_page_size
|
int
|
The maximum number of items to return per page. |
20
|
fields
|
str
|
The fields to return. |
''
|
all_pages
|
bool
|
True to return all pages. False to return the first page. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
The list of JGI sample records. |
Source code in nmdc_client/data_staging.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 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 | |
update_jgi_sample
¶
update_jgi_sample(jgi_file_id: str, jgi_sample: dict) -> dict
Update JGI samples in the NMDC database. For more information on available keys, visit the NMDC API Docs https://api.microbiomedata.org/docs#/Workflow%20management/update_jgi_samples_wf_file_staging_jgi_samples__jdp_file_id__patch
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jgi_file_id
|
str
|
The JGI file ID of the sample to be updated. |
required |
jgi_sample
|
dict
|
The updated JGI sample data. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The response from the update operation. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the update fails. |
Source code in nmdc_client/data_staging.py
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 | |
GlobusTaskAPI
¶
GlobusTaskAPI(auth: NMDCAuth, api_base_url: str = 'https://api.microbiomedata.org', env: str = '')
Bases: nmdc_client.api_client.NMDCAPIClient
Class to interact with the NMDC API for Globus tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
NMDCAuth
|
The NMDCAuth instance containing the credentials and API base URL for authentication. |
required |
api_base_url
|
str
|
The base URL of an instance of the NMDC Runtime API. By default, this is the base URL of the production instance. |
'https://api.microbiomedata.org'
|
env
|
str
|
Deprecated. Use |
''
|
Warnings
The env parameter is deprecated. Use api_base_url instead.
Source code in nmdc_client/data_staging.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | |
create_globus_task
¶
create_globus_task(globus_task: dict) -> dict
Create a new Globus task in the NMDC database. For more information on available keys, visit the NMDC API Docs https://api.microbiomedata.org/docs#/Workflow%20management/create_globus_tasks_wf_file_staging_globus_tasks_post
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
globus_task
|
dict
|
The Globus task data to be created. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The created Globus task record. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the creation fails. |
Source code in nmdc_client/data_staging.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | |
list_globus_tasks
¶
list_globus_tasks(filter: str | None = None, max_page_size: int = 20, fields: str = '', all_pages: bool = False) -> list[dict]
Get Globus tasks from the NMDC database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter
|
str | None
|
Filter to apply to the API call. |
None
|
max_page_size
|
int
|
The maximum number of items to return per page. |
20
|
fields
|
str
|
The fields to return. |
''
|
all_pages
|
bool
|
True to return all pages. False to return the first page. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
The list of Globus task records. |
Source code in nmdc_client/data_staging.py
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 | |
update_globus_task
¶
update_globus_task(globus_task_id: str, globus_task: dict) -> dict
Update a Globus task in the NMDC database. For more information on available keys, visit the NMDC API Docs https://api.microbiomedata.org/docs#/Workflow%20management/update_globus_tasks_wf_file_staging_globus_tasks__task_id__patch
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
globus_task_id
|
str
|
The ID of the Globus task to be updated. |
required |
globus_task
|
dict
|
The Globus task data to be updated. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The updated Globus task record. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the update fails. |
Source code in nmdc_client/data_staging.py
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | |
Related Pages¶
- Core Search API Reference for public core APIs
CollectionSearchSubclasses for public collection subclasses