API Reference

Complete NextRows API documentation with endpoints, parameters, and examples

The NextRows API enables you to extract structured data from any website using AI-powered natural language processing. This reference provides complete documentation for all endpoints, parameters, and response formats.

Quick Start

Get started with a simple extraction request:

cURL
curl -X POST https://api.nextrows.com/v1/extract \
  -H "Authorization: Bearer sk-nr-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "url",
    "data": ["https://example.com"],
    "prompt": "Extract product names and prices"
  }'

Base URL

All API requests use the following base URL:

https://api.nextrows.com

Authentication

All requests require authentication using your API key in the Authorization header:

Authorization: Bearer sk-nr-your-api-key-here

Keep your API key secure! Never expose it in client-side code or public repositories.

Endpoints

Core Parameters

Extract Endpoint Parameters

ParameterTypeRequiredDescription
typestringType of extraction: "url" or "text"
dataarrayURLs or text content to extract from (max 20 items)
promptstringNatural language description of what to extract (max 2000 characters)
schemaobjectJSON Schema for data validation

Extraction Types

URL Extraction

Extract data directly from web pages:

{
  "type": "url",
  "data": [
    "https://example.com/page1",
    "https://example.com/page2"
  ],
  "prompt": "Extract product information"
}

Text Extraction

Extract data from provided text content:

{
  "type": "text",
  "data": [
    "Product: iPhone 14\nPrice: $999\nRating: 4.5/5",
    "Product: Samsung Galaxy\nPrice: $899\nRating: 4.3/5"
  ],
  "prompt": "Extract product name, price, and rating"
}

Response Format

Success Response

{
  "success": true,
  "data": [
    {
      "field1": "value1",
      "field2": "value2"
    }
  ]
}

Error Response

{
  "success": false,
  "error": "Detailed error message"
}

HTTP Status Codes

NextRows uses conventional HTTP status codes:

StatusMeaningDescription
200SuccessRequest completed successfully
400Bad RequestInvalid parameters or request format
401UnauthorizedMissing or invalid API key
402Payment RequiredInsufficient credits
404Not FoundEndpoint not found
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error occurred
503Service UnavailableService temporarily unavailable

Schema Validation

Use JSON Schema to ensure extracted data matches your expected structure:

Schema Example
{
  "type": "url",
  "data": ["https://jobs.example.com"],
  "prompt": "Extract job listings",
  "schema": {
    "type": "array",
    "items": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1
        },
        "company": {
          "type": "string"
        },
        "salary": {
          "type": "number",
          "minimum": 0
        },
        "location": {
          "type": "string"
        }
      },
      "required": ["title", "company"]
    }
  }
}

Schema Benefits

  • Type Safety: Ensure correct data types
  • Data Validation: Catch extraction errors early
  • Consistency: Standardize output format
  • Quality Control: Validate required fields

Advanced Features

Batch Processing

Process multiple URLs efficiently:

{
  "type": "url",
  "data": [
    "https://site1.com/products",
    "https://site2.com/products",
    "https://site3.com/products"
  ],
  "prompt": "Extract product catalog from each site"
}

Rate Limits

Limit TypeValueUpgrade Options
Requests per minute20Fixed limit
URLs per request20Fixed limit

Error Handling

Common Errors

Invalid API Key

{
  "success": false,
  "error": "Unauthorized"
}

Credits Exhausted

{
  "success": false,
  "error": "Credits exhausted"
}

Extraction Failed

{
  "success": false,
  "error": "Failed to extract data"
}

Best Practices for Error Handling

Python Example
import requests
import time

def extract_with_retry(url, prompt, max_retries=3):
    for attempt in range(max_retries):
        try:
            response = requests.post(
                "https://api.nextrows.com/v1/extract",
                headers={"Authorization": "Bearer sk-nr-your-api-key"},
                json={
                    "type": "url",
                    "data": [url],
                    "prompt": prompt
                }
            )
            
            if response.status_code == 200:
                return response.json()
            elif response.status_code == 429:
                # Rate limited - wait and retry
                wait_time = 2 ** attempt
                time.sleep(wait_time)
                continue
            else:
                # Other error - don't retry
                response.raise_for_status()
                
        except requests.exceptions.RequestException as e:
            if attempt == max_retries - 1:
                raise e
            time.sleep(1)
    
    raise Exception("Max retries exceeded")

Credit System

Credit Consumption

Different extraction types consume different amounts of credits:

Extraction TypeBase CostFactors
Simple text1 creditPer request
Basic URL2-5 creditsPage complexity
Complex extraction5-10 creditsAI processing required

Monitoring Usage

Check your credit usage:

Check Credits
curl -X GET https://api.nextrows.com/v1/credits \
  -H "Authorization: Bearer sk-nr-your-api-key"

Response:

{
  "success": true,
  "data": {
    "credits": 755
  }
}

Examples by Use Case

Additional Resources