Module: ncbi.datasets.openapi.configuration

NCBI Datasets API

Module: ncbi.datasets.openapi.configuration

NCBI Datasets API

### NCBI Datasets is a resource that lets you easily gather data from NCBI. The Datasets version 1 API is considred stable and will not be subject to breaking changes. For some larger downloads, you may want to download a [dehydrated bag](, and retrieve the individual data files at a later time. # noqa: E501

The version of the OpenAPI document: v1 Generated by:

class ncbi.datasets.openapi.configuration.Configuration(host=None, api_key=None, api_key_prefix=None, access_token=None, username=None, password=None, discard_unknown_keys=False, disabled_client_side_validations='', server_index=None, server_variables=None, server_operation_index=None, server_operation_variables=None, ssl_ca_cert=None)

Bases: object

NOTE: This class is auto generated by OpenAPI Generator

Ref: Do not edit the class manually.

param host

Base url

param api_key

Dict to store API key(s). Each entry in the dict specifies an API key. The dict key is the name of the security scheme in the OAS specification. The dict value is the API key secret.

param api_key_prefix

Dict to store API prefix (e.g. Bearer) The dict key is the name of the security scheme in the OAS specification. The dict value is an API key prefix when generating the auth data.

param username

Username for HTTP basic authentication

param password

Password for HTTP basic authentication

param discard_unknown_keys

Boolean value indicating whether to discard unknown properties. A server may send a response that includes additional properties that are not known by the client in the following scenarios: 1. The OpenAPI document is incomplete, i.e. it does not match the server


  1. The client was generated using an older version of the OpenAPI document and the server has been upgraded since then.

If a schema in the OpenAPI document defines the additionalProperties attribute, then all undeclared properties received by the server are injected into the additional properties map. In that case, there are undeclared properties, and nothing to discard.

param disabled_client_side_validations (string)

Comma-separated list of JSON schema validation keywords to disable JSON schema structural validation rules. The following keywords may be specified: multipleOf, maximum, exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, maxItems, minItems. By default, the validation is performed for data generated locally by the client and data received from the server, independent of any validation performed by the server side. If the input data does not satisfy the JSON schema validation rules specified in the OpenAPI document, an exception is raised. If disabled_client_side_validations is set, structural validation is disabled. This can be useful to troubleshoot data validation problem, such as when the OpenAPI document validation rules do not match the actual API data received by the server.

param server_index

Index to servers configuration.

param server_variables

Mapping with string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before.

param server_operation_index

Mapping from operation ID to an index to server configuration.

param server_operation_variables

Mapping from operation ID to a mapping with string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before.

param ssl_ca_cert

str - the path to a file of concatenated CA certificates in PEM format


API Key Authentication Example. Given the following security scheme in the OpenAPI specification:

cookieAuth: # name for the security scheme

type: apiKey in: cookie name: JSESSIONID # cookie name

You can programmatically set the cookie:

conf = ncbi.datasets.openapi.Configuration(

api_key={‘cookieAuth’: ‘abc123’} api_key_prefix={‘cookieAuth’: ‘JSESSIONID’}


The following cookie will be added to the HTTP request:

Cookie: JSESSIONID abc123


Default server index


Default server variables


Temp file folder for downloading files


function hook to refresh API key if expired


Username for HTTP basic authentication


Password for HTTP basic authentication


Logging Settings


Log stream handler


Log file handler


SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server.


Set this to customize the certificate file to verify the peer.


client certificate file


client key file


Set this to True/False to enable/disable SSL hostname verification.


urllib3 connection pool’s maximum number of connections saved per pool. urllib3 uses 1 connection as default value, but this is not the best value when you are making a lot of possibly parallel requests to the same host, which is often the case here. cpu_count * 5 is used as default value to increase performance.


Proxy URL


Proxy headers


Safe chars for path_param


Adding retries to override urllib3 default value 3

classmethod set_default(default)

Set default instance of configuration.

It stores default configuration, which can be returned by get_default_copy method.


default – object of Configuration

classmethod get_default_copy()

Return new instance of configuration.

This method returns newly created, based on default constructor, object of Configuration class or returns a copy of default configuration passed by the set_default method.


The configuration object.

property logger_file

Debug file location

property debug

Debug switch

property logger_format

Log format

get_api_key_with_prefix(identifier, alias=None)

Gets API key (with prefix if set).

  • identifier – The identifier of apiKey.

  • alias – The alternative identifier of apiKey.


The token for api key authentication.


Gets HTTP basic authentication header (string).


The token for basic HTTP authentication.


Gets Auth Settings dict for api client.


The Auth Settings information dict.


Gets the essential information for debugging.


The report for debugging.


Gets an array of host settings


An array of host settings

get_host_from_settings(index, variables=None, servers=None)

Gets host URL based on the index and variables :param index: array index of the host settings :param variables: hash of variable and the corresponding value :param servers: an array of host settings or None :return: URL based on host settings

property host

Return generated host.

Generated December 6, 2022