Get a story with assets
Read the files and links attached to a story, with fragments on FileAsset and URLAsset to get their download addresses and thumbnails.
Once you can get a story, the next step is to read its assets: the files, links and other objects attached to the current version. Stories, spaces and users describes what an asset is.
List the assets
Assets belong to the version. Ask for __typename on each one: it tells you what kind of asset it is.
query {
story(slug: 123) {
id
slug
version {
title
assets {
__typename
uuid
created
}
}
user {
name
}
}
}
__typename is FileAsset for an uploaded file, URLAsset for a link, and so on.
Read the fields of each type
Each asset type has its own fields. To read them, use an inline fragment for each type, the same way ... on Story does with node in Get a story:
query {
story(slug: 123) {
id
slug
version {
title
assets {
__typename
uuid
created
... on FileAsset {
embed
filename
downloadUrl
}
... on URLAsset {
embed
url
}
}
}
user {
name
}
}
}
The response, for a story with one image attached:
{
"data": {
"story": {
"id": "U3Rvcnk6MTIz",
"slug": 123,
"version": {
"title": "Hello world!",
"assets": [
{
"__typename": "FileAsset",
"uuid": "ef022818-88dc-432c-975d-74bc4575a251",
"created": "2020-03-26T10:21:10.067170Z",
"embed": {
"url": "https://your-platform-name.elium.com/api/story/asset/12/download/13/image001.jpg",
"thumbnail_url": "https://your-platform-name.elium.com/api/story/asset/12/thumbnail/13?fallback=false&tclass=xxlarge",
"image_url": "https://your-platform-name.elium.com/api/story/asset/12/thumbnail/13?fallback=false&tclass=xxlarge",
"cover_url": "https://your-platform-name.elium.com/api/story/asset/12/thumbnail/13?fallback=false&tclass=cover",
"filename": "image001.jpg",
"digest": "b6b6783c4b5445249b30e17d969515a1f5d8b82bf05a1c5ca97211e244ad9a1a",
"filesize": 53223,
"mimetype": "image/jpeg"
},
"filename": "image001.jpg",
"downloadUrl": "https://your-platform-name.elium.com/api/story/asset/12/download/13/image001.jpg"
}
]
},
"user": {
"name": "John Doe"
}
}
}
}
embed gives the thumbnails and metadata of a FileAsset, and the extract (a structured summary of the page) of a URLAsset. Downloading a file needs the same authentication as the API.