Code examples
Copy-paste integrations in popular languages.
curl
curl -X POST https://api.nightglass.xyz/api/v1/screenshot \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"url": "https://example.com", "width": 1440, "height": 900}' \
--output screenshot.png
Python
import requests
response = requests.post(
"https://api.nightglass.xyz/api/v1/screenshot",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY",
},
json={
"url": "https://example.com",
"width": 1440,
"height": 900,
"format": "png",
},
)
with open("screenshot.png", "wb") as f:
f.write(response.content)
print(f"Saved {len(response.content)} bytes")
Node.js
const response = await fetch(
"https://api.nightglass.xyz/api/v1/screenshot",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_API_KEY",
},
body: JSON.stringify({
url: "https://example.com",
width: 1440,
height: 900,
}),
}
);
const buffer = await response.arrayBuffer();
await Bun.write("screenshot.png", buffer);
// or with Node fs:
// fs.writeFileSync("screenshot.png", Buffer.from(buffer));
Go
package main
import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]any{
"url": "https://example.com",
"width": 1440,
"height": 900,
})
req, _ := http.NewRequest("POST",
"https://api.nightglass.xyz/api/v1/screenshot",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
f, _ := os.Create("screenshot.png")
defer f.Close()
io.Copy(f, resp.Body)
}
Python (x402 agent flow)
"""
Agent-native screenshot using x402.
No API key needed — the agent pays per-request.
Requires: pip install x402 web3
"""
from x402.client import X402Client
client = X402Client(
private_key="YOUR_WALLET_PRIVATE_KEY",
network="base",
)
# The client handles the full 402 → pay → retry flow
response = client.post(
"https://api.nightglass.xyz/api/v1/screenshot",
json={"url": "https://example.com"},
)
with open("screenshot.png", "wb") as f:
f.write(response.content)