> For the complete documentation index, see [llms.txt](https://docs.imerit.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.imerit.net/sdk/sdk-documentation/utility-functions/list_storage_files.md).

# list\_storage\_files

`imerit_ango.sdk.SDK.`

## list\_storage\_files(storage\_id, bucket\_name, path, get\_signed\_urls, retry\_on\_slow\_down, recursive, page\_token, page\_size)

List files in a connected storage. By default, the method lists all files under the given path, including files in subfolders. To browse one folder at a time as in the [File Explorer](https://docs.imerit.net/data/importing-assets/file-explorer.md), pass `recursive=False`.

### Parameters

* **storage\_id:** string
  * The ID of the connected storage. Use [get\_storages](https://docs.imerit.net/sdk/sdk-documentation/organization-level-sdk-functions/get_storages.md) to find it.
* **bucket\_name:** string
  * The storage bucket name, or the container name for Azure Blob Storage.
* **path:** string, *default ""*
  * A path inside the bucket or container, such as `"project-1/images/"`. Leave it empty to start at the root. In folder mode, the trailing slash is optional.
* **get\_signed\_urls:** bool, *optional*
  * Request temporary download URLs. Defaults to `True` for recursive listings and `False` for folder pages.
* **retry\_on\_slow\_down:** bool, *default True*
  * Retry when an S3 listing is throttled.
* **recursive:** bool, *default True*
  * Pass `False` to list only the files and subfolders directly inside the requested folder, one page at a time.
* **page\_token:** string, *optional*
  * Pass the previous response's `data.nextPageToken` to fetch the next page. Omit this parameter for the first page. Requires `recursive=False`.
* **page\_size:** int, *default 1000*
  * Maximum number of files and folders combined per page, from 1 to 1000. Requires `recursive=False`.

A [service account key](https://docs.imerit.net/core-concepts/organizations/service-accounts.md) needs the `storages:read` scope.

### Response

For a recursive listing, `data.files` is a list of signed download URLs, or a list of paths if you pass `get_signed_urls=False`.

For a folder page, `data` contains these fields.

* `files` contains entries with a `path` and, when requested, a signed download `url`.
* `folders` contains subfolder paths ending in `/`. A folder can appear on multiple pages.
* `nextPageToken` is the token to pass as `page_token` for the next page, or `None` (`null` in JSON) after the last page. A page can contain fewer entries than requested or be empty, so continue until this value is `None`.

### Browse a folder page by page

{% tabs %}
{% tab title="python" %}

```python
import os

from imerit_ango.sdk import SDK

sdk = SDK(api_key=os.environ["ANGO_API_KEY"])
page_token = None

while True:
    page = sdk.list_storage_files(
        storage_id=os.environ["STORAGE_ID"],
        bucket_name="ango-datasets",
        path="project-1/images/",
        recursive=False,
        page_size=100,
        page_token=page_token,
    )["data"]

    for folder in page["folders"]:
        print("Folder:", folder)
    for file in page["files"]:
        print("File:", file["path"])

    page_token = page["nextPageToken"]
    if page_token is None:
        break
```

{% endtab %}

{% tab title="curl" %}

```bash
curl --get "https://imeritapi.ango.ai/v2/storages/${STORAGE_ID}/files" \
  --header "apikey: ${ANGO_API_KEY}" \
  --data-urlencode "bucketName=ango-datasets" \
  --data-urlencode "path=project-1/images/" \
  --data-urlencode "recursive=false" \
  --data-urlencode "pageSize=100"
```

For the next page, add `--data-urlencode "pageToken=${NEXT_PAGE_TOKEN}"` with the value of `data.nextPageToken`.
{% endtab %}
{% endtabs %}

To list every file under the same path in a single response, omit the pagination arguments and leave `recursive` at its default.

{% hint style="info" %}
**See also**

[Signed storage URLs](https://docs.imerit.net/sdk/sdk-documentation/utility-functions/signed-storage-urls.md)
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.imerit.net/sdk/sdk-documentation/utility-functions/list_storage_files.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
