Get Key Items¶
Description¶
This operation returns the values for the specified keys. It has variations where it can return a single value for a key or a range of values based on indexes.
Method¶
GET
Important
Make sure to replace xxxx in the domain name in the request specification below to the one assigned to your application.
Endpoint URL¶
Return All Values
https://xxxx.backendless.app/api/hive/[hive-name]/list/[key]
Return Value By Index
Every element in a list is located at a specific index position. The operation accepts an index to return the value located in that position. List indexes are zero-based, it means the very first element in a List has the index of 0
. However, you can also use a negative index
, for instance -1
to return the last item from that list, -2
points to the second to last and so on. For more information about the indexes see the Hive Overview section of this guide.
https://xxxx.backendless.app/api/hive/[hive-name]/list/[key]/[index]
Return A Range Of Values
This format of the operation retrieves a range of values by using two index positions to form a range.
https://xxxx.backendless.app/api/hive/[hive-name]/list/[key]?from=[indexFrom]&to=[indexTo]
where:
Argument | Description |
---|---|
[hive-name] |
Name of a hive where the operation is performed. |
[key] |
Key name identifying a list. |
[index] |
An index position of a specific value in the list. |
[indexFrom/indexTo] |
The indexFrom parameter identifies the first value to get by the index position, while the indexTo parameter identifies the last value to get by index position. |
Request Headers¶
None.
Request Body¶
None.
Response Body¶
One value when this operation uses a single index position.
A JSON array containing values:
- When all values are requested.
- When a range of values is requested by using the
indexFrom
andindexTo
parameters.
An empty JSON array if no elements exist in the specified list.
Examples¶
Return All Values
The example below returns all values from the fruits
list.
curl --location --request GET "https://xxxx.backendless.app/api/hive/groceryStore/list/fruits"
where:
Argument | Description |
---|---|
groceryStore |
Name of a hive where the operation is performed. |
fruits |
Key name identifying a list. |
Return Value By Index
The example below returns an item located at the index position 1
in the fruits
list.
curl --location --request GET "https://xxxx.backendless.app/api/hive/groceryStore/list/fruits/1"
where:
Argument | Description |
---|---|
groceryStore |
Name of a hive where the operation is performed. |
fruits |
Key name identifying a list. |
Return Range Of Values
The example below returns four values from the fruits
list since the operation is set to retrieve all items in range starting from index position 2
to 5
.
curl --location --request GET "https://xxxx.backendless.app/api/hive/groceryStore/list/fruits?from=2&to=5"
where:
Argument | Description |
---|---|
groceryStore |
Name of a hive where the operation is performed. |
fruits |
Key name identifying a list. |
Codeless Reference¶
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
key name |
Key name identifying a list. |
Returns a list containing values.
Consider the following List storage:
The example below returns all values from the "fruits"
list.
The output will look as shown below after the Codeless logic runs.
You can also get an item by using the index position. Every value in a list is located at a specific index position. The operation accepts an index to return the value located in that position. List indexes are zero-based, it means the very first element in a List has the index of 0
. However, you can also use a negative index
, for instance -1
to return the last item from that list, -2
points to the second to last and so on. For more information about the indexes see the Hive Overview section of this guide.
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
key name |
Key name identifying a list. |
index |
An index position of the specified value. |
The example below retrieves the value positioned in the index 1 in the "fruits"
list.
The output will look as shown below after the Codeless logic runs.
This operation also allows getting a range of items:
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
key name |
Key name identifying a list. |
from |
Identifies the first value to get by index position |
to |
Identifies the last value to get by index position |
The example below returns two values from the "fruits"
list since the operation is set to retrieve all items in range starting from index position 0
to 1.
The output will look as shown below after the Codeless logic runs.