Complete API documentation for Open Browser Rendering.
http://localhost:3000
All endpoints (except / and /health) require Bearer token authentication.
Header:
Authorization: Bearer YOUR_API_KEY
Get API information.
Endpoint: GET /
Authentication: Not required
Response:
{
"name": "Open Browser Rendering",
"version": "1.0.0",
"description": "Open-source alternative to Cloudflare Browser Rendering API",
"endpoints": {
"screenshot": "POST /screenshot",
"pdf": "POST /pdf",
"evaluate": "POST /evaluate",
"health": "GET /health"
},
"documentation": "https://github.com/devmode-id/OpenBrowserRendering"
}Capture a screenshot of a web page.
Endpoint: POST /screenshot
Authentication: Required
Request Body:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
url |
string | Yes | - | URL to capture |
viewport |
object | No | {width: 1280, height: 720} |
Viewport dimensions |
viewport.width |
number | No | 1280 | Viewport width in pixels |
viewport.height |
number | No | 720 | Viewport height in pixels |
screenshotOptions |
object | No | {} |
Screenshot options |
screenshotOptions.fullPage |
boolean | No | false | Capture full page |
screenshotOptions.type |
string | No | "png" | Image type: "png" or "jpeg" |
screenshotOptions.quality |
number | No | - | JPEG quality (1-100) |
gotoOptions |
object | No | {} |
Navigation options |
gotoOptions.waitUntil |
string | No | "networkidle" | Wait condition: "load", "domcontentloaded", "networkidle" |
gotoOptions.timeout |
number | No | 30000 | Navigation timeout in ms |
Example Request:
{
"url": "https://example.com",
"viewport": {
"width": 1920,
"height": 1080
},
"screenshotOptions": {
"fullPage": true,
"type": "png"
},
"gotoOptions": {
"waitUntil": "networkidle",
"timeout": 30000
}
}Response:
- Content-Type:
image/pngorimage/jpeg - Body: Binary image data
Error Responses:
| Status | Description |
|---|---|
| 400 | Invalid request body |
| 401 | Unauthorized (invalid API key) |
| 429 | Too many concurrent requests |
| 500 | Server error |
Generate a PDF from a web page.
Endpoint: POST /pdf
Authentication: Required
Request Body:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
url |
string | Yes | - | URL to convert |
format |
string | No | "A4" | Paper format: "Letter", "Legal", "Tabloid", "Ledger", "A0"-"A6" |
printBackground |
boolean | No | true | Print background graphics |
gotoOptions |
object | No | {} |
Navigation options |
gotoOptions.waitUntil |
string | No | "networkidle" | Wait condition |
gotoOptions.timeout |
number | No | 30000 | Navigation timeout in ms |
Example Request:
{
"url": "https://example.com",
"format": "A4",
"printBackground": true,
"gotoOptions": {
"waitUntil": "networkidle",
"timeout": 30000
}
}Response:
- Content-Type:
application/pdf - Body: Binary PDF data
Error Responses:
| Status | Description |
|---|---|
| 400 | Invalid request body |
| 401 | Unauthorized (invalid API key) |
| 429 | Too many concurrent requests |
| 500 | Server error |
Execute JavaScript in a page context.
Endpoint: POST /evaluate
Authentication: Required
Request Body:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
url |
string | Yes | - | URL to navigate to |
script |
string | Yes | - | JavaScript code to execute |
gotoOptions |
object | No | {} |
Navigation options |
gotoOptions.waitUntil |
string | No | "networkidle" | Wait condition |
gotoOptions.timeout |
number | No | 30000 | Navigation timeout in ms |
Example Request:
{
"url": "https://example.com",
"script": "document.title",
"gotoOptions": {
"waitUntil": "networkidle",
"timeout": 30000
}
}Response:
{
"result": "Example Domain"
}Complex Script Example:
{
"url": "https://example.com",
"script": "({ title: document.title, links: document.querySelectorAll('a').length })"
}Response:
{
"result": {
"title": "Example Domain",
"links": 5
}
}Error Responses:
| Status | Description |
|---|---|
| 400 | Invalid request body |
| 401 | Unauthorized (invalid API key) |
| 429 | Too many concurrent requests |
| 500 | Server error or script execution error |
Check service health and status.
Endpoint: GET /health
Authentication: Not required
Response:
{
"status": "ok",
"active": 0,
"maxConcurrency": 2,
"browserEngine": "chromium",
"uptime": 123.456
}Fields:
| Field | Type | Description |
|---|---|---|
status |
string | Service status: "ok" |
active |
number | Current active rendering requests |
maxConcurrency |
number | Maximum concurrent requests allowed |
browserEngine |
string | Browser engine in use |
uptime |
number | Server uptime in seconds |
The API implements concurrency-based rate limiting. When the maximum number of concurrent requests is reached, additional requests will receive a 429 Too Many Concurrent Requests error.
Configure MAX_CONCURRENCY in your .env file based on your server resources.
All error responses follow this format:
{
"error": "Error message description"
}- Set appropriate timeouts - Adjust
gotoOptions.timeoutbased on expected page load time - Use networkidle for dynamic content - For JavaScript-heavy sites, use
waitUntil: "networkidle" - Optimize viewport size - Use smaller viewports when possible to reduce memory usage
- Handle errors gracefully - Implement retry logic for transient failures
- Monitor concurrency - Check
/healthendpoint to monitor active requests
See EXAMPLES.md for complete code examples in various programming languages.