Bearer Token Authentication
The most secure way to authenticate API requests is using a Bearer token in the Authorization header.
Usage
Include your API key in the Authorization header:
curl -X POST https://api.renderscreenshot.com/v1/screenshot \ -H "Authorization: Bearer rs_live_xxxxx" \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com"}'
Benefits
- Secure: Key is not visible in URLs or logs
- Standard: Uses the OAuth 2.0 Bearer token format
- Flexible: Works with all HTTP methods
Code Examples
Java
import okhttp3.*; OkHttpClient client = new OkHttpClient(); MediaType JSON = MediaType.get("application/json"); String body = "{\"url\": \"https://example.com\"}"; Request request = new Request.Builder() .url("https://api.renderscreenshot.com/v1/screenshot") .header("Authorization", "Bearer rs_live_xxxxx") .post(RequestBody.create(body, JSON)) .build(); Response response = client.newCall(request).execute();
Node.js
const response = await fetch('https://api.renderscreenshot.com/v1/screenshot', { method: 'POST', headers: { 'Authorization': 'Bearer rs_live_xxxxx', 'Content-Type': 'application/json' }, body: JSON.stringify({ url: 'https://example.com', preset: 'og_card' }) });
PHP
$ch = curl_init('https://api.renderscreenshot.com/v1/screenshot'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer rs_live_xxxxx', 'Content-Type: application/json' ], CURLOPT_POSTFIELDS => json_encode([ 'url' => 'https://example.com' ]) ]); $response = curl_exec($ch); curl_close($ch);
Python
import requests response = requests.post( 'https://api.renderscreenshot.com/v1/screenshot', headers={ 'Authorization': 'Bearer rs_live_xxxxx', 'Content-Type': 'application/json' }, json={'url': 'https://example.com'} )
Ruby
require 'net/http' require 'json' uri = URI('https://api.renderscreenshot.com/v1/screenshot') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri) request['Authorization'] = 'Bearer rs_live_xxxxx' request['Content-Type'] = 'application/json' request.body = { url: 'https://example.com' }.to_json response = http.request(request)
When to Use
Use Bearer token authentication when:
- Making server-side API calls
- Building backend integrations
- Maximum security is required