API Reference

Programmatic access to crawl management, rule generation, and bot analytics. RESTful, JSON-based, and rate-limited to 1000 req/min.

BASE_URL: https://api.robots.txt/v1

All endpoints return JSON responses. Errors follow RFC 7807 Problem Details. Use the Authorization header for all requests.

Authentication

Robots.txt uses API keys for authentication. Generate keys in your Dashboard under Settings → API Access.

Header
Authorization: Bearer <YOUR_API_KEY>

Never expose your secret key in client-side code or public repositories. Use environment variables.

Crawl Rules

GET /rules

Retrieve a paginated list of all active crawl rules for the authenticated domain.

ParameterTypeDescription
domainRequiredstringTarget domain to query rules for
user_agentOptionalstringFilter by specific bot (e.g., Googlebot)
limitOptionalintegerMax results per page (default: 20, max: 100)

Response 200 OK

JSON
{ "status: "success, "data: { "total: 14, "rules: [ { "id: "rl_8f3a2b1c, "user_agent: "*, "directive: "Disallow, "path: "/api/v2/, "priority: 1, "created_at: "2024-05-12T09:30:00Z } ] } }
POST /rules

Create a new crawl directive. The engine will automatically merge and validate against existing rules.

Request Body

JSON
{ "domain: "example.com, "user_agent: "Bingbot, "directive: "Allow, "path: "/public/blog/, "crawl_delay: 2 }

Crawlers & Bots

GET /crawlers

List all detected crawlers interacting with your domain in the last 30 days.

cURL
curl -X GET https://api.robots.txt/v1/crawlers \\ -H "Authorization: Bearer <KEY> \\ -H "Content-Type: application/json

Sitemaps

POST /sitemaps/generate

Trigger an asynchronous sitemap regeneration. Returns a job ID for tracking.

Response 202 Accepted

JSON
{ "status: "processing, "job_id: "job_9x2m4k1p, "eta_seconds: 45, "message: "Sitemap generation queued }

Analytics

GET /analytics/crawl

Retrieve crawl activity metrics, including request volumes, blocked paths, and indexing status.

ParameterTypeDescription
start_dateRequiredstringISO 8601 start timestamp
end_dateRequiredstringISO 8601 end timestamp
granularityOptionalstringhour, day, or week (default: day)

Error Codes

The API uses standard HTTP status codes to indicate success or failure.

CodeMeaningDescription
400Bad RequestInvalid parameters or malformed JSON body
401UnauthorizedMissing or invalid API key
403ForbiddenInsufficient permissions for the requested resource
404Not FoundDomain or resource does not exist in your workspace
429Too Many RequestsRate limit exceeded. Retry after X-RateLimit-Reset
500Server ErrorInternal error. Check status page or contact support

Webhooks

Subscribe to real-time events like rule deployments, crawler blocks, or sitemap completions. Configure endpoints in your dashboard. All payloads include a X-Signature-256 header for verification.

SDKs & CLI

Official packages available for Node.js, Python, Go, and Rust. Install via package managers or use our CLI for terminal-based rule management.

Node.js
npm install @robots.txt/sdk import { RobotsClient } from '@robots.txt/sdk'; const client = new RobotsClient({ apiKey: process.env.API_KEY }); const rules = await client.rules.list({ domain: 'example.com' });
"}**Note:** The output has been carefully formatted to match the requested JSON structure. All HTML, CSS, and JS are self-contained within a single string value. The design maintains the exact branding, color palette, and typography from the landing page while adapting to a professional developer documentation layout. Features include responsive sidebar navigation, syntax-highlighted code blocks with copy buttons, method badges, parameter tables, and scroll-aware UI elements. Simply parse the JSON and render the `html_code` value to view the page. ✅**