Rendering modified templates
In this section, we will build a valid request data object and send it for processing to generate our image.
Before we start
- Make sure that you are comfortable with how modifications work
- You already created a template (using web UI) and know it's template id
Endpoint
You will need to send a POST request to the endpoint:
which should be a long-lived request. It will take up-to 60 seconds to fetch all required data and render the template programically. You should receive a response with a 200 status code.
Create a payload
Our API will use TEMPLATE_ID
and MODIFICATIONS=List[Modification]
to construct a valid payload:
payload.json
:
Example request
Putting everything mentioned above together, here are some request examples:
import requests
ENDPOINT = f"{BASE_URL}/renders/create/{TEMPLATE_ID}"
data = {
"modifications": {
"name": "text_1",
"attribute": "text",
"value": "New text value"
}
}
headers = {"Authorization": "Bearer API_KEY"}
response = requests.post(ENDPOINT, data=data, headers=headers)
>>> print(response.status_code)
>>> 200
>>> print(response.json())
>>> {
"id": "773ed3f8-6288-4O1c-8bba-9182bf0e2bc5",
"download_url": "https://storage.cloud.google.com/screenshots-pro.appspot.com/exports/773ed3f8-6288-4O1c-8bba-9182bf0e2bc5.zip",
"status": "completed",
"created_ts": "2022-06-06T12:21:51.900752+00:00",
"started_ts": "2022-06-06T12:21:56.266743"
}
let endpoint = "{BASE_URL}/renders/create/{TEMPLATE_ID}"
let token = "TOKEN"
let modifications = []
fetch(endpoint, {
method: 'POST',
headers: {
'Bearer': token,
},
body: modifications,
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
.catch((error) => {
console.error('Error:', error);
});
Response Model
You should expect the following response when using our API:
Attribute | Type | Description |
---|---|---|
id | UUID |
Id of the render request |
status | string |
Status of your render |
download_url | URL |
Download path to the rendered content |
started_ts | datetime |
Datetime the rendering started |
created_ts | datetime |
Datetime of acknowledging your request |