API Documentation
API Endpoints
Enrichment
Handle enrichment requests for a specific observable (domain or IP address).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The incoming request object containing query parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
A JSON response indicating whether the observable was found, |
|
|
and if so, the corresponding IOC. |
Source code in docs/Submodules/GreedyBear/api/views/enrichment.py
Feeds
Handle requests for IOC feeds with specific parameters and format the response accordingly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The incoming request object. |
required | |
feed_type
|
str
|
Type of feed (e.g. cowrie, honeytrap, etc.). |
required |
attack_type
|
str
|
Type of attack (e.g., all, specific attack types). |
required |
prioritize
|
str
|
Prioritization mechanism to use (e.g., recent, persistent). |
required |
format_
|
str
|
Desired format of the response (e.g., json, csv, txt). |
required |
include_mass_scanners
|
bool
|
query parameter flag to include IOCs that are known mass scanners. |
required |
include_tor_exit_nodes
|
bool
|
query parameter flag to include IOCs that are known tor exit nodes. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
The HTTP response with formatted IOC data. |
Source code in docs/Submodules/GreedyBear/api/views/feeds.py
Advanced Feeds
Handle requests for IOC feeds based on query parameters and format the response accordingly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The incoming request object. |
required | |
feed_type
|
str
|
Type of feed to retrieve. (supported: |
required |
attack_type
|
str
|
Type of attack to filter. (supported: |
required |
max_age
|
int
|
Maximum number of days since last occurrence. E.g. an IOC that was last seen 4 days ago is excluded by default. (default: 3) |
required |
min_days_seen
|
int
|
Minimum number of days on which an IOC must have been seen. (default: 1) |
required |
include_reputation
|
str
|
|
required |
exclude_reputation
|
str
|
|
required |
feed_size
|
int
|
Number of IOC items to return. (default: 5000) |
required |
ordering
|
str
|
Field to order results by, with optional |
required |
verbose
|
bool
|
|
required |
paginate
|
bool
|
|
required |
format
|
str
|
Response format type. Besides |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
The HTTP response with formatted IOC data. |
Source code in docs/Submodules/GreedyBear/api/views/feeds.py
ASN Aggregated Feeds
Retrieve aggregated IOC feed data grouped by ASN (Autonomous System Number).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The HTTP request object. |
required | |
feed_type
|
str
|
Filter by feed type (e.g. 'cowrie', 'honeytrap'). Default: 'all'. |
required |
attack_type
|
str
|
Filter by attack type (e.g., 'scanner', 'payload_request'). Default: 'all'. |
required |
max_age
|
int
|
Maximum age of IOCs in days. Default: 3. |
required |
min_days_seen
|
int
|
Minimum days an IOC must have been observed. Default: 1. |
required |
exclude_reputation
|
str
|
';'-separated reputations to exclude (e.g., 'mass scanner'). Default: none. |
required |
ordering
|
str
|
Aggregation ordering field (e.g., 'total_attack_count', 'asn'). Default: '-ioc_count'. |
required |
asn
|
str
|
Filter results to a single ASN. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
HTTP response with a JSON list of ASN aggregation objects. |
|
|
Each object contains: asn (int): ASN number. ioc_count (int): Number of IOCs for this ASN. total_attack_count (int): Sum of attack_count for all IOCs. total_interaction_count (int): Sum of interaction_count for all IOCs. total_login_attempts (int): Sum of login_attempts for all IOCs. honeypots (List[str]): Sorted list of unique honeypots that observed these IOCs. expected_ioc_count (float): Sum of recurrence_probability for all IOCs, rounded to 4 decimals. expected_interactions (float): Sum of expected_interactions for all IOCs, rounded to 4 decimals. first_seen (DateTime): Earliest first_seen timestamp among IOCs. last_seen (DateTime): Latest last_seen timestamp among IOCs. |
Source code in docs/Submodules/GreedyBear/api/views/feeds.py
Feeds Pagination
Handle requests for paginated IOC feeds based on query parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The incoming request object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
The paginated HTTP response with IOC data. |
Source code in docs/Submodules/GreedyBear/api/views/feeds.py
Cowrie Session
Retrieve Cowrie honeypot session data including command sequences, credentials, and session details. Queries can be performed using either an IP address to find all sessions from that source, or a SHA-256 hash to find sessions containing a specific command sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The HTTP request object containing query parameters |
required | |
query
|
(str, required)
|
The search term, can be either an IP address or the SHA-256 hash of a command sequence. SHA-256 hashes should match command sequences generated using Python's "\n".join(sequence) format. |
required |
include_similar
|
bool
|
When "true", expands the result to include all sessions that executed command sequences belonging to the same cluster(s) as command sequences found in the initial query result. Requires CLUSTER_COWRIE_COMMAND_SEQUENCES enabled in configuration. Default: false |
required |
include_credentials
|
bool
|
When "true", includes all credentials used across matching Cowrie sessions. Default: false |
required |
include_session_data
|
bool
|
When "true", includes detailed information about matching Cowrie sessions. Default: false |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
200
|
JSON object containing: - query (str): The original query parameter - commands (list[str]): Unique command sequences (newline-delimited strings) - sources (list[str]): Unique source IP addresses - credentials (list[str], optional): Unique credentials if include_credentials=true - sessions (list[dict], optional): Session details if include_session_data=true - time (datetime): Session start time - duration (float): Session duration in seconds - source (str): Source IP address - interactions (int): Number of interactions in session - credentials (list[str]): Credentials used in this session - commands (str): Command sequence executed (newline-delimited) |
Response |
400
|
Bad Request - Missing or invalid query parameter |
Response |
404
|
Not Found - No matching sessions found |
Response |
500
|
Internal Server Error - Unexpected error occurred |
Example Queries
/api/cowrie_session?query=1.2.3.4 /api/cowrie_session?query=5120e94e366ec83a79ee80454e4d1c76c06499ab19032bcdc7f0b4523bdb37a6 /api/cowrie_session?query=1.2.3.4&include_credentials=true&include_session_data=true&include_similar=true
Source code in docs/Submodules/GreedyBear/api/views/cowrie_session.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
Command Sequence
View function that handles command sequence queries based on IP addresses or SHA-256 hashes.
Retrieves and returns command sequences and related IOCs based on the query parameter. If IP address is given, returns all command sequences executed from this IP. If SHA-256 hash is given, returns details about the specific command sequence. Can include similar command sequences if requested.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The HTTP request object containing query parameters |
required | |
query
|
str
|
The search term, can be either an IP address or a SHA-256 hash. |
required |
include_similar
|
bool
|
When parameter is present, returns related command sequences based on clustering. |
required |
Returns:
| Type | Description |
|---|---|
|
Response object with command sequence data or an error response |
Raises:
| Type | Description |
|---|---|
Http404
|
If the requested resource is not found |
Source code in docs/Submodules/GreedyBear/api/views/command_sequence.py
General Honeypot List
Retrieve a list of all general honeypots, optionally filtering by active status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The incoming request object containing query parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
A JSON response containing the list of general honeypots. |
Source code in docs/Submodules/GreedyBear/api/views/general_honeypot.py
Statistics
Bases: ViewSet
A viewset for viewing and editing statistics related to feeds and enrichment data.
Provides actions to retrieve statistics about the sources and downloads of feeds, as well as statistics on enrichment data.
Source code in docs/Submodules/GreedyBear/api/views/statistics.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
__aggregation_response_static_ioc(annotations)
Helper method to generate IOC response based on annotations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
annotations
|
dict
|
Dictionary containing the annotations for the query. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
Response
|
A JSON response containing the aggregated IOC data. |
Source code in docs/Submodules/GreedyBear/api/views/statistics.py
__aggregation_response_static_statistics(annotations)
Helper method to generate statistics response based on annotations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
annotations
|
dict
|
Dictionary containing the annotations for the query. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
Response
|
A JSON response containing the aggregated statistics. |
Source code in docs/Submodules/GreedyBear/api/views/statistics.py
__parse_range(request)
staticmethod
Parse the range parameter from the request query string to determine the time range for the query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The incoming request object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
A tuple containing the delta time and basis for the query range. |
Source code in docs/Submodules/GreedyBear/api/views/statistics.py
enrichment(request, pk=None)
Retrieve enrichment statistics, including the number of sources and requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The incoming request object. |
required | |
pk
|
str
|
The type of statistics to retrieve (e.g., "sources", "requests"). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Response |
A JSON response containing the requested statistics. |
Source code in docs/Submodules/GreedyBear/api/views/statistics.py
feeds(request, pk=None)
Retrieve feed statistics, including the number of sources and downloads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The incoming request object. |
required | |
pk
|
str
|
The type of statistics to retrieve (e.g., "sources", "downloads"). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Response |
A JSON response containing the requested statistics. |
Source code in docs/Submodules/GreedyBear/api/views/statistics.py
feeds_types(request)
Retrieve statistics for different types of feeds using GeneralHoneypot M2M relationship.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
The incoming request object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
A JSON response containing the feed type statistics. |
Source code in docs/Submodules/GreedyBear/api/views/statistics.py
Serializers
EnrichmentSerializer
Bases: Serializer
Source code in docs/Submodules/GreedyBear/api/serializers.py
validate(data)
Check a given observable against regex expression
Source code in docs/Submodules/GreedyBear/api/serializers.py
FeedsRequestSerializer
Bases: Serializer
Source code in docs/Submodules/GreedyBear/api/serializers.py
Note: Enhanced with additional filter fields (ioc_type, etc.) in version > 2.4.0
FeedsResponseSerializer
Bases: Serializer
Serializer for feed response data structure.
NOTE: This serializer is currently NOT used in production code (as of #629). It has been kept in the codebase for the following reasons:
- Documentation: Serves as a clear schema definition for the API response contract
- Testing: Validates the expected response structure through unit tests
- Future-proofing: Allows easy re-enabling of validation if security requirements change
- Reference: Useful for API consumers and developers to understand the response format
Performance Optimization Context: Previously, this serializer was instantiated and validated for each IOC in the response (up to 5000 times per request), causing significant overhead (~1.8s for 5000 IOCs). The optimization removed this per-item validation since the data is constructed internally in api/views/utils.py::feeds_response() and guaranteed to match this schema.
The response is now built directly without serializer validation, reducing response time to ~0.03s (50-90x speedup) while maintaining the exact same API contract defined here.
See: #629 for benchmarking details and discussion.
Source code in docs/Submodules/GreedyBear/api/serializers.py
IOCSerializer
Note: Includes FireHol categories field in version > 2.4.0
GeneralHoneypotSerializer
Validation Functions
feed_type_validation
Validates that a given feed type exists in the set of valid feed types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feed_type
|
str
|
The feed type to validate |
required |
valid_feed_types
|
frozenset
|
Set of allowed feed type values |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The validated feed type string, unchanged |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If feed_type is not found in valid_feed_types |
Source code in docs/Submodules/GreedyBear/api/serializers.py
ordering_validation
Validates that given ordering corresponds to a field in the IOC model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ordering
|
str
|
The ordering to validate |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The validated ordering string, unchanged |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If ordering does not correspond to a field in the IOC model |