A lightweight, browser-based example demonstrating how to retrieve vulnerability information from the VulDB API using JavaScript and XMLHttpRequest.
VulDB is a vulnerability management and cyber threat intelligence platform providing information about software vulnerabilities, affected products, CVE identifiers, risk assessments, exploits, and countermeasures.
This repository provides a starting point for developers who want to integrate VulDB data into custom applications, security dashboards, and vulnerability management workflows.
- Features
- Repository Structure
- Requirements
- Getting Started
- How It Works
- API Query Examples
- Response Handling
- API Credits and Limits
- Security Considerations
- Troubleshooting
- Documentation and Support
- Contributing
- License
- Retrieve the three most recently added vulnerability entries by default.
- Authenticate using a personal VulDB API key.
- Submit asynchronous HTTP POST requests using native browser JavaScript.
- Display the API response directly on a simple HTML page.
- Customize the request to retrieve other vulnerability data supported by the API.
- No external JavaScript libraries, npm packages, or build process required.
| File | Description |
|---|---|
index.html |
HTML demonstration page with a request button and response output area. |
vuldb_api.js |
JavaScript function for authentication, API communication, and response display. |
README.md |
Repository documentation and usage instructions. |
LICENSE |
GNU General Public License v3.0. |
.gitattributes |
Git file attribute configuration. |
- A modern web browser with JavaScript enabled.
- An internet connection to access
vuldb.comover HTTPS. - A VulDB user account with a valid personal API key and available API credits.
- Git, if cloning the repository instead of downloading it as a ZIP archive.
No Node.js installation is required to run the included browser demonstration.
git clone https://github.com/vuldb/vuldb-api-javascript-examples.git
cd vuldb-api-javascript-examplesAlternatively, download the ZIP archive and extract it locally.
Sign in to VulDB and obtain your personal API key from your user account.
Open vuldb_api.js and locate the following configuration:
var api_key = "[your_personal_api_key]";
var request = "recent=3";Replace [your_personal_api_key] with your actual API key, without the square brackets. Keep recent=3 to request the three latest entries.
Warning
Only use a real API key in a private, local demonstration. Never commit it to Git, publish it in a website, or distribute JavaScript containing the key. For production integrations, see Security Considerations.
Open index.html in your browser and click Request data.
Alternatively, if Python 3 is installed, start a local HTTP server from the repository directory:
python3 -m http.server 8000 --bind 127.0.0.1On Windows, use py -3 -m http.server 8000 --bind 127.0.0.1 if the Python launcher is available.
Visit http://localhost:8000/ and click Request data. The response appears below the button. Keep the local server private and stop it with Ctrl+C when finished.
Browser-based API access is subject to the API server's cross-origin resource sharing (CORS) policy. Serving the files locally does not bypass that policy. If direct browser requests are blocked, use a server-side integration instead.
The HTML page loads vuldb_api.js and calls vuldbApi() when the request button is clicked.
| Property | Value |
|---|---|
| Endpoint used by the example | https://vuldb.com/api |
| HTTP method | POST |
| Content type | application/x-www-form-urlencoded |
| Authentication | apikey form parameter |
| Default query | recent=3 |
| Default response format | JSON |
| JavaScript interface | XMLHttpRequest |
The function sends the API key and query as form data. Once the request completes with HTTP status 200, the original script places the response text inside the HTML element with ID result.
The request flow is:
flowchart LR
A[Request data button] --> B[vuldbApi function]
B -->|HTTPS POST| C[VulDB API]
C -->|API response| B
B --> D[Result output]
The current script uses /api; the official API reference also documents the endpoint https://vuldb.com/?api.
To change the query, edit the request variable in vuldb_api.js. The function automatically adds the API key to the POST body.
| Use case | Request value |
|---|---|
| Three most recent entries (default) | recent=3 |
| Ten most recent entries | recent=10 |
| Ten most recently updated entries | updates=10 |
| Retrieve a specific VulDB entry | id=67685 |
| Retrieve detailed vulnerability information | id=67685&details=1 |
| Search by CVE | search=CVE-2014-6271 |
| Search by product | search=Apache%20HTTP%20Server |
| Exact CVE lookup | advancedsearch=cve:CVE-2014-6271 |
| Pin the API major version | recent=3&version=3 |
| Request XML instead of JSON | recent=3&format=xml |
For example, to search for a specific CVE, change the request to:
var request = "search=CVE-2014-6271";The included script does not offer a query input field or automatically encode parameter values. When building dynamic queries, use URLSearchParams to encode form data correctly.
For the full list of query types, search filters, response formats, and available data fields, refer to the API documentation.
The default JSON response has three principal sections:
| Section | Description |
|---|---|
response |
API status, version, result count, and credit usage. |
request |
Information about the processed query. |
result |
Matching vulnerability records. |
Depending on the query and access permissions, records may contain entry IDs, titles, CVE references, risk information, timestamps, and further vulnerability details.
The included demo displays the response without parsing it. For application integrations, parse the JSON, check response.status separately from the HTTP status, and handle missing or empty results.
The following standalone example illustrates how the same request can be implemented with fetch() and structured response handling. It is an alternative implementation, not an additional script included in the repository. Run it only in a trusted environment; for server-side JavaScript, use a runtime with built-in Fetch support, such as Node.js 22 or later.
async function fetchRecentVulnerabilities(apiKey) {
const body = new URLSearchParams({
apikey: apiKey,
recent: "3",
version: "3"
});
const response = await fetch("https://vuldb.com/?api", {
method: "POST",
body
});
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
const data = await response.json();
const status = Number(data.response?.status);
if (status === 204) {
return [];
}
if (status !== 200) {
throw new Error(data.response?.error || `VulDB API error: ${status}`);
}
return Array.isArray(data.result) ? data.result : [];
}For server-side Node.js usage, supply the key through an environment variable or a secret manager rather than embedding it in the source code:
fetchRecentVulnerabilities(process.env.VULDB_API_KEY)
.then(console.log)
.catch(console.error);API access is governed by the account's subscription and remaining credits. Monitor response.consumption and response.remaining when integrating the API into an automated workflow.
Standard vulnerability queries typically use one credit. Detailed queries (details=1) may charge per returned record. Credits recover over a rolling 24-hour period. Follow the API reference's recommended ceiling of 30 requests per minute, with at least two seconds between requests.
For recurring vulnerability synchronization, use the timestamp-based query methods described in the API documentation, rather than repeatedly fetching a fixed number of recent entries.
The included script is intended as an introductory demonstration, not a production-ready API client.
- Protect credentials: Keep API keys out of public repositories, frontend bundles, logs, and shared examples. Browser-side JavaScript cannot keep an API key secret from the browser user.
- Use a backend in production: Store credentials securely on a server and expose only the application data needed by authorized frontend users.
- Render responses safely: The existing demo uses
innerHTML. UsetextContentinstead to display response data as plain text and avoid interpreting it as HTML. - Handle failures: Add network error handling, request timeouts, response validation, and controlled retries where appropriate.
- Use HTTPS: Keep certificate verification enabled and do not bypass browser security controls.
- Respect API limits: Prevent uncontrolled repeated requests and monitor credit usage.
For example, the response rendering line in the original script can be replaced with:
document.getElementById("result").textContent = this.responseText;This is a recommended modification; the original repository currently uses innerHTML.
| Symptom | Suggested action |
|---|---|
| Clicking the button produces no visible output | Check the browser's developer console and Network tab. The original script does not display network errors or non-200 HTTP responses. |
API status 401 |
Check that the API key was supplied correctly and is valid. |
API status 402 |
Verify that the account plan permits the requested operation. |
API status 403 |
Check remaining API credits and account limits. |
API status 204 |
The query completed but found no matching records. Review the search parameters. |
API status 400 or 405 |
Review the query syntax and supported request types. |
HTTP status 429 |
Reduce request frequency and avoid immediate retries. |
| CORS error | Check the API's allowed origins. Use an authorized server-side integration if cross-origin requests are blocked. |
API status codes in the JSON payload can differ from the HTTP status. Inspect both when debugging.
- Website: vuldb.com
- API reference: vuldb.com/kb/api
- Additional client examples: VulDB on GitHub
- Bug reports: GitHub Issues
- Support: support@vuldb.com
When reporting an issue, provide the query type, browser or runtime version, HTTP status, and relevant error messages. Remove API keys and other sensitive information before sharing logs or screenshots.
Contributions, bug reports, and suggestions are welcome. Use GitHub Issues to report problems or submit a pull request with proposed improvements. Keep examples simple, document changes, and ensure that no credentials are included.
The source code in this repository is licensed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE for the full license text.
Access to and use of VulDB API data remain subject to the applicable VulDB terms and account conditions. The repository's source code license does not grant unrestricted access to or redistribution rights for VulDB data.