Getting started overview
This guide outlines the essential steps to get started with the MalwareBazaar API, focusing on account setup, API key acquisition, and making your initial API request. MalwareBazaar, operated by abuse.ch, provides a public repository of malware samples to assist security researchers and threat intelligence analysts in their work. The API enables automated querying and submission of malware data.
Before making your first API call, you will need to obtain an API key. This key authenticates your requests and grants access to the platform's data. The process is designed to be straightforward for non-commercial use cases, with specific guidelines for commercial applications.
The MalwareBazaar API supports several types of requests, including searching for samples by hash, retrieving recent additions, and submitting new samples for analysis. All API interactions are performed over HTTPS, ensuring secure communication. Responses are typically returned in JSON format, facilitating programmatic parsing and integration into existing security tools.
Here's a quick reference table for the getting started steps:
| Step | What to do | Where |
|---|---|---|
| 1. Review API Documentation | Understand API capabilities and requirements | MalwareBazaar API Documentation |
| 2. Obtain API Key | Locate and retrieve your unique API key | MalwareBazaar API Documentation |
| 3. Prepare Request | Construct your first API call (e.g., fetch recent samples) | Local development environment or cURL |
| 4. Execute Request | Send the API call and observe the response | Terminal or HTTP client |
| 5. Parse Response | Process the JSON output | Your application code |
Create an account and get keys
MalwareBazaar does not require a traditional account creation process with a username and password for basic API key access. Instead, the API key is publicly available within the API documentation itself for non-commercial use. This approach simplifies access for researchers and allows for quick integration.
To obtain your API key:
- Navigate to the official MalwareBazaar API documentation page.
- Locate the section titled "API Key" or similar. The key is typically presented directly on this page.
- Copy the provided API key. This key is a unique string of characters that you will include in your API requests to authenticate yourself.
It is important to handle your API key securely. While the MalwareBazaar key for public use is not tied to a specific user account, treating it as a sensitive credential is a good security practice. Avoid embedding it directly in client-side code or public repositories. For server-side applications, consider storing it in environment variables or a secure configuration management system.
For commercial use cases or enterprise-level access, MalwareBazaar's parent organization, abuse.ch, may require explicit permission or offer enterprise licensing through partners as detailed in their terms. If your use falls under commercial activity, consult the documentation for specific instructions or contact abuse.ch directly to discuss appropriate licensing.
Your first request
Once you have your API key, you can make your first request to the MalwareBazaar API. A common starting point is to fetch a list of recent malware samples. This demonstrates how to structure a basic query and retrieve data.
The MalwareBazaar API uses HTTP POST requests with a JSON payload in the request body. The API key is typically included in the JSON payload.
Example: Fetching recent samples
This example uses curl, a common command-line tool for making HTTP requests, to fetch the most recently added malware samples.
Request details:
- Endpoint:
https://mb-api.abuse.ch/api/v1/ - Method:
POST - Headers:
Content-Type: application/json - Body: A JSON object containing the
querytype and yourAPI_KEY.
curl command:
curl -s -X POST \
-H "Content-Type: application/json" \
--data '{"query": "get_recent", "selector": "time", "limit": 10, "API_KEY": "YOUR_API_KEY"}' \
https://mb-api.abuse.ch/api/v1/
Replace YOUR_API_KEY with the actual API key you obtained from the MalwareBazaar API documentation.
Expected JSON response (truncated example):
{
"query_status": "ok",
"data": [
{
"id": "123456789",
"sha256_hash": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",
"file_name": "sample.exe",
"file_size": 123456,
"file_type_mime": "application/x-dosexec",
"first_seen": "2026-05-29 10:00:00",
"tags": ["trojan", "downloader"],
"signature": "Generic.Malware.Signature",
"imphash": "0123456789abcdef0123456789abcdef",
"tlsh": "T123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
"ssdeep": "123:abc:def",
"reporter": "abuse.ch",
"anonymous": 0,
"origin_country": null,
"delivery_method": null,
"yara_rules": [],
"comments": ""
}
// ... more samples
]
}
This response indicates a successful query ("query_status": "ok") and provides an array of malware samples, each with various metadata fields like sha256_hash, file_name, tags, and first_seen. You can then parse this JSON data within your application to extract relevant information.
Common next steps
After successfully making your first request, consider these common next steps to further integrate with MalwareBazaar's API:
-
Explore Other Query Types: The MalwareBazaar API supports various query types beyond fetching recent samples. You can search for samples by specific hash values (SHA256, MD5, SHA1), YARA rules, or even by file name. Review the MalwareBazaar API documentation for a complete list of available queries and their parameters.
- Hash lookup: Querying by
sha256_hash(or other hash types) is fundamental for verifying the presence of known malware in your environment. - YARA rule lookup: If you develop custom YARA rules for threat detection, you can use the API to check if samples matching your rules exist in the MalwareBazaar collection.
- Hash lookup: Querying by
-
Integrate into Security Workflows: Incorporate MalwareBazaar's data into your existing security tools, such as Security Information and Event Management (SIEM) systems, threat intelligence platforms, or incident response playbooks. Automated lookups can enrich alerts with context from a vast malware repository.
- For example, an alert from an endpoint detection and response (EDR) solution could trigger an automated API call to MalwareBazaar to check if a suspicious file's hash is known malware.
-
Parse and Analyze Data: Develop robust parsing logic for the JSON responses. Extract relevant fields like
tags,signature,imphash, andtlshto categorize and analyze malware samples effectively. These fields provide critical context for understanding malware behavior and attribution. Information on parsing JSON can be found in various developer resources, such as the Mozilla Developer Network's JSON.parse reference. -
Handle Rate Limits and Errors: The MalwareBazaar API, like many public APIs, may impose rate limits to ensure fair usage. Implement error handling and backoff strategies in your code to manage these limits gracefully. The API response will typically include status codes and error messages when a request fails or is rate-limited. Understanding common HTTP status codes is crucial for effective API integration as defined by IETF RFC 9110.
-
Consider Commercial Licensing: If your usage scales beyond non-commercial limits or is part of a commercial product/service, review the MalwareBazaar API documentation for information on commercial licensing. Adhering to the terms of service is essential for sustained access.
Troubleshooting the first call
Encountering issues during your first API call is common. Here's a guide to troubleshoot some of the most frequent problems:
-
Incorrect API Key:
- Symptom: API returns an error indicating invalid or missing API key, or unauthorized access.
- Solution: Double-check that you have copied the API key correctly from the MalwareBazaar API documentation. Ensure there are no leading or trailing spaces. Verify that the key is included in the JSON payload under the
API_KEYfield, as required by MalwareBazaar.
-
Incorrect Endpoint or Method:
- Symptom: HTTP 404 Not Found error or an empty/unexpected response.
- Solution: Confirm that you are sending the request to the correct API endpoint (
https://mb-api.abuse.ch/api/v1/). Ensure you are using thePOSTHTTP method, as MalwareBazaar's API primarily uses POST for queries, unlike many REST APIs that might use GET for data retrieval.
-
Malformatted JSON Payload:
- Symptom: API returns a 400 Bad Request error or an error message about invalid JSON.
- Solution: Verify that your JSON payload is syntactically correct. Check for misplaced commas, missing quotes, or incorrect field names (e.g.,
"query": "get_recent"and"selector": "time"). Tools like online JSON validators can help identify issues. Ensure theContent-Type: application/jsonheader is set correctly.
-
Network Connectivity Issues:
- Symptom: Request times out, cannot connect to host, or other network-related errors.
- Solution: Check your internet connection. If you are behind a corporate firewall or proxy, ensure that it is configured to allow outbound connections to
mb-api.abuse.chon port 443 (HTTPS).
-
Rate Limiting:
- Symptom: API returns a 429 Too Many Requests error.
- Solution: This indicates you have exceeded the allowed number of requests within a given timeframe. Wait for the rate limit period to expire and try again. For production systems, implement a backoff strategy where your application waits for an increasing amount of time before retrying a failed request. Consult the MalwareBazaar documentation for specific rate limit details.
-
Outdated Documentation/API Changes:
- Symptom: Requests that previously worked now fail, or documented parameters are not recognized.
- Solution: APIs can evolve. Always refer to the latest MalwareBazaar API documentation to ensure your implementation aligns with the current API specification.
By systematically addressing these common issues, you can debug your first MalwareBazaar API call and move towards successful integration.