-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
nav: | ||
- index.md | ||
- 'search' | ||
- 'organisation' | ||
- 'user' | ||
- 'custom-field' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
nav: | ||
- query.md | ||
- filters.md | ||
- sorting.md | ||
- pagination.md |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Query API | ||
|
||
## Overview | ||
|
||
The Query API is the API used to search for objects with filtering and sorting capabilities. It's an API introduced by TheHive 4 and is optimized for the the new data model. | ||
|
||
TheHive comes with a list of predefined search *Queries* like: | ||
|
||
- `listOrganisation` | ||
- `listUser` | ||
- `listAlert` | ||
- `listCase` | ||
|
||
## Query | ||
|
||
```plain | ||
POST /api/v0/query | ||
``` | ||
|
||
## Request Body | ||
|
||
The Query API request body should be an array of *operations* of different types: | ||
|
||
- Selection: *Required* | ||
- list of objects | ||
- object by identifier | ||
- Filtering: *optional* | ||
- Sorting: *optional* | ||
- Pagination: *optional* | ||
- Formatting: *optional* | ||
|
||
!!! Examples | ||
|
||
=== "Simple List" | ||
```json | ||
{ | ||
"query": [ | ||
{ | ||
"_name": "listOrganisation" | ||
} | ||
] | ||
} | ||
``` | ||
=== "List with filters" | ||
List organisations called *admin* | ||
```json | ||
{ | ||
"query": [ | ||
{ | ||
"_name": "listOrganisation" | ||
}, | ||
{ | ||
"_like": { | ||
"_field": "name", | ||
"_value": "admin" | ||
}, | ||
"_name": "filter" | ||
} | ||
] | ||
} | ||
``` | ||
=== "List with filters and sort" | ||
List organisations called *admin*, sorted by ascendant `updatedAt` value | ||
```json | ||
{ | ||
"query": [ | ||
{ | ||
"_name": "listOrganisation" | ||
}, | ||
{ | ||
"_like": { | ||
"_field": "name", | ||
"_value": "admin" | ||
}, | ||
"_name": "filter" | ||
}, | ||
{ | ||
"_fields": [ | ||
{ | ||
"updatedAt": "asc" | ||
} | ||
], | ||
"_name": "sort" | ||
} | ||
] | ||
} | ||
``` | ||
=== "List with pagination" | ||
List organisations called *admin*, sorted by ascendant `updatedAt` value, paginated to display the first 15 items | ||
```json | ||
{ | ||
"query": [ | ||
{ | ||
"_name": "listOrganisation" | ||
}, | ||
{ | ||
"_like": { | ||
"_field": "name", | ||
"_value": "admin" | ||
}, | ||
"_name": "filter" | ||
}, | ||
{ | ||
"_fields": [ | ||
{ | ||
"updatedAt": "asc" | ||
} | ||
], | ||
"_name": "sort" | ||
}, | ||
{ | ||
"_name": "page", | ||
"from": 0, | ||
"to": 15 | ||
} | ||
] | ||
} | ||
``` | ||
|
||
|
Empty file.