Noma

List Assets

List Assets

Returns a paginated list of assets in the project library. Each item uses the same shape as Get an Asset.

The HTTP path is /api/files (the word “files” in the path is the REST resource name for assets).

Request

GET /api/files HTTP/1.1
Host: app.nomacms.com
project-id: <project-uuid>
Authorization: Bearer <api-token>
Accept: application/json

Requires the read ability on the token.

Query parameters

ParamDescription
searchOptional. Matches filename, original filename, or MIME type (substring match, case-sensitive per database collation).
typeOptional. One of image, video, audio, or document. Filters by file extension groups configured on the server (for example images include jpg, png, webp, and similar).
paginateOptional. Page size. Defaults to 25, minimum 1, maximum 100.

Results are ordered by created_at descending (newest first).

Response (200)

JSON object with Laravel-style pagination:

FieldTypeDescription
dataarrayAsset objects (see below)
linksobjectPagination links (first, last, prev, next)
metaobjectPagination metadata (current_page, per_page, total, and so on)

Each element of data includes:

FieldTypeDescription
uuidstringAsset UUID
filenamestringOriginal filename (as stored on upload)
mime_typestringMIME type (images may be normalized, for example to image/webp after optimization)
sizestringHuman-readable size (for example 1.0 MB)
urlstringPublic URL for the primary file
original_urlstring | nullURL for the original upload when an optimized variant exists
thumbnail_urlstring | nullThumbnail URL when applicable
metadataobject | nullRelated metadata (for example alt_text, width, height for images) when loaded

Errors

StatusWhen
400Missing project-id or project cannot be resolved (see Authentication)
401Missing or invalid bearer token
403Token does not have read (or *)
404No project with that UUID
429Rate limited

Example

import { createClient } from "@nomacms/js-sdk"
 
const client = createClient({
  projectId: process.env.NOMA_PROJECT_ID!,
  apiKey: process.env.NOMA_API_KEY!,
})
 
const page = await client.assets.list({
  search: "hero",
  type: "image",
  paginate: 24,
})
 
console.log(page)
import axios from "axios"
 
async function main() {
  const { data } = await axios.get("https://app.nomacms.com/api/files", {
    headers: {
      "project-id": process.env.NOMA_PROJECT_ID!,
      Authorization: `Bearer ${process.env.NOMA_API_KEY}`,
      Accept: "application/json",
    },
    params: { search: "hero", type: "image", paginate: 24 },
  })
  console.log(data)
}
 
void main()
<?php
 
$query = http_build_query(['search' => 'hero', 'type' => 'image', 'paginate' => 24]);
$ch = curl_init('https://app.nomacms.com/api/files?' . $query);
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => [
        'project-id: ' . getenv('NOMA_PROJECT_ID'),
        'Authorization: Bearer ' . getenv('NOMA_API_KEY'),
        'Accept: application/json',
    ],
    CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);
curl -sS \
  -H "project-id: $NOMA_PROJECT_ID" \
  -H "Authorization: Bearer $NOMA_API_KEY" \
  -H "Accept: application/json" \
  "https://app.nomacms.com/api/files?search=hero&type=image&paginate=24"
package main
 
import (
	"io"
	"net/http"
	"os"
)
 
func main() {
	req, err := http.NewRequest("GET", "https://app.nomacms.com/api/files?search=hero&type=image&paginate=24", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("project-id", os.Getenv("NOMA_PROJECT_ID"))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("NOMA_API_KEY"))
	req.Header.Set("Accept", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	_, _ = io.Copy(os.Stdout, res.Body)
}
require "net/http"
require "uri"
 
uri = URI("https://app.nomacms.com/api/files")
uri.query = URI.encode_www_form("search" => "hero", "type" => "image", "paginate" => 24)
req = Net::HTTP::Get.new(uri)
req["project-id"] = ENV.fetch("NOMA_PROJECT_ID")
req["Authorization"] = "Bearer #{ENV.fetch('NOMA_API_KEY')}"
req["Accept"] = "application/json"
 
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  puts http.request(req).body
end
import os
import urllib.parse
import urllib.request
 
params = urllib.parse.urlencode({"search": "hero", "type": "image", "paginate": 24})
url = f"https://app.nomacms.com/api/files?{params}"
req = urllib.request.Request(
    url,
    headers={
        "project-id": os.environ["NOMA_PROJECT_ID"],
        "Authorization": f"Bearer {os.environ['NOMA_API_KEY']}",
        "Accept": "application/json",
    },
)
with urllib.request.urlopen(req) as res:
    print(res.read().decode())
  • Authentication - Headers and abilities
  • Get an Asset - One asset by id or filename
  • Upload an Asset - Create assets
  • JavaScript SDK - assets.list

Search documentation

Find guides and reference pages