Skip to content

Get Key Names

Description

This operation retrieves key names from a specific store type. Key names are retrieved with paging, the default page size is 10,000 items. The operation supports filtering, where the returned key names match the specified pattern.

Method

GET

Endpoint URL

Important

Make sure to replace xxxx in the domain name in the request specification below to the one assigned to your application.

https://xxxx.backendless.app/api/hive/[hive-name]/[bucket-type]/keys?filterPattern=[pattern]&cursor=[cursor]&pageSize=[pageSize]

where:

Argument                Description
[hive-name] Name of a hive where the operation is performed.
[bucket-type] Designates the store type to iterate over the keys in. Must be one of the following values: key-value, list, set, sorted-set, map.
[pattern] Optional parameter. A pattern the returned key names must match. Supports the glob format for pattern expressions. If the parameter is not set, defaults to * (all keys).  You can specify a pattern with a prefix and/or suffix, for example: filterPattern=leaderboard1*_new_york.
It is not recommended to change the filterPattern value during the paging process, since you can retrieve inconsistent data and the cursor value may become invalid.
[cursor] Optional parameter. This is a special value used to retrieve additional key names in a paged data set. The value of the cursor is returned in the prior invocation of the operation. The cursor value should be used in conjunction with the pageSize parameter described below. To iterate through all keys in the store, start by setting the cursor to 0; By doing so, you instruct the operation to start the key names retrieval from the very beginning of the collection.
[pageSize] Optional parameter. Defaults to 5000. Identifies the number of key names to return in the response. The operation may return key names up to the number specified in the pageSize parameter.

Request Headers

None.

Request Body

None.

Response Body

A JSON object with the following structure:

{  
  "keys": [  
    "key_name_1",  
    "key_name_2"  
  ],  
  "cursor": "182"  
}

The cursor value of "0" in the response indicates that you have reached the end of the store and there are no keys left to return. In some cases you can get more keys than specified in the pageSize parameter.

Example

The example below may return up to six key names from the key-value store, since the pageSize parameter is set to 6.

curl --location --request GET "https://xxxx.backendless.app/api/hive/groceryStore/list/keys?filterPattern=*&cursor=0&pageSize=6"

where:

Argument                Description
groceryStore Name of a hive where the operation is performed.

Response

{  
    "keys": [  
     "fruits",  
     "vegetables",  
     "fish"  
    ],  
    "cursor": "185"  
}

Codeless Reference

general_api_get_key_names

where:

Argument                Description
hive name Name of a hive where the operation is performed.
type Storage type, can be one of the following: Key / Value, Sorted Set, Set, Map, List.
filter pattern A pattern to filter the keys with. Only the keys matching the pattern will be returned by the operation
page size Identifies the number of keys to return in the response. Operation may return up to the specified number of key names. Refer to the section above for more information.
cursor A value received in the response of a prior call of the same block. Refer to the section above for more information.

Returns an object containing key names and the cursor position.

Consider the following Key Value storage:

sample-key-value

The example below retrieves the key names from the key-value storage:

general_api_example_get_key_names
The output will look as shown below after the Codeless logic runs.
general_api_example_get_key_names_2