> For the complete documentation index, see [llms.txt](https://docs.coldstack.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coldstack.io/http-api-compatible-with-amazon-s3/api-reference/bucket/listobjects.md).

# ListObjects/ListObjectsV2

Returns a list of objects in a bucket.

When issuing, pagination is used; in one request, you can get a list of no longer than 1000 objects. If there are more objects, then it is necessary to execute several queries in a row.

**Note**

This method has two versions.

* `listObjectsV2` - up-to-date version, more convenient to use.
* `listObjectsV1` - previous version.

To call both methods, the same is used `URL`, but it differs in the query parameter. To invoke `listObjectsV2`, use the parameter `list-type=2`.

### listObjectsV2 <a href="#listobjectsv2" id="listobjectsv2"></a>

#### Request <a href="#requestv2" id="requestv2"></a>

```
GET /{bucket}?list-type=2&continuation-token=ContinuationToken&delimiter=Delimiter&encoding-type=EncodingType&max-keys=MaxKeys&prefix=Prefix&start-after=StartAfter HTTP/1.1
```

**Path parameters**

| Parameter | Description  |
| --------- | ------------ |
| `bucket`  | Bucket name. |

**Query parameters**

All parameters listed in the table are optional.

| Parameter            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `continuation-token` | <p>Used to get the next part of the list if all the results do not fit into one answer.<br>To get the next part of the list, use the value <code>NextContinuationToken</code>from the previous answer.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `delimiter`          | <p>Separator character.<br><br>If specified, Object Storage treats the key as a file path, where directories are separated by a character <code>delimiter</code>. In response to the request, the user will see a list of files and directories in the bucket. Files will be displayed in items <code>Contents</code>, and directories in items <code>CommonPrefixes</code>.<br><br>If a parameter is also specified in the request <code>prefix</code>, then Object Storage will return a list of files and directories in the directory <code>prefix</code> .</p>                                                                                                                                                                                                                                               |
| `encoding-type`      | <p>Server response encoding.<br><br>Object Storage, at the request of the client, can encode the response in the required form.<br><br>Possible values: <code>url</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `max-keys`           | <p>The maximum number of items in a response.<br><br>By default, Object Storage yields no more than 1000 items <code>Contents</code>and <code>CommonPrefixes</code>. This parameter should be used if you need to get less than 1000 items in one response.<br><br>If more keys fall under the selection criteria than fit in the search results, then the answer contains <code>\<IsTruncated>true\</IsTruncated></code>.<br><br>To get all the elements of the issue, if there are more of them <code>max-keys</code>, it is necessary to perform several consecutive requests to Object Storage with a parameter <code>continuation-token</code>, where for each request <code>continuation-token</code>is equal to the value of the element <code>NextContinuationToken</code>from the previous response.</p> |
| `prefix`             | <p>The string that the key should start with.<br><br>Object Storage will only select keys that start with <code>prefix</code>.<br><br>It can be used simultaneously with the parameter <code>delimiter</code>. In this case, the output logic is determined by the parameter <code>delimiter</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `start-after`        | The key to start the listing with.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

**Headings**

Use only [generic headers](/http-api-compatible-with-amazon-s3/api-reference/common-request-headers.md) in your request .

#### Response <a href="#responsev2" id="responsev2"></a>

**Headings**

The response can only contain [general headers](/http-api-compatible-with-amazon-s3/api-reference/common-response-headers.md) .

**Response codes**

For a list of possible answers, see the [Answers](/http-api-compatible-with-amazon-s3/api-reference/answers.md) section .

The successful response contains additional data in XML format, the schema of which is described below.

**Data schema**

```markup
<?xml version="1.0" encoding="UTF-8"?>
<ListBucketResult>
   <IsTruncated>boolean</IsTruncated>
   <Contents>
      <ETag>string</ETag>
      <Key>string</Key>
      <LastModified>timestamp</LastModified>
      <Size>integer</Size>
      <StorageClass>string</StorageClass>
   </Contents>
   ...
   <Name>string</Name>
   <Prefix>string</Prefix>
   <Delimiter>string</Delimiter>
   <MaxKeys>integer</MaxKeys>
   <CommonPrefixes>
      <Prefix>string</Prefix>
   </CommonPrefixes>
   ...
   <EncodingType>string</EncodingType>
   <KeyCount>integer</KeyCount>
   <ContinuationToken>string</ContinuationToken>
   <NextContinuationToken>string</NextContinuationToken>
   <StartAfter>string</StartAfter>
</ListBucketResult>
```

| Element                 | Description                                                                                                                                                                                                                                                                                                              |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ListBucketResult`      | Root element.                                                                                                                                                                                                                                                                                                            |
| `IsTruncated`           | <p>A flag indicating whether all results were returned in this response.<br><br><code>True</code>- everything. <code>False</code>- Not all.<br><br>Path: <code>/ListBucketResult/IsTruncated</code>.</p>                                                                                                                 |
| `Contents`              | <p>Description of the object.<br><br>The response will contain as many elements <code>Contents</code>as the keys match the request conditions.<br><br>Path: <code>/ListBucketResult/Contents</code>.</p>                                                                                                                 |
| `ETag`                  | <p>MD5 hash of the object. Metadata is not included in the hash calculation.<br><br>Path: <code>/ListBucketResult/Contents/ETag</code>.</p>                                                                                                                                                                              |
| `Key`                   | <p>Object key.<br><br>Path: <code>/ListBucketResult/Contents/Key</code>.</p>                                                                                                                                                                                                                                             |
| `LastModified`          | <p>The date and time the object was last modified.<br><br>Path: <code>/ListBucketResult/Contents/LastModified</code>.</p>                                                                                                                                                                                                |
| `Size`                  | <p>The size of the object in bytes.<br><br>Path: <code>/ListBucketResult/Contents/Size</code>.</p>                                                                                                                                                                                                                       |
| `StorageClass`          | <p>Object storage class: <code>STANDARD</code>or <code>COLD</code>.<br><br>Path: <code>/ListBucketResult/Contents/StorageClass</code>.</p>                                                                                                                                                                               |
| `Name`                  | <p>Bucket name.<br><br>Path: <code>/ListBucketResult/Name</code>.</p>                                                                                                                                                                                                                                                    |
| `Prefix`                | <p>The value of the query parameter <code>prefix</code>.<br><br>Path: <code>/ListBucketResult/Prefix</code>.</p>                                                                                                                                                                                                         |
| `Delimiter`             | <p>The value of the query parameter <code>delimiter</code>.<br><br>Path: <code>/ListBucketResult/Delimiter</code>.</p>                                                                                                                                                                                                   |
| `MaxKeys`               | <p>The value of the query parameter <code>max-keys</code>.<br><br>Path: <code>/ListBucketResult/MaxKeys</code>.</p>                                                                                                                                                                                                      |
| `CommonPrefixes`        | <p>The part of the key name that is determined when processing query parameters <code>delimiter</code>and <code>prefix</code>.<br><br>Path: <code>/ListBucketResult/CommonPrefixes</code>.</p>                                                                                                                           |
| `EncodingType`          | <p>The encoding in which Object Storage represents the key in the XML response.<br><br>Appears if the client passed a parameter when requested <code>encoding-type</code>.<br><br>Path: <code>/ListBucketResult/EncodingType</code>.</p>                                                                                 |
| `KeyCount`              | <p>The number of keys returned by the query.<br>The number of keys will always be less than or equal <code>MaxKeys</code>.<br><br>Path: <code>/ContinuationToken/KeyCount</code>.</p>                                                                                                                                    |
| `ContinuationToken`     | <p>The value of the query parameter <code>continuation-token</code>.<br><br>Path: <code>/ContinuationToken/ContinuationToken</code>.</p>                                                                                                                                                                                 |
| `NextContinuationToken` | <p>The value that must be substituted into the query parameter <code>continuation-token</code>to get the next part of the list, if the entire list does not fit into the current response.<br>Refundable only if <code>IsTruncated = true</code>.<br><br>Path: <code>/ListBucketResult/NextContinuationToken</code>.</p> |
| `StartAfter`            | <p>The value of the query parameter <code>start-after</code>.<br><br>Path: <code>/ListBucketResult/StartAfter</code>.</p>                                                                                                                                                                                                |

### ListObjects <a href="#listobjectsv1" id="listobjectsv1"></a>

#### Request <a href="#requestv1" id="requestv1"></a>

```
GET /{bucket}?delimiter=Delimiter&encoding-type=EncodingType&marker=Marker&max-keys=MaxKeys&prefix=Prefix HTTP/1.1
```

**Path parameters**

| Parameter | Description  |
| --------- | ------------ |
| `bucket`  | Bucket name. |

**Query parameters**

All parameters listed in the table are optional.

| Parameter       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `delimiter`     | <p>Separator character.<br><br>If specified, Object Storage treats the key as a file path, where directories are separated by a character <code>delimiter</code>. In response to the request, the user will see a list of files and directories in the bucket. Files will be displayed in items <code>Contents</code>, and directories in items <code>CommonPrefixes</code>.<br><br>If a parameter is also specified in the request <code>prefix</code>, then Object Storage will return a list of files and directories in the directory <code>prefix</code> .</p>                                                                                                                                                                                                            |
| `encoding-type` | <p>Server response encoding.<br><br>Object Storage, at the request of the client, can encode the response in the required form.<br><br>Possible values: <code>url</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `marker`        | <p>The key from which the issuance will begin.<br><br>In the resulting output, Object Storage will leave the keys starting from the next one after <code>marker</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `max-keys`      | <p>The maximum number of items in a response.<br><br>By default, Object Storage yields no more than 1000 items <code>Contents</code>and <code>CommonPrefixes</code>. This parameter should be used if you need to get less than 1000 items in one response.<br><br>If more keys fall under the selection criteria than fit in the search results, then the answer contains <code>\<IsTruncated>true\</IsTruncated></code>.<br><br>To get all the elements of the issue, if there are more of them <code>max-keys</code>, it is necessary to perform several consecutive requests to Object Storage with a parameter <code>marker</code>, where for each request <code>marker</code>is equal to the value of the element <code>NextMarker</code>from the previous response.</p> |
| `prefix`        | <p>The string that the key should start with.<br><br>Object Storage will only select keys that start with <code>prefix</code>.<br><br>It can be used simultaneously with the parameter <code>delimiter</code>. In this case, the output logic is determined by the parameter <code>delimiter</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

**Headings**

Use only [generic headers](/http-api-compatible-with-amazon-s3/api-reference/common-request-headers.md) in your request .

#### Response <a href="#responsev1" id="responsev1"></a>

**Headings**

The response can only contain [general headers](/http-api-compatible-with-amazon-s3/api-reference/common-response-headers.md) .

**Response codes**

For a list of possible answers, see the [Answers](/http-api-compatible-with-amazon-s3/api-reference/answers.md) section .

The successful response contains additional data in XML format, the schema of which is described below.

**Data schema**

```
<?xml version="1.0" encoding="UTF-8"?>
<ListBucketResult>
   <IsTruncated>boolean</IsTruncated>
   <Marker>string</Marker>
   <NextMarker>string</NextMarker>
   <Contents>
      <ETag>string</ETag>
      <Key>string</Key>
      <LastModified>timestamp</LastModified>
      <Size>integer</Size>
      <StorageClass>string</StorageClass>
   </Contents>
   ...
   <Name>string</Name>
   <Prefix>string</Prefix>
   <Delimiter>string</Delimiter>
   <MaxKeys>integer</MaxKeys>
   <CommonPrefixes>
      <Prefix>string</Prefix>
   </CommonPrefixes>
   ...
   <EncodingType>string</EncodingType>
</ListBucketResult>
```

| Element            | Description                                                                                                                                                                                                                                |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ListBucketResult` | Root element.                                                                                                                                                                                                                              |
| `IsTruncated`      | <p>A flag indicating whether all results were returned in this response.<br><br><code>True</code>- everything. <code>False</code>- Not all.<br><br>Path: <code>/ListBucketResult/IsTruncated</code>.</p>                                   |
| `Marker`           | <p>The value of the query parameter <code>marker</code>.<br><br>Path: <code>/ListBucketResult/Marker</code>.</p>                                                                                                                           |
| `NextMarker`       | <p>The value that must be substituted into the query parameter <code>marker</code>to get the next part of the list, if the entire list does not fit into the current response.<br><br>Path: <code>/ListBucketResult/NextMarker</code>.</p> |
| `Contents`         | <p>Description of the object.<br><br>The response will contain as many elements <code>Contents</code>as the keys match the request conditions.<br><br>Path: <code>/ListBucketResult/Contents</code>.</p>                                   |
| `ETag`             | <p>MD5 hash of the object. Metadata is not included in the hash calculation.<br><br>Path: <code>/ListBucketResult/Contents/ETag</code>.</p>                                                                                                |
| `Key`              | <p>Object key.<br><br>Path: <code>/ListBucketResult/Contents/Key</code>.</p>                                                                                                                                                               |
| `LastModified`     | <p>The date and time the object was last modified.<br><br>Path: <code>/ListBucketResult/Contents/LastModified</code>.</p>                                                                                                                  |
| `Size`             | <p>The size of the object in bytes.<br><br>Path: <code>/ListBucketResult/Contents/Size</code>.</p>                                                                                                                                         |
| `StorageClass`     | <p>Object storage class: <code>STANDARD</code>or <code>COLD</code>.<br><br>Path: <code>/ListBucketResult/Contents/StorageClass</code>.</p>                                                                                                 |
| `Name`             | <p>Bucket name.<br><br>Path: <code>/ListBucketResult/Name</code>.</p>                                                                                                                                                                      |
| `Prefix`           | <p>The value of the query parameter <code>prefix</code>.<br><br>Path: <code>/ListBucketResult/Prefix</code>.</p>                                                                                                                           |
| `Delimiter`        | <p>The value of the query parameter <code>delimiter</code>.<br><br>Path: <code>/ListBucketResult/Delimiter</code>.</p>                                                                                                                     |
| `MaxKeys`          | <p>The value of the query parameter <code>max-keys</code>.<br><br>Path: <code>/ListBucketResult/MaxKeys</code>.</p>                                                                                                                        |
| `CommonPrefixes`   | <p>The part of the key name that is determined when processing query parameters <code>delimiter</code>and <code>prefix</code>.<br><br>Path: <code>/ListBucketResult/CommonPrefixes</code>.</p>                                             |
| `EncodingType`     | <p>The encoding in which Object Storage represents the key in the XML response.<br><br>Appears if the client passed a parameter when requested <code>encoding-type</code>.<br><br>Path: <code>/ListBucketResult/EncodingType</code>.</p>   |
