Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VulDB API – Python Examples

Python License: GPL v3 VulDB API

Python example scripts for retrieving vulnerability information from the VulDB API.

VulDB provides structured vulnerability data and cyber threat intelligence (CTI) for vulnerability management, security research, risk assessment and automated security workflows. These examples demonstrate API authentication, HTTP requests and response processing in Python. They can serve as a starting point for custom integrations, including SIEM and SOAR platforms.

Table of Contents

Features

  • Retrieve recently added vulnerability entries.
  • Request basic or detailed vulnerability information.
  • Demonstrate API key authentication via POST data or an HTTP header.
  • Fetch and process JSON responses.
  • Use either the Python standard library or the third-party requests package.
  • Configure queries using command-line arguments in the advanced example.

Repository Contents

File Description
recent.py Minimal example using urllib to retrieve 10 recent entries and print the raw response.
vuldb_api_demo.py Command-line example using requests and argparse to configure recent-entry queries and detail levels. Includes an ID lookup option that requires the correction described below.
LICENSE GNU General Public License v3.0.

Requirements

  • Python 3.
  • A VulDB account with a valid personal API key and available API credits.
  • HTTPS connectivity to vuldb.com.
  • The requests package for vuldb_api_demo.py only.

The modules urllib, argparse and json are included in the Python standard library and require no additional installation.

Installation

Clone the repository and enter its directory:

git clone https://github.com/vuldb/vuldb-api-python-examples.git
cd vuldb-api-python-examples

Optionally, create an isolated Python environment:

python3 -m venv .venv
source .venv/bin/activate

On Windows PowerShell, use py -3 -m venv .venv followed by .\.venv\Scripts\Activate.ps1 instead.

Install the dependency required by the advanced example:

python3 -m pip install requests

On Windows, use py -3 instead of python3 if necessary.

Authentication

Log in to VulDB and locate your personal API key in your user profile. Configure the script you intend to execute:

Script Configuration Authentication method
recent.py Replace [your_personal_api_key] in post_fields with your key. POST parameter apikey
vuldb_api_demo.py Assign your key to personalApiKey. HTTP header X-VulDB-ApiKey

Important

The existing examples expect the key to be configured in the source code. Do not commit or share a file containing a real API key. For automated integrations, use an environment variable or a secrets manager instead. See Production Integration.

Usage

Basic Example: Retrieve Recent Vulnerabilities

After configuring the API key in recent.py, execute:

python3 recent.py

The script sends a request for 10 recent vulnerability entries and prints the unprocessed JSON response to standard output. To change the requested number, adjust the recent value in the post_fields dictionary.

Save the response to a local file:

python3 recent.py > vulnerabilities.json

Advanced Example: Command-Line Interface

After configuring the API key in vuldb_api_demo.py, display the available options:

python3 vuldb_api_demo.py --help
Argument Value Default Description
--recent Integer 5 Number of recent entries to request.
--details 0 or 1 0 Basic (0) or extended (1) response data.
--id Numeric VulDB ID None Intended to retrieve a specific entry; requires the fix below.
-h, --help None — Display command-line help.

Retrieve the five most recent entries (default behavior):

python3 vuldb_api_demo.py

Retrieve 20 recent entries:

python3 vuldb_api_demo.py --recent 20

Request detailed information for five recent entries:

python3 vuldb_api_demo.py --recent 5 --details 1

On a successful HTTP response, the script decodes the JSON and prints the entry object of each returned result. It does not print the complete API response, even when --details 1 is specified. To inspect all returned fields, modify the output statement to print the complete result object (for example, print(json.dumps(i, indent=2))).

Retrieve a Specific Vulnerability by VulDB ID

Warning

In the current implementation, --recent defaults to 5 and is evaluated before --id. Consequently, an ID-only invocation still requests recent entries. To enable ID lookups while retaining the five-entry fallback, change the --recent argument definition from default=5 to default=None. The existing fallback already requests five recent entries when neither option is provided. Supply only one of --recent and --id at a time.

After making this correction, the following commands retrieve the entry with VulDB ID 67685:

python3 vuldb_api_demo.py --id 67685
python3 vuldb_api_demo.py --id 67685 --details 1

The ID is a VulDB entry identifier, not a CVE identifier. For CVE-based searches and other query types, refer to the API documentation.

API Reference

Endpoint

Property Value
URL https://vuldb.com/?api
HTTP method POST
Request encoding application/x-www-form-urlencoded
Default response format JSON
Authentication apikey form parameter or X-VulDB-ApiKey header

Response Structure

A JSON response normally includes three sections:

Section Purpose
response Status and request-processing metadata, including credit consumption and remaining credits.
request Information about the processed query.
result Matching vulnerability records.

The API-level response.status can differ from the HTTP status code. Check both when processing responses programmatically. Consult the API documentation and Data Points for the full schema, available fields and additional request types.

API Credits and Rate Limits

  • API usage depends on the account and subscription. Each request consumes at least one credit, including unsuccessful requests.
  • Detailed queries can consume additional credits depending on the results returned.
  • Credits replenish on a rolling 24-hour basis. Monitor the consumption and remaining fields in the response section.
  • VulDB recommends no more than 30 requests per minute. Space repeated requests at least two seconds apart and respect any throttling responses.

See API Credits for guidance on selecting the appropriate credit allocation.

Production Integration

The repository contains educational examples rather than a complete production API client. For production usage, keep credentials outside source files, configure request timeouts, validate responses, handle rate limits and implement bounded retries where appropriate.

Example: Environment-Based Authentication

The following standalone example illustrates a more robust request using requests. It is an additional example for integration purposes, not an existing file in this repository.

Set the VULDB_API_KEY environment variable securely using your preferred secret management mechanism, then run the following code in that environment:

import os
import requests

api_key = os.environ["VULDB_API_KEY"]

response = requests.post(
    "https://vuldb.com/?api",
    headers={"X-VulDB-ApiKey": api_key},
    data={"version": 3, "recent": 5, "details": 0},
    timeout=30,
)
response.raise_for_status()

payload = response.json()
metadata = payload.get("response", {})
status = str(metadata.get("status"))

if status not in {"200", "204"}:
    raise RuntimeError(f"VulDB API error: {status}")

for item in payload.get("result") or []:
    print(item.get("entry", {}))

The version parameter selects API major version 3 for predictable parsing. Review the API version guidance before changing this value. The example deliberately omits automatic retries and pagination; add these according to your integration requirements.

Troubleshooting

Problem Recommended action
ModuleNotFoundError: No module named 'requests' Install requests using the same Python environment used to execute the script.
API status 401 Verify the key and account access.
API status 402 Check whether your subscription permits the requested operation.
API status 403 Check your remaining credits and allow the credit window to replenish, or review your subscription.
HTTP 429 Reduce the request frequency and respect the indicated suspension period.
--id returns recent entries Apply the correction described under Retrieve a Specific Vulnerability by VulDB ID.
No output from the advanced example Inspect the HTTP status and JSON response. The existing script prints results only for HTTP 200 and has no explicit error-reporting branch.
Unexpected or incomplete fields Verify the details setting, output statement and available data fields for your request.

Contributing

Bug reports, suggestions and improvements are welcome via GitHub Issues or Pull Requests. Include the Python version, reproduction steps and relevant error information. Remove API keys and any other sensitive information from all submissions.

License

The example source code is distributed under the GNU General Public License v3.0.

Access to the VulDB API and use of the retrieved data are governed separately by the applicable VulDB Terms of Use and subscription conditions. The source code license does not grant unrestricted rights to redistribute VulDB data.

Support and Resources

Resource Link
VulDB website vuldb.com
API documentation VulDB API
API data fields Data Points
API credit guidance API Credits
Technical support support@vuldb.com
Support information VulDB Support
Other integrations VulDB on GitHub