- Print
- DarkLight
- PDF
What can I do with Prerender.io Rest API?
Swagger
All of our current API endpoints are also available via Swagger.
The new V3 API endpoints are also available here.
The location of the Prerender token has changed. You can find it under the Security and Access menu under Prerender Token.
Please note that API access is a premium feature available exclusively with our Advanced and Custom/Enterprise plans. For more information or to upgrade your plan, please get in touch with us.
Recache
You can use the recache API to cache a URL for the first time or recache a URL cached previously. This POST request needs to be in JSON format; otherwise, it won't work.
The recache API is great for keeping your costs down, letting you set your cache expiration to a high value by using the recache API to supplement pages that change more often.
URL
https://api.prerender.io/recache
Params
{
"prerenderToken": "YOUR_TOKEN",
"url": "http://www.example.com/url/to/recache"
}
Example
curl -H "Content-Type: application/json" -d '{"prerenderToken": "YOUR\_TOKEN", "url": "http://www.example.com/"}' https://api.prerender.io/recache
Recaching Multiple URLs
The recache API can take up to 1,000 URLs per request. Make sure to change the parameter to "urls" if you want to add more than 1 url per request.
Params
{
"prerenderToken": "YOUR_TOKEN",
"urls": [
"http://www.example.com/url/to/recache",
"http://www.example.com/url/to/recache2"
]
}
Example
curl -H "Content-Type: application/json" -d '{"prerenderToken": "YOUR\_TOKEN", "urls": \["http://www.example.com/url/to/recache", "http://www.example.com/url/to/recache2"\]}' https://api.prerender.io/recache
You can also use our Python script to cache or recache URLs in bulk from a text file or a sitemap's URL.
the script and it's documentation can be found here: Automate URL Caching with Prerender Recache Script
Recaching mobile pages
To recache mobile pages add "adaptiveType": "mobile" to the recache request.
Params
{
"prerenderToken": "YOUR_TOKEN",
"url": "http://www.example.com/url/to/recache",
"adaptiveType": "mobile"
}
Example
curl -H "Content-Type: application/json" -d '{"prerenderToken": "YOUR\_TOKEN", "url": "http://www.example.com/", "adaptiveType": "mobile"}' https://api.prerender.io/recache
Search
The search API lets you search for cached URLs within your account and see their cache status.
URL
https://api.prerender.io/search
Params
{
"prerenderToken": "YOUR TOKEN",
"query": "example.com/path",
"exactMatch": "https://example.com/path",
"start": 0,
"adaptiveType": "desktop"
}
- The
query
parameter performs a 'contains' query. Optional parameter exactMatch
returns the results where the URL is fully identical. Optional parameter. If bothquery
andexactMatch
are present onlyexactMatch
will be used.start
is for pagination. The search returns 200 URLs. If you want to get then next 200 you can set thestart
parameter to 200. 400 for the next batch, etc. Optional parameter.adaptiveType
: Can be "mobile" or "desktop". If you have both mobile and desktop version of a page yu can filter for them this way. Optional parameter
Sitemap
The sitemap API lets you add new URLs via sitemap XML files. Existing URLs will not be recached.
URL
https://api.prerender.io/sitemap
Params
{
"prerenderToken": "YOUR TOKEN",
"url": "https://www.sitemaps.org/sitemap.xml"
}
Example
curl -H "Content-Type: application/json" -d '{"prerenderToken": "YOUR_TOKEN", "url": "https://www.sitemaps.org/sitemap.xml"}' https://api.prerender.io/sitemap
Clear cache
This API will enable you to clear your cache, totally or partially. It is only available for users in our current plans. Users in our legacy plans will not have access to this API and should reach out to us to clear their cache. This call schedules a clear job. The job usually runs quite fast, but it is dependent on the size of the cache. It’s possible to check the job’s status, as shown below. There can only be one scheduled job per user. This is a POST request with two parameters.
URL
https://api.prerender.io/cache-clear
Params
{
"prerenderToken": "YOUR TOKEN",
"query”: “https://example.com%"
}
prerenderToken - Your API token
query - This query will be inserted into an SQL-like condition. So “%” and “?” act as a wildcard.
http://example.com% - adding “%” after a URL will delete everything that begins with the string before “%”. In this example, all cache that starts with https://example.com will be deleted.
Example
curl -X POST -H “Content-Type: application/json” -d ‘{“prerenderToken”: “YOUR TOKEN”, “query”: “https://example.com%“}’ https://api.prerender.io/cache-clear
Return values
200 - Cache clear queued
403 - Cache clear in progress
Check cache clear job status
This is a GET request. You will need to provide your API token in the URL.
URL
https://api.prerender.io/cache-clear-status
Example
curl https://api.prerender.io/cache-clear-status/YOURTOKEN
Return values
403 - in progress
200 - not queued
Change Recache Speed
This API endpoint allows you to adjust the rendering speed of your Manual/API and Automatic rendering queues.
You can customize the speed or revert to the default automatic delay.
You can read more about the rendering queues here.
Before increasing the recache speed, consult with your development and infrastructure teams. A higher number of requests during the rendering process could potentially overload your servers or affect your service's performance. Ensure your system can handle the increased load before making changes.
URL
https://api.prerender.io/change-recache-speed
Method
This is a POST request. You will need to provide your Prerender token as a parameter.
Params
{
"prerenderToken": "YOUR_TOKEN",
"urlsPerHour": 18000 // 0, or between 3600 and 36000
}
prerenderToken
: Your Prerender token. You can find it under the Security and Access menu.urlsPerHour
: The number of URLs to recache per hour. Use 0 for automatic delay, or a value between 3600 and 36000.
Example
curl -X POST -H "Content-Type: application/json" -d '{"prerenderToken": "YOUR_TOKEN", "urlsPerHour": 18000}' https://api.prerender.io/change-recache-speed
Response
For automatic delay (urlsPerHour = 0):
{
"success": true,
"recacheMetrics": null,
"isAutomaticDelay": true
}
For custom delay:
{
"success": true,
"recacheMetrics": {
"delayBetweenURLs": 10286,
"num10Sec": 1,
"num30Sec": 3,
"num1Min": 6,
"num10Min": 59,
"num1Hour": 350,
"num1Day": 8400
},
"isAutomaticDelay": false
}
The recacheMetrics
object provides statistics on how many pages will be cached in various time periods based on your settings.
36000 is the fastest recache speed, while 18000 is slower. Setting to 0 reverts to the default automatic delay.