Sera API¶
An on-demand API can be used to submit page URLs to SERA for rendering, allowing you to integrate with tools and automatically render frequently updated sites via scripts or tools.
Prerequisite¶
- You must have an account on Nitrogen.
- Your target domain on which you want to call SERA on demand api must have been registered on Nitrogen.
- You must have a service account configured with Editor access. If not, you can refer this article for the same.
API Request & Response¶
Endpoint¶
Authorization¶
API Request Payload¶
The following is the request payload for the on demand render API
{
"pageGroupName": "Saree Category",
"urls": [
"https://www.example.com/saree/satin-sarees",
"https://www.example.com/saree/shimmer-sarees",
"https://www.example.com/saree/silk-sarees",
"https://www.example.com/saree/supernet-sarees",
"https://www.example.com/saree/tissue-sarees"
],
"viewport": "SERA_VIEWPORT_MOBILE",
"callbackUrl" : "https://www.example.com"
}
Example¶
curl --request PUT --location 'https://dash.n7.io/api/v2/sera/domains/{domain}/ondemand/render' \
--header 'Authorization: Token <api-key-of-service-account>' \
--header 'Content-Type: application/json' \
--data-raw '{
"pageGroupName": "Saree Category",
"urls": [
"https://www.example.com/saree/satin-sarees",
"https://www.example.com/saree/shimmer-sarees",
"https://www.example.com/saree/silk-sarees",
"https://www.example.com/saree/supernet-sarees",
"https://www.example.com/saree/tissue-sarees"
],
"viewport": "SERA_VIEWPORT_MOBILE",
"callbackUrl" : "https://www.example.com"
}'
Path Param¶
domain
: the domain for which urls needs to be rendered
Request Payload¶
pageGroupName
: name of the page groupurls
: the list of URLs that needs to be rendered. You can process a maximum of 100 URLs at a time.resourceBlockRegex
: the list of patterns that needs to block during rendering, eg: images and third-party calls usually not required for non-user traffic.waitForSelector
: Wait for the given selector to appear in page. If selector already exists at the time of page load, sera will finalize rendering immediately.-
viewport
: Possible Viewport values for viewport are belowValue Viewport SERA_VIEWPORT_DESKTOP Desktop SERA_VIEWPORT_MOBILE Mobile SERA_VIEWPORT_DESKTOP_MOBILE Desktop and Mobile -
callbackUrl
: A Url which will be called upon the rendering of the pages with the relevant status. pageWaitTimeout
: You can configure the time the SERA rendering process should wait before responding with timeout error.stabilizeWaitTimeout
: Extra time required for rendering to complete after page load
Payload Fields¶
Field | Type | Default |
---|---|---|
domain | required | (none) |
urls | required | (none) |
pageGroupName | optional | Just-In-Time |
viewport | optional | SERA_VIEWPORT_DESKTOP_MOBILE |
waitForSelector | optional | (empty) |
resourceBlockRegex | optional | (empty) |
pageWaitTimeout | optional | 30 |
stabilizeWaitTimeout | optional | 0 |
callbackUrl | optional | (empty) |
API Response Object¶
The following is the response for the on demand render API
Response Fields¶
message
: Unique UUID, to identify the URLs requested in SERA API
Response to Callback API¶
The callback URL is invoked with an HTTP POST
request, containing the following payload
{
"runId" : "905aebcc-32ed-4c77-96e9-d048276a1819",
"domain" : "www.example.com",
"startTime" : "2024-10-15T08:31:26.857Z",
"endTime" : "2024-10-15T08:31:52.182Z",
"url" : "https://www.example.com/saree/satin-sarees",
"statusCode" : 200,
"deviceType" : "desktop"
}
Callback Headers¶
user-agent
: Nitrogen/1.0 SERA CallbackContent-Type
: application/json
Callback Payload¶
runId
: message recieved in response from SERA API,domain
: www.example.com,startTime
: start timestamp for url processing in UTC,endTime
: end timestamp for url processing in UTC,url
: https://www.example.com/saree/satin-sarees,statusCode
: Status code received from origindeviceType
: device type for which URL is requested