Getting started overview

To begin utilizing the SavePage.io API, developers typically follow a sequence of steps: account creation, API key generation, and implementation of a first API request. This process enables the programmatic capture and archiving of web pages. The API is designed around a core endpoint for page capture, offering both synchronous and asynchronous modes of operation. Asynchronous captures allow for processing in the background, with results delivered via webhooks, a common pattern for long-running operations in web APIs as seen in AWS API Gateway.

SavePage.io provides a free tier that includes 50 captures per month, allowing for initial testing and development without immediate cost. Paid plans start at $9 per month, increasing the capture allowance. The API documentation includes code examples for several popular programming languages, facilitating integration.

Reference the table below for a quick overview of the essential steps:

Step Action Location/Resource
1. Sign Up Create a SavePage.io account. SavePage.io homepage
2. Get API Key Locate your unique API key. SavePage.io API reference documentation
3. Make First Request Send a basic capture request to the API. SavePage.io general documentation
4. Configure Callbacks (Optional) Set up a webhook endpoint for asynchronous results. SavePage.io API reference documentation

Create an account and get keys

Access to the SavePage.io API requires an authenticated account. The process begins with registering on the official SavePage.io website. Upon successful registration, users are granted access to a dashboard where API keys are generated and managed.

  1. Navigate to the SavePage.io Website: Open your web browser and go to SavePage.io's official site.
  2. Sign Up: Locate the 'Sign Up' or 'Get Started' button, typically found in the navigation bar or prominent on the homepage. Complete the registration form with your email address and a secure password.
  3. Verify Email (If Required): Some registration processes include an email verification step. Check your inbox for a verification email and follow the instructions provided to activate your account.
  4. Access Your Dashboard: Log in to your newly created account. This will usually direct you to your personal dashboard or account settings page.
  5. Locate API Keys: Within your dashboard, look for a section labeled 'API Keys', 'Developer Settings', or similar. The exact location may vary, but it is typically a dedicated area for managing credentials. The SavePage.io API reference documentation provides specific guidance on where to find this.
  6. Generate or Copy Your API Key: Your API key is a unique string that authenticates your requests to the SavePage.io API. If a key is not automatically generated, there will be an option to generate a new one. Copy this key and store it securely. Treat your API key like a password; it should not be exposed in client-side code or publicly accessible repositories.

The API key is a critical component for interacting with the SavePage.io API. Each request you send to the API will need to include this key for authentication purposes. This is a standard security practice for web APIs, ensuring that only authorized applications can access resources as described by OIDC specifications.

Your first request

After obtaining your API key, the next step is to make your first page capture request. SavePage.io's API is designed to be straightforward, primarily using a single endpoint for capturing web pages. The examples below demonstrate how to perform a basic capture using cURL, Python, and Node.js. For a full list of supported parameters and return values, consult the SavePage.io API reference.

cURL Example

Using cURL is often the quickest way to test an API endpoint directly from the command line without writing code. Replace YOUR_API_KEY with your actual API key and https://example.com with the URL you wish to capture.

curl -X POST \ 
  https://api.savepage.io/v1/capture \ 
  -H "Content-Type: application/json" \ 
  -H "Authorization: Bearer YOUR_API_KEY" \ 
  -d '{ "url": "https://example.com" }'

This command sends a POST request to the /v1/capture endpoint, specifying the URL to capture in the request body. The Authorization header carries your API key, prefixed with Bearer, which is a common authentication scheme for OAuth 2.0-based APIs.

Python Example

For Python developers, the requests library simplifies HTTP interactions. Ensure you have it installed (pip install requests).

import requests
import json

api_key = "YOUR_API_KEY"
url_to_capture = "https://example.com"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {api_key}"
}

data = {
    "url": url_to_capture
}

response = requests.post("https://api.savepage.io/v1/capture", headers=headers, data=json.dumps(data))

print(response.status_code)
print(response.json())

This Python script sends a POST request with the URL and API key, then prints the HTTP status code and the JSON response from the API. The response typically includes a capture ID and the status of the capture.

Node.js Example

Node.js developers can use the built-in https module or a library like axios (npm install axios) for making HTTP requests. The example below uses axios for brevity.

const axios = require('axios');

const apiKey = "YOUR_API_KEY";
const urlToCapture = "https://example.com";

const headers = {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${apiKey}`
};

const data = {
    url: urlToCapture
};

axios.post("https://api.savepage.io/v1/capture", data, { headers })
    .then(response => {
        console.log(response.status);
        console.log(response.data);
    })
    .catch(error => {
        console.error(error.response ? error.response.data : error.message);
    });

This Node.js example constructs a POST request with the necessary headers and payload, then logs the response status and data, or any errors encountered during the request. Both Python and Node.js examples demonstrate standard practices for interacting with RESTful APIs.

Common next steps

Once you have successfully executed your initial capture request, there are several common steps developers take to integrate SavePage.io more deeply into their applications or workflows:

  1. Handle Asynchronous Captures with Callbacks: For captures that might take longer, or to avoid blocking your application, implement callback URLs (webhooks). SavePage.io can send a POST request to your specified endpoint once the capture is complete, providing the capture results. This is crucial for maintaining responsiveness in web applications and is a common pattern for processing long-running tasks as seen in AWS EventBridge API Destinations. Details on configuring callbacks are in the API reference documentation.
  2. Retrieve Capture Status and Data: After initiating a capture, you'll receive a capture ID. You can use this ID to poll the API for the capture's status and retrieve the archived page data once it's available. The API offers endpoints to check status and download archived content.
  3. Explore Advanced Capture Options: The SavePage.io API supports various parameters to fine-tune the capture process, such as specifying viewport dimensions, delaying capture, including or excluding specific elements, or setting custom headers for the request. Review the API reference for a comprehensive list of these options to customize your captures.
  4. Error Handling and Retry Logic: Implement robust error handling in your application to gracefully manage API errors, such as invalid URLs, authentication failures, or rate limits. Consider implementing retry logic with exponential backoff for transient errors to improve the reliability of your integration.
  5. Monitor API Usage: Keep an eye on your API usage, especially if you are on a free or tiered plan, to ensure you stay within your allocated capture limits. Your SavePage.io dashboard likely provides metrics and usage statistics.
  6. Integrate with Storage Solutions: While SavePage.io stores captured pages, you might want to integrate it with your own cloud storage solutions (e.g., AWS S3, Google Cloud Storage) for long-term archiving or direct access within your infrastructure.
  7. Security Best Practices: Always protect your API key. Avoid hardcoding it directly into your application code. Instead, use environment variables or a secure configuration management system. Ensure that any webhook endpoints you expose are secure and validate incoming requests to prevent abuse.

Troubleshooting the first call

Encountering issues during your first API call is a common part of the development process. Here are some troubleshooting steps and common problems along with their potential solutions for SavePage.io:

  • Authentication Errors (401 Unauthorized):
    • Issue: You receive an HTTP 401 status code, indicating that your request is not authorized.
    • Solution: Double-check that your API key is correct and included in the Authorization: Bearer YOUR_API_KEY header. Ensure there are no typos, extra spaces, or missing prefixes (Bearer). Verify that the key copied from your SavePage.io dashboard is the one being used.
  • Bad Request Errors (400 Bad Request):
    • Issue: The API responds with an HTTP 400 error, suggesting an issue with the request's format or parameters.
    • Solution: Review your request body. Ensure it's valid JSON and that the url parameter is present and contains a well-formed URL (e.g., "https://example.com"). Check the Content-Type: application/json header is correctly set in your request. Consult the SavePage.io API reference for required parameters and data types.
  • Not Found Errors (404 Not Found):
    • Issue: An HTTP 404 status code indicating the endpoint was not found.
    • Solution: Verify that the API endpoint URL is correct (e.g., https://api.savepage.io/v1/capture). Ensure there are no typos in the path.
  • Server Errors (5xx Errors):
    • Issue: You receive an HTTP 5xx status code, indicating a server-side problem.
    • Solution: These errors typically point to issues on the SavePage.io side. While less common, if you encounter these, it's advisable to check the SavePage.io status page or documentation for any service announcements. You might also try the request again after a short delay.
  • Network or Connection Issues:
    • Issue: Your request times out or fails to connect.
    • Solution: Check your internet connection. Ensure no firewalls or proxies are blocking your outbound requests to api.savepage.io.
  • Rate Limiting (429 Too Many Requests):
    • Issue: Although less likely on a very first call, repeated requests can quickly hit rate limits, resulting in a 429 status code.
    • Solution: If you're rapidly testing, space out your requests. Check your plan's rate limits and consider implementing exponential backoff in your code for retries. Information on rate limits is usually available in the API reference documentation.

Always review the exact error message provided in the API response body, as it often contains specific details that can pinpoint the problem. If problems persist, consulting the official SavePage.io documentation and potentially their support channels is recommended.