Back to API Unlimited

API Documentation

Complete reference for the OnLeads API

Authentication

All API requests require authentication using an API key. Include your key in the X-API-Key header.

HTTP Header
X-API-Key: sk_live_your_api_key_here

Keep your API key secure

Never expose your API key in client-side code or public repositories.

Base URL

All API endpoints use the following base URL:

https://api.onleads.io

Rate Limits & Concurrency

API Unlimited subscriptions have concurrent request limits based on your worker count:

Workers Concurrent Requests Note
1 1 per endpoint Can run /scrape + /google-search simultaneously
3 3 per endpoint 3 scrape requests in parallel
5 5 per endpoint Maximum parallelism

If you exceed your concurrent limit, you'll receive a 429 response. Wait for an in-progress request to complete before sending another.

Error Handling

The API returns standard HTTP status codes and JSON error responses:

Status Code Description
400 missing_keyword Required parameter missing
400 blocked_operator Query contains a blocked search operator
401 invalid_api_key API key is invalid or missing
402 no_credits Insufficient credits (pay-as-you-go only)
403 subscription_required Endpoint requires API Unlimited
429 concurrent_limit All request slots in use
503 server_provisioning Resources being set up (wait 5-10 min)
Error Response Format
{
  "error": "All request slots in use",
  "message": "All 3 scrape request slots are in use. Please wait.",
  "code": "concurrent_limit",
  "max_concurrent": 3
}
POST

/v1/scrape/

Extract business leads from Google Maps. Returns detailed business information including name, phone, address, website, ratings, and more.

Request Body

Parameter Type Description
keyword required string Business type or search term (e.g., "restaurants", "plumbers")
location required string City, address, or area (e.g., "Miami, FL", "10001")
max_results optional integer Maximum results to return (default: unlimited, max: 500)

Example Request

cURL
curl -X POST https://api.onleads.io/v1/scrape/ \
  -H "X-API-Key: sk_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"keyword": "restaurants", "location": "Miami, FL", "max_results": 100}'

Response

200 OK
{
  "success": true,
  "results": [
    {
      "name": "Joe's Pizza",
      "phone": "+1 305-555-0123",
      "address": "123 Ocean Drive, Miami, FL 33139",
      "website": "https://joespizza.com",
      "rating": 4.5,
      "num_reviews": 328,
      "categories": ["Pizza", "Italian"],
      "place_id": "ChIJ...",
      "google_maps_url": "https://maps.google.com/...",
      "latitude": 25.7617,
      "longitude": -80.1918
    }
  ],
  "total": 100,
  "credits_charged": 0,
  "unlimited": true,
  "query": {
    "keyword": "restaurants",
    "location": "Miami, FL",
    "max_results": 100
  }
}
GET

/v1/credits/

Check your current credit balance (for pay-as-you-go users).

Example Request

cURL
curl https://api.onleads.io/v1/credits/ \
  -H "X-API-Key: sk_live_your_key"

Response

200 OK
{
  "credits": 5000,
  "email": "user@example.com"
}
GET

/v1/server-status/

Check the status of your dedicated worker(s).

Requires: API Unlimited subscription

Response

200 OK
{
  "has_subscription": true,
  "is_ready": true,
  "status": "healthy",
  "message": "Your resources are ready and operational.",
  "worker_count": 3,
  "servers": [
    {"index": 0, "status": "healthy"},
    {"index": 1, "status": "healthy"},
    {"index": 2, "status": "healthy"}
  ]
}

Code Examples

Python

Python (requests)
import requests

API_KEY = "sk_live_your_key"
BASE_URL = "https://api.onleads.io"

def scrape_businesses(keyword, location, max_results=100):
    response = requests.post(
        f"{BASE_URL}/v1/scrape/",
        headers={"X-API-Key": API_KEY},
        json={
            "keyword": keyword,
            "location": location,
            "max_results": max_results
        }
    )
    return response.json()

# Example usage
results = scrape_businesses("restaurants", "Miami, FL")
print(f"Found {results['total']} businesses")
for biz in results['results']:
    print(f" - {biz['name']}: {biz['phone']}")

JavaScript

JavaScript (fetch)
const API_KEY = 'sk_live_your_key';
const BASE_URL = 'https://api.onleads.io';

async function scrapeBusinesses(keyword, location, maxResults = 100) {
  const response = await fetch(`${BASE_URL}/v1/scrape/`, {
    method: 'POST',
    headers: {
      'X-API-Key': API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ keyword, location, max_results: maxResults })
  });
  return response.json();
}

// Example usage
scrapeBusinesses('restaurants', 'Miami, FL')
  .then(data => console.log(`Found ${data.total} businesses`));

cURL

cURL
# Scrape businesses
curl -X POST https://api.onleads.io/v1/scrape/ \
  -H "X-API-Key: sk_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"keyword": "restaurants", "location": "Miami, FL"}'

# Check credits
curl https://api.onleads.io/v1/credits/ \
  -H "X-API-Key: sk_live_your_key"

# Google search (API Unlimited only)
curl -X POST https://api.onleads.io/v1/google-search/ \
  -H "X-API-Key: sk_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"query": "best crm software"}'

Need Help?

If you have questions or run into issues, we're here to help.