nvd_client.config¶
Client configuration.
NVD publishes two rolling windows (https://nvd.nist.gov/developers/start-here):
- without an API key, 5 requests in 30 seconds
- with an API key, 50 requests in 30 seconds
The default rate_limit_delay leaves one request's worth of that window
between calls (6 seconds, or 0.6 seconds when a key is set). Set the delay
yourself to slow down further. NIST also recommends sleeping for several
seconds between requests so bursts are not rejected.
Classes:
-
NvdConfig–Settings for nvd_client.api.NvdApi.
Attributes:
-
MAX_CVE_RESULTS_PER_PAGE– -
MAX_CPE_RESULTS_PER_PAGE– -
RATE_LIMIT_WINDOW_SECONDS– -
RATE_LIMIT_REQUESTS_WITHOUT_KEY– -
RATE_LIMIT_REQUESTS_WITH_KEY– -
DEFAULT_BASE_URL– -
DEFAULT_USER_AGENT–
DEFAULT_USER_AGENT
module-attribute
¶
NvdConfig
dataclass
¶
NvdConfig(base_url: str = DEFAULT_BASE_URL, api_key: str | None = None, timeout: float | tuple[float, float] = 30.0, results_per_page: int = MAX_CVE_RESULTS_PER_PAGE, cpe_results_per_page: int = MAX_CPE_RESULTS_PER_PAGE, rate_limit_delay: float | None = None, max_retries: int = 4, backoff_factor: float = 1.0, max_backoff: float = 60.0, user_agent: str = '', proxy: str | None = None)
Settings for nvd_client.api.NvdApi.
The object is frozen. Build a new config and a new client to change it.
An empty api_key is stored as None. Naive date values are not
configured here; see nvd_client.utils.format_nvd_datetime.
timeout is passed to requests and may be a single seconds value
or a (connect, read) pair. results_per_page is the CVE default
(NVD's maximum is 2000). CPE Match calls use cpe_results_per_page
(NVD's maximum is 500).
max_retries is the number of additional attempts after the first
request. Retries cover connection errors and HTTP 403, 429, 500, 502,
503, and 504. backoff_factor seconds grow as
backoff_factor * 2**attempt, capped by max_backoff. A
Retry-After header replaces that delay.
Attributes:
-
base_url(str) – -
api_key(str | None) – -
timeout(float | tuple[float, float]) – -
results_per_page(int) – -
cpe_results_per_page(int) – -
rate_limit_delay(float | None) – -
max_retries(int) – -
backoff_factor(float) – -
max_backoff(float) – -
user_agent(str) – -
proxy(str | None) – -
effective_rate_limit_delay(float) –Seconds to wait between HTTP calls.
results_per_page
class-attribute
instance-attribute
¶
results_per_page: int = MAX_CVE_RESULTS_PER_PAGE
cpe_results_per_page
class-attribute
instance-attribute
¶
cpe_results_per_page: int = MAX_CPE_RESULTS_PER_PAGE