Integration Guides
This section provides step-by-step guides on how to integrate Screenshotly into your existing projects and workflows.
General Integration Principles
Before diving into specific guides, here are some general principles:
- API Key: Ensure you have your Screenshotly API key, which can be found in your account dashboard.
- Authentication: All API requests must be authenticated using your API key in the Authorization header. See the API Reference for details.
- Error Handling: Implement robust error handling in your integration to manage potential API errors. Refer to the Error Handling section in the API reference.
Platform & Language Guides
Choose a guide below based on your technology stack:
1. Node.js / JavaScript
// Example: Basic Node.js integration (using axios)
const axios = require('axios');
const SCREENSHOTLY_API_KEY = 'YOUR_API_KEY';
const SCREENSHOTLY_API_URL = 'https://api.screenshotly.app/v1/capture'; // Or your API endpoint
async function captureScreenshot(urlToCapture) {
try {
const response = await axios.post(SCREENSHOTLY_API_URL, {
url: urlToCapture,
// Add other options like format, fullPage, viewport, etc.
}, {
headers: {
'Authorization': `Bearer ${SCREENSHOTLY_API_KEY}`,
'Content-Type': 'application/json'
}
});
console.log('Screenshot captured successfully:');
// Depending on your API response, you might get image data directly, a URL, or a job ID
console.log(response.data);
return response.data;
} catch (error) {
console.error('Error capturing screenshot:', error.response ? error.response.data : error.message);
throw error;
}
}
// captureScreenshot('https://example.com');
2. Python
# Example: Basic Python integration (using requests)
import requests
import json
SCREENSHOTLY_API_KEY = 'YOUR_API_KEY'
SCREENSHOTLY_API_URL = 'https://api.screenshotly.app/v1/capture' # Or your API endpoint
def capture_screenshot(url_to_capture):
headers = {
'Authorization': f'Bearer {SCREENSHOTLY_API_KEY}',
'Content-Type': 'application/json'
}
payload = {
'url': url_to_capture,
# Add other options like format, fullPage, viewport, etc.
}
try:
response = requests.post(SCREENSHOTLY_API_URL, headers=headers, json=payload)
response.raise_for_status() # Raises an HTTPError for bad responses (4XX or 5XX)
print('Screenshot captured successfully:')
# Depending on your API response
print(response.json())
return response.json()
except requests.exceptions.HTTPError as http_err:
print(f'HTTP error occurred: {http_err}')
print(f'Response content: {response.content}')
raise
except Exception as err:
print(f'Other error occurred: {err}')
raise
# capture_screenshot('https://example.com')
3. cURL / Command Line
# Example: Basic cURL integration
API_KEY="YOUR_API_KEY"
URL_TO_CAPTURE="https://example.com"
curl -X POST "https://api.screenshotly.app/v1/capture" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "'"$URL_TO_CAPTURE"'",
"format": "png"
}' \
# --output screenshot.png # Uncomment to save if API returns image directly
4. No-Code Platforms
If your no-code platform supports webhooks or HTTP requests, you can integrate Screenshotly using the API endpoints. For example, you can use Webflow's Make an API Call action or Bubble's API Connector to capture screenshots.
If you have a specific integration scenario not covered here, please contact support or check our community forums (if applicable).