Composable Frontend 2.0 Learn more 

  • Products/
    Product Assets/
    Get all Files

    Get all Files

    This endpoint is for Administrator use only. Do not use this endpoint on your customer-facing frontends.

    GET Get all Files

    https://useast.api.elasticpath.com/v2/files
    

    Parameters

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API.

    Query parameters

    NameRequiredTypeDescription
    filterOptionalstringSpecifies the filter attributes. See Filtering.
    page[limit]OptionalintegerThe number of records per page. See Pagination.
    page[offset]OptionalintegerThe number of records to offset the results by. See Pagination.

    Filtering

    The following operators and attributes are available when filtering on this endpoint.

    AttributeTypeOperatorsExample
    file_namestringeq / likeeq(file_name, my_image.jpg)
    widthintegergt / ge / lt / legt(width,200)
    heightintegergt / ge / lt / lelt(height,500)
    DEPRECATED publicbooleaneqeq(public,true)
    file_sizeintegergt / ge / lt / lele(file_size,20953)

    Example string for filtering:

    const { MoltinClient } = require('@moltin/request')
    const client = new MoltinClient({
      client_id: 'X',
      client_secret: 'X'
    })
    //Clean up the file name
    const filterName = fileName.replace(/[^A-Z0-9]/gi, "_")
              .toLowerCase()
      client
      .get(`files/?filter=eq(file_name,${filterName}`);
      .then(product => {
        // Do something...
      })
      .catch(console.error)
    

    For more information, see Filtering files.

    Request Examples

    Curl

    curl -X GET https://useast.api.elasticpath.com/v2/files \
         -H "Authorization: Bearer XXXX" \
         -H "Content-Type: application/json" \
    

    JavaScript SDK

    await Moltin.Files.All();
    

    Response Example

    200 OK

    {
        "data": [
            {
                "type": "file",
                "id": "f8cf26b3-6d38-4275-937a-624a83994702",
                "link": {
                    "href": "https://files-eu.epusercontent.com/e8c53cb0-120d-4ea5-8941-ce74dec06038/f8cf26b3-6d38-4275-937a-624a83994702.png"
                },
                "file_name": "f6669358-85db-4367-9cde-1deb77acb5f4.png",
                "mime_type": "image/png",
                "file_size": 110041,
                "meta": {
                    "dimensions": {
                        "width": 1000,
                        "height": 1000
                    },
                    "timestamps": {
                        "created_at": "2018-03-13T13:45:21.673Z"
                    }
                },
                "links": {
                    "self": "https://useast.api.elasticpath.com/v2/files/f8cf26b3-6d38-4275-937a-624a83994702"
                }
            }
        ],
        "links": {
            "self": "https://useast.api.elasticpath.com/v2/files?page[offset]=0&page[limit]=100&filter=",
            "first": "https://useast.api.elasticpath.com/v2/files?page[offset]=0&page[limit]=100&filter=",
            "last": null
        },
        "meta": {
            "page": {
                "limit": 100,
                "offset": 0,
                "current": 1,
                "total": 1
            },
            "results": {
                "total": 1
            }
        }
    }
    
    Previous
    Files API Overview