API Reference

API Basics

Learn the fundamentals of working with our REST API

Making Requests

Our REST API is accessible via HTTPS at https://browserize.com/api. All requests must use HTTPS - HTTP requests will be rejected.

The API accepts requests with JSON payloads and returns JSON responses. Make sure to set the appropriate content type header:

http
Content-Type: application/json

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header:

http
Authorization: Bearer your_api_key_here

You can obtain an API key from your dashboard settings. Keep your API key secure and never share it publicly.

Response Format

Successful responses follow a standard format:

json
{
  "status": "success",
  "data": {
    // Response data here
  },
  "meta": {
    "request_id": "req_abc123",
    "timestamp": "2024-03-20T12:00:00Z"
  }
}

The data field contains the actual response data, while the meta field includes request metadata that can be useful for debugging.

Error Handling

Error responses follow a consistent format:

json
{
  "status": "error",
  "error": {
    "code": "invalid_request",
    "message": "The request was invalid",
    "details": {
      "field": "email",
      "issue": "Invalid email format"
    }
  }
}

Common HTTP status codes:

  • 200 - Success
  • 400 - Bad Request
  • 401 - Unauthorized
  • 403 - Forbidden
  • 404 - Not Found
  • 429 - Too Many Requests
  • 500 - Internal Server Error

Examples

Here's a complete example of making an API request using fetch:

javascript
const API_KEY = 'your_api_key_here';
const API_URL = 'https://browserize.com/api';

async function createScreenshot(url) {
  try {
    const response = await fetch(`${API_URL}/screenshots`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        url: url,
        format: 'png',
        width: 1920,
        height: 1080
      })
    });

    if (!response.ok) {
      const error = await response.json();
      throw new Error(error.error.message);
    }

    const data = await response.json();
    return data.data;
  } catch (error) {
    console.error('API request failed:', error);
    throw error;
  }
}

Check out our examples section for more code samples in different programming languages.