API
API Docs
Pagination Query Builder for API
BotBye API supports Keyset-based pagination, which allows for efficient page retrieval.
This method is controlled by the following query parameters (should be encoded as URI component):
- cursor (Optional): a cursor for pagination.
- after (string): Pointer to the item after which the items are to be retrieved.
- before (string): Pointer to the item before which the items are to be retrieved.
- where (Optional): is used to create conditions for data filtering. It can be used to create simple conditions (leaf nodes) as well as compound logical expressions (branch nodes).
- predicate (string): The filtering condition (e.g., gte, lte, eq for a leaf or and, or for a branch). For possible values, see below.
- opearands (string): A list of nested conditions (used only for branches, such as and, or).
- fieldPath (string): The field to which the filtering condition is applied (used only for a leaf. Each entity has its own fieldPath list). For possible values, see below.
- value (string): The value to compare against the field (used only for a leaf).
- order_by (Optional): property by which to order by.
- fieldPath (string): name of order field. For possible values, see below.
- direction (string): ASC or DESC
Query parameters
where
The following fields can be used in requests for filtering, sorting, and displaying project data:
Possible predicate values
| Parameter | Description |
|---|---|
| and | only for branches |
| or | only for branches |
| eq | = |
| not_eq | != |
| like | searches for values containing the specified pattern |
| starts_with | searches for a value that starts with the specified prefix |
| gt | > |
| lt | < |
| gte | >= |
| lte | <= |
| in | match values in the list |
| is_null | is null |
| is_not_null | is not null |
Possible project field path
| Parameter | Description |
|---|---|
| id | The unique identifier of the project |
| name | The name of the project |
| createdAt | The timestamp when the project was created |
| url | The URL associated with the project |
Possible request field path
The following fields can be used in requests for filtering, sorting, and displaying project's requests data:
| Parameter | Description |
|---|---|
| id | The unique identifier of the request |
| project_id | The unique identifier of the project associated with the request |
| request_method | The HTTP method used for the request (e.g., GET, POST, PUT, DELETE) |
| request_uri | The URI path of the request, which specifies the resource being requested |
| remote_addr | The IP address of the client that made the request |
| created_at | The timestamp when the request was created |
| asn | The Autonomous System Number (ASN) associated with the IP address of the request |
| country | The country associated with the IP address of the request, represented as a 3-letter ISO 3166-1 alpha-3 country code. |
| request_status | declined or allowed |
Usage Examples
Simple Condition (Leaf Node)
1
2
3
4
5
{
"fieldPath": "name",
"predicate": "eq",
"value": "Test"
}
returns project where the name field is 'Test'
Compound Condition (Branch Node)
In the compound condition, the and predicate is used to combine multiple conditions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"predicate": "and",
"operands": [
{
"fieldPath": "project_id",
"predicate": "eq",
"value": "c415a474-be24-11eb-8529-0242ac130003"
},
{
"fieldPath": "country",
"predicate": "eq",
"value": "DEU"
// alpha-3 country code
}
]
}
return requests from Germany for project with id = c415a474-be24-11eb-8529-0242ac130003
Incorrect Use of a Branch with value
The incorrect example demonstrates an error when the value field is used incorrectly in a branching where. Can only be predicate(and/or) and operands.
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"predicate": "and",
"operands": [
{
"fieldPath": "name",
"predicate": "eq",
"value": "Test project"
}
],
"value": "25"
// Error: `value` should not be used in branches
}
order_by
The order_by parameter is used to sort objects by the specified fields(using the field path described in the documentation where).
1
2
3
4
{
"fieldPath": "remote_addr",
"direction": "DESC"
}
returns the objects sorted by descending order of ip
limit
The limit parameter defines the maximum number of objects that will be returned as a result of the query(min 1, max 100, default 20)
cursor
The cursor parameter is used to specify the selection start point for page navigation.
1
2
3
{
"after": "MjAyNC0wNi0wM1QxMzoxNjoyNi41MTNaLDAxOTBkOWYxLTQ2OTEtNzIyYy1hNzlmLWQ5ZmQ0NmJmMDY1YQ=="
}