Official Python client for the Mallory threat intelligence API
Project description
malloryapi
Official Python client for the Mallory threat intelligence API.
Installation
pip install malloryapi
# or
uv add malloryapi
Quick Start
from malloryapi import MalloryApi
client = MalloryApi(api_key="your-api-key")
# List recent vulnerabilities
vulns = client.vulnerabilities.list(limit=10)
for v in vulns:
print(v["cve_id"], v.get("cvss_base_score"))
# Get a specific vulnerability
vuln = client.vulnerabilities.get("CVE-2024-1234")
# Trending threat actors (last 7 days)
actors = client.threat_actors.trending(period="7d")
Authentication
Pass your API key directly or set the MALLORY_API_KEY environment variable:
# Explicit
client = MalloryApi(api_key="sk-...")
# From environment
import os
os.environ["MALLORY_API_KEY"] = "sk-..."
client = MalloryApi()
Async Support
from malloryapi import AsyncMalloryApi
async with AsyncMalloryApi(api_key="sk-...") as client:
vulns = await client.vulnerabilities.list(limit=10)
actor = await client.threat_actors.get("apt28-uuid")
Resources
Entities
| Resource | Accessor | Key Methods |
|---|---|---|
| Vulnerabilities | client.vulnerabilities |
list, get, trending, exploited, export, exploits, mentions, products, observables |
| Threat Actors | client.threat_actors |
list, get, trending, export, mentions, observables, attack_patterns |
| Malware | client.malware |
list, get, trending, export, mentions, observables, vulnerabilities, attack_patterns |
| Exploits | client.exploits |
list, get, export, vulnerabilities |
| Exploitations | client.exploitations |
list, get |
| Organizations | client.organizations |
list, get, trending, export, mentions, products, breaches |
| Products | client.products |
list, get, trending, search, export, advisories, mentions |
| Attack Patterns | client.attack_patterns |
list, get, trending, mentions, threat_actors, malware |
| Breaches | client.breaches |
list, get, organizations |
| Detection Signatures | client.detection_signatures |
list, get |
| Advisories | client.advisories |
list, get, export, products, vulnerabilities |
| Weaknesses | client.weaknesses |
list, get |
Content
| Resource | Accessor | Key Methods |
|---|---|---|
| Stories | client.stories |
list, get, topics, references, events, similar, entities, export |
| References | client.references |
list, get, create, labels, entities, threat_actors, vulnerabilities |
| Sources | client.sources |
list, statistics |
| Content Chunks | client.content_chunks |
list, get, search |
Analytics
| Resource | Accessor | Key Methods |
|---|---|---|
| Mentions | client.mentions |
list, actors, vulnerabilities |
| Search | client.search |
query |
Pagination
All list methods return a PaginatedResponse with .items, .total, .offset, .limit, and .has_more:
page = client.vulnerabilities.list(offset=0, limit=50)
print(f"Showing {len(page)} of {page.total}")
if page.has_more:
next_page = client.vulnerabilities.list(offset=50, limit=50)
Auto-pagination
Iterate over all results automatically:
from malloryapi import paginate_sync
for vuln in paginate_sync(client.vulnerabilities.list, limit=100):
print(vuln["cve_id"])
Async version:
from malloryapi import paginate_async
async for vuln in paginate_async(client.vulnerabilities.list):
print(vuln["cve_id"])
Trending
Entities with trending support accept a period parameter ("1d", "7d", or "30d"):
# Trending vulnerabilities over the last 30 days
vulns = client.vulnerabilities.trending(period="30d")
# Trending threat actors (defaults to 7 days)
actors = client.threat_actors.trending()
Error Handling
from malloryapi import MalloryApi, NotFoundError, AuthenticationError
client = MalloryApi(api_key="sk-...")
try:
vuln = client.vulnerabilities.get("CVE-9999-0000")
except NotFoundError:
print("Vulnerability not found")
except AuthenticationError:
print("Invalid API key")
All exceptions inherit from APIError and include status_code and response_body attributes.
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file malloryapi-0.2.2.post1.dev0.tar.gz.
File metadata
- Download URL: malloryapi-0.2.2.post1.dev0.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b1d8eef08be0a8ef258a1cbfe2d49d90697ca9eb9e2d64bfc47d2d0e9e14fe5
|
|
| MD5 |
04dafefd11ef5aa14167b2be3d5d1e42
|
|
| BLAKE2b-256 |
02eacecb5571f1b8a7ea6dd920224060a920c5af1685ffb1f5c0e72dbe2b9245
|
Provenance
The following attestation bundles were made for malloryapi-0.2.2.post1.dev0.tar.gz:
Publisher:
publish.yml on malloryai/malloryapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
malloryapi-0.2.2.post1.dev0.tar.gz -
Subject digest:
9b1d8eef08be0a8ef258a1cbfe2d49d90697ca9eb9e2d64bfc47d2d0e9e14fe5 - Sigstore transparency entry: 955146487
- Sigstore integration time:
-
Permalink:
malloryai/malloryapi@c37609cae124d6751d6e896cf9d3a4cb0c7e5bd1 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/malloryai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c37609cae124d6751d6e896cf9d3a4cb0c7e5bd1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file malloryapi-0.2.2.post1.dev0-py3-none-any.whl.
File metadata
- Download URL: malloryapi-0.2.2.post1.dev0-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ffe3e56e7036cf93a229fd37362d0b7850d08c0f042b3252041213b598c722f
|
|
| MD5 |
7cd1c5d37d2a107186ba250cd3f8d08b
|
|
| BLAKE2b-256 |
04fee7df37916b5ad03d60e61de97d11e2393589ef7dde48f64e0010601fa43c
|
Provenance
The following attestation bundles were made for malloryapi-0.2.2.post1.dev0-py3-none-any.whl:
Publisher:
publish.yml on malloryai/malloryapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
malloryapi-0.2.2.post1.dev0-py3-none-any.whl -
Subject digest:
1ffe3e56e7036cf93a229fd37362d0b7850d08c0f042b3252041213b598c722f - Sigstore transparency entry: 955146490
- Sigstore integration time:
-
Permalink:
malloryai/malloryapi@c37609cae124d6751d6e896cf9d3a4cb0c7e5bd1 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/malloryai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c37609cae124d6751d6e896cf9d3a4cb0c7e5bd1 -
Trigger Event:
release
-
Statement type: