Authentication overview

SavePage.io secures access to its API primarily through API key authentication. This method requires developers to include a unique, secret key with every request to verify their identity and authorize the operation. The API key functions as a Bearer token, meaning it grants access to whoever possesses it, underscoring the importance of its secure handling. All API communication with SavePage.io must occur over HTTPS to protect the API key and other sensitive data during transit, mitigating risks like man-in-the-middle attacks. This aligns with general recommendations for securing web APIs, as detailed by sources like the World Wide Web Consortium on secure communications.

The SavePage.io API allows users to programmatically capture web pages, retrieve capture statuses, and manage archived content. Proper authentication ensures that only authenticated users can access these functionalities, preventing unauthorized usage and protecting user data. The design prioritizes simplicity for developers while maintaining essential security protocols.

Supported authentication methods

SavePage.io exclusively supports API key authentication for accessing its services. This approach simplifies the authentication process for developers, as it avoids the complexities associated with more elaborate schemes like OAuth 2.0 unless specific delegation or third-party authorization is required. For direct service-to-service communication or user-initiated requests where the user directly owns the API key, API keys are a common and effective solution.

Below is a summary of the authentication method supported by SavePage.io:

Method When to Use Security Level Notes
API Key (Bearer Token) Direct application access, server-to-server communication, personal scripts Moderate to High (with proper handling) Default and sole method for SavePage.io API. Requires secure storage and transmission via HTTPS.

The API key acts as a secret, and its compromise could lead to unauthorized access to your SavePage.io account and usage of your capture quotas. Therefore, treating API keys with the same care as passwords is a fundamental security practice, as outlined in general API security guidelines such as those provided by Swagger's API security best practices.

Getting your credentials

To interact with the SavePage.io API, you will need to obtain an API key. This key is generated and managed within your SavePage.io user dashboard. The process generally involves the following steps:

  1. Sign Up or Log In: Navigate to the SavePage.io website and either create a new account or log in to an existing one.
  2. Access Dashboard: Once logged in, proceed to your user dashboard.
  3. Locate API Settings: Within the dashboard, look for a section typically labeled "API Settings," "Developer Settings," or "API Keys." Refer to the SavePage.io documentation for the precise location.
  4. Generate New Key: If you don't have an existing key or wish to generate a new one for security reasons (e.g., key rotation), there will be an option to "Generate New API Key" or similar.
  5. Copy Your Key: After generation, your API key will be displayed. It is crucial to copy this key immediately and store it securely, as it may only be shown once for security purposes. If you lose it, you might need to revoke it and generate a new one.

SavePage.io recommends generating separate API keys for different applications or environments (e.g., development, staging, production) to enhance security and simplify key management. This practice allows for granular control and easier revocation if a specific key is compromised without affecting other services.

Authenticated request example

Once you have obtained your API key, you can use it to authenticate your requests to the SavePage.io API. The key must be included in the Authorization HTTP header with the Bearer scheme. Below are examples demonstrating how to make an authenticated request using cURL and Python.

cURL Example

This cURL command demonstrates how to send a request to the SavePage.io capture endpoint, including your API key:

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", "wait": true}'

Replace YOUR_API_KEY with your actual API key retrieved from your dashboard. The -d flag in cURL is used to send the JSON payload containing the URL to be captured and any other capture options.

Python Example

Using the requests library in Python, an authenticated request would look like this:

import requests

API_KEY = "YOUR_API_KEY"
API_ENDPOINT = "https://api.savepage.io/v1/capture"

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

payload = {
    "url": "https://example.com",
    "wait": True
}

try:
    response = requests.post(API_ENDPOINT, headers=headers, json=payload)
    response.raise_for_status()  # Raise an exception for HTTP errors
    print("Capture initiated successfully:")
    print(response.json())
except requests.exceptions.HTTPError as err:
    print(f"HTTP error occurred: {err}")
except Exception as err:
    print(f"An error occurred: {err}")

In this Python example, the API key is passed within the headers dictionary. The requests.post method automatically handles the JSON serialization of the payload. Always ensure that error handling is implemented in your code to gracefully manage API responses, including authentication failures or other service errors.

Security best practices

Securing your API keys is paramount to maintaining the integrity and availability of your SavePage.io services. Adhering to the following best practices can significantly reduce the risk of unauthorized access and misuse:

  • Keep API Keys Confidential: Treat your API keys like passwords. Never hardcode them directly into client-side code (e.g., JavaScript in a web browser) or commit them to version control systems like Git. Instead, use environment variables, secret management services, or secure configuration files. For server-side applications, load keys from secure stores.

  • Use HTTPS/TLS: Always ensure that all communication with the SavePage.io API occurs over HTTPS. This encrypts the data in transit, protecting your API key from interception by malicious actors. SavePage.io enforces HTTPS, so attempts to connect over HTTP will fail.

  • Restrict IP Addresses (if available): While SavePage.io's current API key system does not offer IP-based restrictions directly on the key itself, consider implementing IP whitelisting at your network perimeter or within your cloud infrastructure (e.g., firewall rules) to limit which IP addresses can initiate requests to SavePage.io, effectively adding another layer of security for your applications.

  • Regularly Rotate API Keys: Periodically generate new API keys and replace old ones. This practice, known as key rotation, minimizes the window of opportunity for a compromised key to be exploited. If you suspect an API key has been compromised, revoke it immediately through your SavePage.io dashboard and generate a new one.

  • Implement Least Privilege: If SavePage.io were to introduce granular permissions for API keys in the future, always assign the minimum necessary permissions to each key. This principle of least privilege ensures that even if a key is compromised, the potential damage is limited to the specific functionalities it was authorized for.

  • Monitor API Usage: Regularly review your SavePage.io API usage logs and billing statements. Unusual spikes in activity or unexpected API calls could indicate a compromised key or unauthorized use. Set up alerts for anomalous behavior if your monitoring tools support it.

  • Secure Your Development Environment: Ensure that your development machines and build pipelines are secure. Malware or insecure practices in these environments can expose your API keys before they even reach production.

By diligently following these security best practices, developers can significantly enhance the protection of their SavePage.io integrations and safeguard their archived data. For further reading on general API security principles, resources like Google Cloud's API security overview provide valuable insights.