Creating a publication
The simplest way to create a publication is to start with some basic metadata. You need a few basic metadata to create the publication.
Adding the metadata
mutation CreatePublication {
createPublicationFromMetadata(
namespaceId: "example-namespace",
isbn: "example-isbn",
input: {
title: "My First Publication",
author: {
name: "My Author"
}
format: "application/epub+zip",
lang: "en",
publisher: "My Publisher",
subjects: []
})
{
success
publication {
id
}
}
}
You can get a detailed view of every possible metadata field here.
If successful, you will get back a publication ID. You can then use to query information about the publication, for example using the following query:
query GetInfoAboutPublication {
publication(id: "my-new-publication-id") {
metadata {
title
author {
name
}
}
}
}
Uploading the content file
To upload the content file (typically the complete EPUB), you first need to get an upload URL from the server. On the publication
query GetUploadURL{
publication(id: "my-publication-id") {
uploadUrl(input: {
type: CONTENT,
mimeType: "application/epub+zip",
})
}
}
This would return the following JSON
{
"data": {
"publication": {
"uploadUrl": "https://storage.googleapis.com/...."
}
}
}
That URL can be used as the target for a PUT request to upload the file. For example, using curl, it would mean:
curl -X PUT -H 'Content-Type: application/epub+zip' --upload-file /path/to/your/isbn.epub https://storage.googleapis.com/....
Please note that this URL is temporary and does not require any authentication
Uploading the cover & sample
The same technique can be applied to upload a cover or sample by varying the type of the upload url you wish to get. You can also get multiple URLs in a single request:
query GetUploadURLs{
publication(id: "my-publication-id") {
coverUrl: uploadUrl(input: {
type: COVER,
mimeType: "image/jpeg",
})
sampleUrl: uploadUrl(input: {
type: SAMPLE,
mimeType: "application/epub+zip",
})
}
}