Skip to main content

Overview

SnakeQuery provides a simple REST API that transforms natural language queries into structured data operations. This API is designed for server-side applications and backend services where API keys can be securely stored.
Backend Services Only: Never expose your API key in client-side code. This API should only be used from secure server environments.

Base URL

https://app.snakequery.com/api

Authentication

SnakeQuery API uses Bearer token authentication. Include your API key in the Authorization header:
Authorization: Bearer your_api_key_here

Getting Your API Key

  1. Visit SnakeQuery Dashboard
  2. Sign up or log in to your account
  3. Navigate to the Setup section
  4. Copy your API key
Keep your API key secure and never commit it to version control. Use environment variables to store it safely.

Content Type

All requests must include the Content-Type header:
Content-Type: application/json

Error Handling

HTTP Status Codes

Status CodeDescription
200Success
400Bad Request - Invalid query or parameters
401Unauthorized - Invalid or missing API key
402Payment Required - Insufficient credits
429Too Many Requests - Rate limit exceeded
500Internal Server Error
504Gateway Timeout - Request processing timeout

Error Response Format

{
  "error": "Error message describing what went wrong",
  "code": "ERROR_CODE",
  "details": {
    "field": "Additional context about the error"
  }
}

Common Error Codes

  • INVALID_API_KEY: The provided API key is invalid or expired
  • INSUFFICIENT_CREDITS: Account has run out of query credits
  • INVALID_QUERY: The natural language query is malformed
  • INVALID_SCHEMA: The provided response schema is invalid
  • FETCH_ERROR: Unable to fetch data from the provided URL
  • RATE_LIMIT_EXCEEDED: Too many requests in the time window

Quick Start Example

async function querySnakeQuery() {
  const apiKey = process.env.SNAKE_QUERY_API_KEY;
  const baseUrl = 'https://app.snakequery.com/api';
  
  try {
    const response = await fetch(`${baseUrl}/query`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`
      },
      body: JSON.stringify({
        query: 'Find products under $100',
        data: [
          { name: 'iPhone 14', price: 999, category: 'electronics' },
          { name: 'Coffee Mug', price: 19, category: 'home' },
          { name: 'Notebook', price: 15, category: 'office' }
        ]
      })
    });
    
    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(errorData.error || `HTTP ${response.status}`);
    }
    
    const result = await response.json();
    console.log('Results:', result.response);
    console.log('Usage:', result.usageCount);
  } catch (error) {
    console.error('Query failed:', error.message);
  }
}

SDKs and Libraries

While you can use the REST API directly with Fetch, we recommend using our official SDKs for better developer experience:

Next Steps

πŸ’¬ Community & Support

⌘I