The template API provides endpoint to upload, download and find Golem templates (WASM files with associated metadata).
Method | Path | Request | Response |
GET | /v1/templates/{template_id} | - | Array of Template JSON |
Response format:
[
{
"versionedTemplateId": {
"rawTemplateId": "70ff8f69-e121-40ea-b59a-b17526f37a78",
"version": 0
},
"userTemplateId": {
"versionedComponentId": {
"rawTemplateId": "70ff8f69-e121-40ea-b59a-b17526f37a78",
"version": 0
}
},
"protectedTemplateId": {
"versionedComponentId": {
"rawTemplateId": "70ff8f69-e121-40ea-b59a-b17526f37a78",
"version": 0
}
},
"templateName": {
"value": "test-template-1"
},
"templateSize": 329006,
"metadata": {
"exports": [
{
"Function": {
"name": "run",
"parameters": [],
"results": []
}
}
],
"producers": [
{
"fields": [
{
"name": "language",
"values": [
{
"name": "Rust",
"version": ""
}
]
},
{
"name": "processed-by",
"values": [
{
"name": "rustc",
"version": "1.71.0 (8ede3aae2 2023-07-12)"
},
{
"name": "clang",
"version": "15.0.6"
},
{
"name": "wit-component",
"version": "0.14.0"
},
{
"name": "wit-bindgen-rust",
"version": "0.11.0"
}
]
}
]
},
},
"projectId": "866e1f4a-cf1a-40aa-ad8f-77e33294e999"
},
...
}
Explanation
Each template can have multiple versions. Every time a new WASM is uploaded for a given template id, that creates a new version.
This endpoint returns a list of all versions for the template id provided as part of the URL. Each element of the response describes a single version of a template, but does not contain the binary (WASM) itself:
versionedTemplateId
associates a specific version with the template iduserTemplateId
and protectedTemplateId
are implementation details, not used elsewhere on the public API templateName
is the human-readable name of the templatetemplateSize
is the WASM binary’s size in bytesmetadata
contains information extracted from the WASM itself:Example cURL:
curl 'https://release.api.golem.cloud/v1/templates/70ff8f69-e121-40ea-b59a-b17526f37a78'
-H 'Authorization: Bearer 03f17466-202f-43ac-86cc-52e6c6a42d2d'
Method | Path | Request | Response |
PUT | /v1/templates/{template_id}/upload | application/octet-stream | Template JSON |
Request format
The request body contains the new version of the template as a binary WASM stream
Response format
The response is a JSON containing the updated template metadata as described in above in the get metadata endpoint’s description.
Example cURL:
curl -X PUT
'https://release.api.golem.cloud/v1/templates/70ff8f69-e121-40ea-b59a-b17526f37a78/upload'
-H 'Content-Type: application/octet-stream'
--data-binary @new-template.wasm
-H 'Authorization: Bearer 03f17466-202f-43ac-86cc-52e6c6a42d2d'
Method | Path | Request | Response |
GET | /v1/templates?projectId={projectId} | - | Array of Template JSON |
Response format:
Same array of Template
JSON as described above at the get all template metadata by id endpoint.
Explanation
Gets all templates belonging to the given project
Example cURL:
curl 'https://release.api.golem.cloud/v1/templates?projectId=866e1f4a-cf1a-40aa-ad8f-77e33294e999'
-H 'Authorization: Bearer 03f17466-202f-43ac-86cc-52e6c6a42d2d'
Method | Path | Request | Response |
GET | /v1/templates?project-id={projectId}&template-name={templateName} | - | Array of Template JSON |
Response format:
Same array of Template
JSON as described above at the get all template metadata by id endpoint.
Explanation
Gets all templates belonging to the given project with a given name. Because the uniqueness of a template’s name is not enforced, the response may contain templates with different template ids.
Example cURL:
curl 'https://release.api.golem.cloud/v1/templates?project-id=866e1f4a-cf1a-40aa-ad8f-77e33294e999?template-name=test'
-H 'Authorization: Bearer 03f17466-202f-43ac-86cc-52e6c6a42d2d'
Method | Path | Request | Response |
POST | /v1/templates | multipart/form-data | Template JSON |
Request format
The request body is encoded as multipart/form-data
with the following fields:
field0
with content type application/json
containing a TemplateQuery
JSON (described below)template
with content type application/octet-stream
containing the WASMThe JSON passed in the field0
field has the following format:
{
"projectId": "866e1f4a-cf1a-40aa-ad8f-77e33294e999",
"componentName": "test-template"
}
The projectId
is optional, in case it is missing the default project is used.
Response format
The response is a JSON containing the updated template metadata as described in above in the get metadata endpoint’s description.
Example cURL:
curl -X POST
'https://release.api.golem.cloud/v1/templates'
-H 'Content-Type: multipart/form-data'
-F 'field0={"componentName": "test-template"}; type=application/json'
-F 'componentName=@new-template.wasm; type=application/octet-stream'
-H 'Authorization: Bearer 03f17466-202f-43ac-86cc-52e6c6a42d2d'
Method | Path | Request | Response |
GET | /v1/templates/{template_id}/download?version={version} | - | application/octet-stream WASM |
Response format:
Same array of Template
JSON as described above at the get all template metadata by id endpoint.
Explanation
Downloads a specific version of the template’s WASM.
Example cURL:
curl 'https://release.api.golem.cloud/v1/templates/70ff8f69-e121-40ea-b59a-b17526f37a78/download
-H 'Authorization: Bearer 03f17466-202f-43ac-86cc-52e6c6a42d2d'
Method | Path | Request | Response |
GET | /v1/templates/{template_id}/latest | - | JSON number |
Response format:
The latest version number of the template, as a JSON number.
Explanation
Gets the latest version of a template.
Example cURL:
curl 'https://release.api.golem.cloud/v1/templates/70ff8f69-e121-40ea-b59a-b17526f37a78/latest'
-H 'Authorization: Bearer 03f17466-202f-43ac-86cc-52e6c6a42d2d'
All template endpoints can return with the following errors:
Status | Body | Description |
400 | { "errors": ["error1", ...] } | Invalid request, returning with a list of issues detected in the request. |
401 | { "error": "..." } | Unauthorized |
403 | { "error": "..." } | Maximum number of templates exceeded |
404 | { "message": "..." } | Template not found |
409 | { "component_id": "..." } | Template already exists |
500 | { "error": "..." } | Internal server error |