Sorting

Order response by creation date

Query a collection and order the results ascending by creation date.

GET
// Define query
var query = {
  "sorting": {
    "meta.createdAt": "ASC"
  }
};

// Stringify and URI Encode the Object
query = encodeURIComponent(JSON.stringify(query));

// Submit the query
window.fetch(`https://api.cmft.io/v1/<repo>/<collection>?query=${query}`, {
  method: 'get',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': '<apiKey>'
  }
})
  .then(function (response) { return response.json() })
  .then(function (data) {
    console.log(data)
  })

Order response by field value

Query the documents endpoint and order the results ascending by title.

Sample Request

GET https://api.cmft.io/v1/demo/documents?sorting[fields.title]=ASC&key=8MIO994Ley6bqyAlQAHqutiDh4g5Heck

Query Parameters

Name
Type
Description

key

string

API Key

sorting

object

Using multiple sorting parameters

You can apply multiple order parameters:

Sample Request

GET https://api.cmft.io/v1/demo/documents?sorting[fields.title]=ASC&sorting[meta.createdAt]=DESC&key=8MIO994Ley6bqyAlQAHqutiDh4g5Heck

Query Parameters

Name
Type
Description

key

string

API Key

sorting

object

Last updated