Choose your language:
    List all uploads
    Query parameters
    filter[type]  enum  Optional

    Type of upload

    filter[query]  string  Optional

    Textual query to match

    sort[direction]  enum  Optional

    Ordering direction by upload date

    page[offset]  integer  Optional

    Index of first record to fetch

    page[limit]  integer  Optional

    Number of records to fetch

    Returns
    Returns an array of upload objects.

    Examples

    Example code:
    const SiteClient = require('datocms-client').SiteClient;
    const client = new SiteClient('YOUR-API-TOKEN');
    client.uploads.all({
    'filter[type]': 'image',
    'filter[query]': 'foobar',
    'sort[direction]': 'desc',
    'page[offset]': 2,
    'page[limit]': 15
    })
    .then((uploads) => {
    uploads.forEach((upload) => {
    console.log(upload);
    });
    })
    .catch((error) => {
    console.error(error);
    });
    // if you want to fetch all the pages with just one call:
    client.uploads.all({
    'filter[type]': 'image',
    'filter[query]': 'foobar',
    'sort[direction]': 'desc'
    }, {
    allPages: true
    })
    .then((uploads) => {
    uploads.forEach((upload) => {
    console.log(upload);
    });
    })
    Returned output:
    > node example.js
    {
    "id": "666",
    "size": 444,
    "width": 30,
    "height": 30,
    "path": "/45/1496845848-digital-cats.jpg",
    "basename": "digital-cats",
    "filename": "digital-cats.jpg",
    "url": "https://www.datocms-assets.com/45/1496845848-digital-cats.jpg",
    "format": "jpg",
    "author": "Mark Smith",
    "copyright": "2020 DatoCMS",
    "notes": "Nyan the cat",
    "duration": 62,
    "frameRate": 30,
    "blurhash": "LEHV6nWB2yk8pyo0adR*.7kCMdnj",
    "muxPlaybackId": "a1B2c3D4e5F6g7H8i9",
    "muxMp4HighestRes": "high",
    "defaultFieldMetadata": {
    "en": {
    "title": "this is the default title",
    "alt": "this is the default alternate text",
    "customData": {
    "foo": "bar"
    },
    "focalPoint": {
    "x": 0.5,
    "y": 0.5
    }
    }
    },
    "isImage": true,
    "createdAt": "2020-04-21T07:57:11.124Z",
    "updatedAt": "2020-04-21T07:57:11.124Z",
    "mimeType": "image/jpeg",
    "tags": [
    "cats"
    ],
    "smartTags": [
    "robot-cats"
    ],
    "exifInfo": {
    "iso": 10000,
    "model": "ILCE-7",
    "flashMode": 16,
    "focalLength": 35,
    "exposureTime": 0.0166667
    },
    "colors": [
    "#f90a70",
    "#9abdd1",
    "#4b8e50"
    ]
    }