List Files

In this example we will get the list of all CSV files stored on the Kelvin Platform.

There are also options to filter the response for on source and on the exact filename.

API cURL Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
curl -X "POST" \
"https://<url.kelvin.ai>/api/v4/filestorage/list?pagination_type=cursor&page_size=20&direction=asc" \
-H "Authorization: Bearer <Your Current Token>" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"search": [
    "csv"
]
}'

The response will look like this;

API cURL Example Response
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
  "pagination": {
    "next_page": "W3siS2V5IjoiaWQiLCJWYWx1ZSI6IjlmZmQxNjU3LThhMjEtNDQzNS04MTY1LTQwYjcwNmU2ZTlhNyJ9XQ==",
    "previous_page": null
  },
  "data": [
    {
      "file_id": "0107549c-2069-4824-bc4f-30c7bc94172e",
      "file_name": "publisher-example (7).csv",
      "file_size": 603,
      "checksum": "7de7ebb64b70a2b89c6b25c9eb0e23372c8f902390a8448cc1aeb3da70e4a7e8",
      "created": "2024-03-06T16:20:59.416391Z",
      "source": "krn:user:ricardo.goncalves@kelvininc.com",
      "metadata": {}
    },
    {
      "file_id": "0adecb9e-1a50-4459-946d-cb73fc7efe98",
      "file_name": "publisher-example.csv",
      "file_size": 603,
      "checksum": "7de7ebb64b70a2b89c6b25c9eb0e23372c8f902390a8448cc1aeb3da70e4a7e8",
      "created": "2024-03-12T10:31:55.190712Z",
      "source": "krn:user:daniel.carvalho@kelvininc.com",
      "metadata": {
        "allowPlayback": true
      }
    }
  ]
}
API Client (Python) Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from kelvin.api.client import Client

# Login
client = Client(config={"url": "https://<url.kelvin.ai>", "username": "<your_username>"})
client.login(password="<your_password>")

# List Files in Forestorage
response = client.filestorage.list_files(data={
    'search': ['csv']
    })

print(response)

You will see the output like this;

API Client (Python) Example Response
1
data=[FileStorage(file_id='0107549c-2069-4824-bc4f-30c7bc94172e', file_name='publisher-example.csv', file_size=603, checksum='7de7ebb64b70a2b89c6b25c9eb0e23372c8f902390a8448cc1aeb3da70e4a7e8', source='krn:user:demo@kelvin.ai', created=datetime.datetime(2024, 3, 6, 16, 20, 59, 416391, tzinfo=datetime.timezone.utc), metadata={}), FileStorage(file_id='0adecb9e-1a50-4459-946d-cb73fc7efe98', file_name='streaming_data.csv', file_size=603, checksum='7de7ebb64b70a2b89c6b25c9eb0e23372c8f902390a8448cc1aeb3da70e4a7e8', source='krn:user:demo@kelvin.ai', created=datetime.datetime(2024, 3, 12, 10, 31, 55, 190712, tzinfo=datetime.timezone.utc), metadata={'allowPlayback': True})] pagination=PaginationCursor(next_page=None, previous_page=None)