List object keys from the object store layer
Note
Currently, the blob
service supports REST API versions v1
and v2
. Version v1
should be used to access versioned, index and stream (if the stream payload is larger than 1MB) layers. Version v2
should be used to access the object store layer. Always pick the proper API version from API Lookup to ensure you get back the correct API version response. For instructions, see the API Lookup Developer's Guide.
You can list all uploaded object keys
by making a request to blob
v2
REST APIs.
The typical flow for listing keys consists of the following steps:
- Obtain an authorization token.
- Get API base URLs.
- List keys.
Obtain an authorization token
Obtain an authorization token for your HTTP requests. For instructions, see the Identity & Access Management Guide.
Get API base URLs
Use the API Lookup service to get the API endpoints for the blob
v2
APIs for the catalog you want to get data from. For instructions, see the API Lookup Developer's Guide.
List keys
Use the following request to list object keys.
GET /<Base path for the blob API from the API Lookup Service>/layers/<Layer ID>/keys HTTP/1.1
Host: <Hostname for the blob API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
Cache-Control: no-cache
The response specifies a list of keys, structured in a way that represents a virtual file system. In this virtual file system, common prefixes are analogous to folders and objects to files.
{
"pageToken": "string",
"items": [
{
"name": "file1.txt",
"size": 1024,
"lastModified": "2019-12-10T12:20:54Z",
"type": "object"
},
{
"name": "example",
"type": "commonPrefix"
},
]
}
If the response contains a pageToken
, specify a request including this value in order to access the remaining keys.
GET /<Base path for the blob API from the API Lookup Service>/layers/<Layer ID>/keys?pageToken=<Page Token> HTTP/1.1
Host: <Hostname for the blob API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
Cache-Control: no-cache
A returned item of type
commonPrefix
means that one or more keys exist for this prefix, to access those keys, request using the name
field as parent
argument.
GET /<Base path for the blob API from the API Lookup Service>/layers/<Layer ID>/keys?parent=<Common Prefix Name> HTTP/1.1
Host: <Hostname for the blob API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
Cache-Control: no-cache
If you want to list all keys of type
object
, ignoring commonPrefix
, do a request with argument deep=true
.
GET /<Base path for the blob API from the API Lookup Service>/layers/<Layer ID>/keys?deep=true HTTP/1.1
Host: <Hostname for the blob API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
Cache-Control: no-cache
Note
We recommend that your application includes retry logic for handling HTTP 5xx errors. Use exponential backoff in the retry logic.