Get all assets or asset folder through API

Hey there!

I just wanted to ask if there is a way to get all assets stored by cockpit or at least all files in a folder through the API. All I found in the docs is that you can get individual assets through their id.

Thanks in advance!

Hey :wave:

There is no official api (yet). But you can accomplish that by creating a custom api endpoint.

Greets
Artur

Hey @artur

Has there been any progress on this? I’d love to be able to retreive all assets from a folder with pagination in order to use the asset management for a large gallery.

I can see a POST request at my.cockpit.host/assets which goes to my.cockpit.host/assets/assets and has a JSON payload like

{
  "options": {
    "limit":15,
    "skip":0,
    "sort":{
      "_created":-1
    }
  },
  "folder":null
}

This is basically exactly whats needed. But unfortunately, it’s not possible to make a request to that endpoint using an API token - I guess because it’s not utilizing the /api/ middleware(?)