Skip to content

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.

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 and indexTo parameters.

An empty JSON array if no elements exist in the specified list.

Request Headers

None.

Request Body

None.

Examples


Return All Values

The example below returns all values from the approvedTransactions list.

curl --location --request GET "https://xxxx.backendless.app/api/hive/transactions/list/approvedTransactions"

where:

Argument                Description
transactions Name of a hive where the operation is performed.
approvedTransactions Key name identifying a list.

Return Value By Index

The example below returns an item located at the index position 1 in the approvedTransactions list.

curl --location --request GET "https://xxxx.backendless.app/api/hive/transactions/list/approvedTransactions/1"

where:

Argument                Description
transactions Name of a hive where the operation is performed.
approvedTransactions Key name identifying a list.

Return Range Of Values

The example below returns four values from the transactions 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/transactions/list/approvedTransactions?from=2&to=5"

where:

Argument                Description
transactions Name of a hive where the operation is performed.
approvedTransactions Key name identifying a list.

Codeless Reference
list_api_get_key_items

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:

list_api_example_get_values_2

The example below returns all values from the list.

list_api_example_get_key_items

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.
list_api_get_key_item_by_index

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 list.

list_api_example_get_key_items_by_index

This operation also allows getting a range of items:

list_api_get_key_items_by_range

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 four values from the "transactions" list since the operation is set to retrieve all items in range starting from index position 2 to 5.

list_api_example_get_items_by_range