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

  1. Create an account at mantisapi.com/signup. Free tier includes 100 API calls/month.
  2. Go to your Dashboard → API Keys section.
  3. Click "Create API Key". Give it a descriptive name (e.g., "production", "development").
  4. Copy the key. It starts with sk_live_ for production or sk_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_SandboxUses test credits (unlimited during beta)
sk_live_ProductionUses 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:

Each key can be independently revoked without affecting other services.

Rate Limits by Plan

Plan Monthly Credits Requests/sec
Free1001
Starter ($29/mo)5,0005
Pro ($99/mo)25,00015
Scale ($299/mo)100,00050

Next Steps

Ready to Start Scraping?

Follow the Quickstart guide to make your first API call in under 5 minutes.

Quickstart Guide →