Single Documents
Basic document query
Demonstrates how to query a single document.
Query by Document ID
window.fetch('https://api.cmft.io/v1/<repo>/documents/<documentID>', {
method: 'get',
headers: {
'Content-Type': 'application/json',
'Authorization': '<apiKey>'
}
})
.then(function (response) { return response.json() })
.then(function (data) {
console.log(data)
})curl 'https://api.cmft.io/v1/<repo>/documents/<documentID>' \
-H 'Authorization: <apiKey>'https://api.cmft.io/v1/<repo>/documents/<documentID>?key=<apiKey>Query by Document Alias
You can create an alias for a single document by linking it in the Content Tree. Once an alias is created, it is possible to switch out the document that's connected to that alias.
window.fetch('https://api.cmft.io/v1/<repo>/alias/<myAliasName>', {
method: 'get',
headers: {
'Content-Type': 'application/json',
'Authorization': '<apiKey>'
}
})
.then(function (response) { return response.json() })
.then(function (data) {
console.log(data)
})curl 'https://api.cmft.io/v1/<repo>/alias/<myAliasName>' \
-H 'Authorization: <apiKey>'https://api.cmft.io/v1/<repo>/alias/<myAliasName>?key=<apiKey>Sample Request by ID
GET https://api.cmft.io/v1/demo/documents/968390655497867264?key=8MIO994Ley6bqyAlQAHqutiDh4g5Heck
Path Parameters
key
string
API Key
Including Assets for Documents
When querying documents, add embedAssets=true as URL parameter or as a query option to include assets by default, within a documents fields.
This eliminates the need to perform single asset queries and reduces the number of API calls.
Sample Request with Assets included
GET https://api.cmft.io/v1/demo/documents/968390655497867264?embedAssets=true&key=8MIO994Ley6bqyAlQAHqutiDh4g5Heck
Path Parameters
embedAssets
boolean
Truthy if assets should be included
key
string
API Key
Response Shaping: Document query with reduced fields
Let's say we need a document, but not all of its content. In this query example we're going to request a document only with the fields title, text and image.
To learn more about defined fields, take a look at the fields query reference page.
Sample Request
GET https://api.cmft.io/v1/demo/documents/968390655497867264?fields=fields(title,text,images)&key=8MIO994Ley6bqyAlQAHqutiDh4g5Heck
Path Parameters
fields
string
The fields that should be returned by the API
key
string
API Key
Document query with localisation
Example for requesting a document in one specific language (German). This will return all fields that have translation enabled and completed, in German.
Last updated