Authentication
Every request to the WebPerception API requires an API key. This guide covers how to get your key, use it securely, and manage multiple keys.
Get Your API Key
- Create an account at mantisapi.com/signup. Free tier includes 100 API calls/month.
- Go to your Dashboard → API Keys section.
- Click "Create API Key". Give it a descriptive name (e.g., "production", "development").
- Copy the key. It starts with
sk_live_for production orsk_test_for sandbox.
⚠️ Important: Your API key is shown only once at creation. Copy it immediately and store it securely. If you lose it, you'll need to create a new one.
Using Your API Key
Pass your API key in the Authorization header with the Bearer prefix:
Authorization: Bearer sk_live_your_api_key_here
curl
curl -X POST https://api.mantisapi.com/v1/scrape \
-H "Authorization: Bearer sk_live_abc123..." \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'
Python
import os
import requests
api_key = os.environ["MANTIS_API_KEY"]
response = requests.post(
"https://api.mantisapi.com/v1/scrape",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
},
json={"url": "https://example.com"}
)
print(response.json())
Node.js
const apiKey = process.env.MANTIS_API_KEY;
const response = await fetch("https://api.mantisapi.com/v1/scrape", {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify({ url: "https://example.com" })
});
const data = await response.json();
console.log(data);
Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
apiKey := os.Getenv("MANTIS_API_KEY")
body, _ := json.Marshal(map[string]string{"url": "https://example.com"})
req, _ := http.NewRequest("POST", "https://api.mantisapi.com/v1/scrape",
bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Status:", resp.Status)
}
Environment Variables
Never hardcode API keys in your source code. Use environment variables instead.
Linux / macOS
# Add to ~/.bashrc or ~/.zshrc
export MANTIS_API_KEY="sk_live_your_api_key_here"
# Reload
source ~/.bashrc
.env File (recommended for projects)
# .env
MANTIS_API_KEY=sk_live_your_api_key_here
# Python — pip install python-dotenv
from dotenv import load_dotenv
load_dotenv()
api_key = os.environ["MANTIS_API_KEY"]
🚨 Never commit API keys to git. Add
.env to your .gitignore file. If a key is accidentally exposed, revoke it immediately from your dashboard and create a new one.
Key Types
| Prefix | Environment | Credits |
|---|---|---|
sk_test_ | Sandbox | Uses test credits (unlimited during beta) |
sk_live_ | Production | Uses your plan's real credits |
💡 Best practice: Use
sk_test_ keys during development and CI/CD. Switch to sk_live_ only in production. This prevents accidental credit usage during testing.
Managing Multiple Keys
Create separate API keys for different environments or services:
- development — local dev, test key
- staging — pre-production testing, test key
- production — live application, live key
- ci-cd — automated tests, test key
Each key can be independently revoked without affecting other services.
Rate Limits by Plan
| Plan | Monthly Credits | Requests/sec |
|---|---|---|
| Free | 100 | 1 |
| Starter ($29/mo) | 5,000 | 5 |
| Pro ($99/mo) | 25,000 | 15 |
| Scale ($299/mo) | 100,000 | 50 |
Next Steps
Ready to Start Scraping?
Follow the Quickstart guide to make your first API call in under 5 minutes.
Quickstart Guide →