Basic asset query
Demonstrates the basic query for a single asset
.
JavaScript CURL URL
Copy window.fetch('https://api.cmft.io/v1/<repo>/assets/<assetID>', {
method: 'get',
headers: {
'Content-Type': 'application/json',
'Authorization': '<apiKey>'
}
})
.then(function (response) { return response.json() })
.then(function (data) {
console.log(data)
})
Copy curl 'https://api.cmft.io/v1/<repo>/assets/<assetID>' \
-H 'Authorization: <apiKey>'
Copy https://api.cmft.io/v1/<repo>/assets/<assetID>?key=<apiKey>
When querying documents, addembedAssets=true
as URL parameter or as a query option to include assets by default. This eliminates the need to perform single asset queries and reduces the number of API calls.
See example
Response Shaping: Asset query with reduced fields
Like documents, assets have fields which can be defined when making a query. In this example, we're going to query an asset just with its target URL.
To learn how to make a request with multiple fields, take a look at the fields query reference page .
JavaScript CURL URL
Copy window.fetch('https://api.cmft.io/v1/<repo>/assets/<assetID>?fields=fields(file(url))', {
method: 'get',
headers: {
'Content-Type': 'application/json',
'Authorization': '<apiKey>'
}
})
.then(function (response) { return response.json() })
.then(function (data) {
console.log(data)
})
Copy curl 'https://api.cmft.io/v1/<repo>/assets/<assetID>?fields=fields(file(url))' \
-H 'Authorization: <apiKey>'
Copy https://api.cmft.io/v1/<repo>/assets/<assetID>?key=<apiKey>&fields=fields(file(url))
Asset query with localisation
Example for requesting an asset in one specific language (German).
JavaScript CURL URL
Copy window.fetch('https://api.cmft.io/v1/<repo>/assets/<assetID>?locale=de', {
method: 'get',
headers: {
'Content-Type': 'application/json',
'Authorization': '<apiKey>'
}
})
.then(function (response) { return response.json() })
.then(function (data) {
console.log(data)
})
Copy curl 'https://api.cmft.io/v1/<repo>/assets/<assetID>?locale=de' \
-H 'Authorization: <apiKey>'
Copy https://api.cmft.io/v1/<repo>/assets/<assetID>?key=<apiKey>&locale=de