User Guide/API Access

Auto-Generated APIs

Understand and use GoPie's automatic REST API generation for your datasets

GoPie automatically creates REST APIs for every dataset you upload or connect, enabling programmatic access to your data without any coding. These APIs are instantly available, fully documented, and support filtering, pagination, and aggregation.

How It Works

When you add a dataset to GoPie:

  1. Schema Analysis - GoPie analyzes your data structure
  2. API Generation - REST endpoints are created automatically
  3. Documentation - OpenAPI/Swagger docs are generated
  4. Security - API keys and permissions are configured
  5. Optimization - Indexes and caching are set up

APIs are available within seconds of uploading data, with no configuration required.

API Endpoint Structure

Base URL

Your API endpoints follow this pattern:

https://api.gopie.app/v1/{organization}/{project}/{dataset}

Example:

https://api.gopie.app/v1/acme-corp/sales-analytics/customer-orders

Available Endpoints

For each dataset, GoPie creates these endpoints:

EndpointMethodDescription
/GETList all records with pagination
/{id}GETGet single record by ID
/queryPOSTExecute custom queries
/aggregatePOSTPerform aggregations
/schemaGETGet dataset schema
/countGETGet total record count

Making API Requests

Basic GET Request

Retrieve records from your dataset:

curl -X GET \
  'https://api.gopie.app/v1/acme-corp/sales/orders?limit=10' \
  -H 'Authorization: Bearer YOUR_API_KEY'
const response = await fetch(
  'https://api.gopie.app/v1/acme-corp/sales/orders?limit=10',
  {
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  }
);
const data = await response.json();
import requests

response = requests.get(
    'https://api.gopie.app/v1/acme-corp/sales/orders',
    params={'limit': 10},
    headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
data = response.json()
require 'net/http'
require 'json'

uri = URI('https://api.gopie.app/v1/acme-corp/sales/orders?limit=10')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'

response = http.request(request)
data = JSON.parse(response.body)

Response Format

API responses follow a consistent structure:

{
  "data": [
    {
      "id": 1,
      "customer_name": "John Doe",
      "order_date": "2024-01-15",
      "total": 299.99
    },
    // ... more records
  ],
  "meta": {
    "total": 1547,
    "page": 1,
    "per_page": 10,
    "pages": 155
  },
  "links": {
    "first": "https://api.gopie.app/v1/acme-corp/sales/orders?page=1",
    "last": "https://api.gopie.app/v1/acme-corp/sales/orders?page=155",
    "next": "https://api.gopie.app/v1/acme-corp/sales/orders?page=2",
    "prev": null
  }
}

Query Parameters

Filtering

Filter results using query parameters:

# Equal
?status=completed

# Not equal
?status[ne]=cancelled

# Greater than
?amount[gt]=100

# Less than
?created_at[lt]=2024-01-01

# Contains (text search)
?name[contains]=john

# In list
?category[in]=electronics,clothing

# Between
?price[between]=10,100

Sorting

Sort results by any field:

# Ascending
?sort=created_at

# Descending  
?sort=-created_at

# Multiple fields
?sort=-amount,customer_name

Pagination

Control result pagination:

# Page number and size
?page=2&per_page=50

# Offset and limit
?offset=100&limit=50

# Cursor-based (for large datasets)
?cursor=eyJpZCI6MTAwfQ==

Field Selection

Return only specific fields:

# Include fields
?fields=id,name,email

# Exclude fields
?exclude=password,internal_notes

Advanced Queries

Custom SQL Queries

Execute custom SQL via the /query endpoint:

curl -X POST \
  'https://api.gopie.app/v1/acme-corp/sales/orders/query' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "sql": "SELECT customer_id, SUM(total) as lifetime_value FROM orders GROUP BY customer_id HAVING SUM(total) > 1000",
    "parameters": {}
  }'

Custom queries are read-only. Only SELECT statements are allowed.

Aggregations

Perform aggregations without writing SQL:

curl -X POST \
  'https://api.gopie.app/v1/acme-corp/sales/orders/aggregate' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "group_by": ["category"],
    "aggregates": {
      "total_sales": {"sum": "amount"},
      "order_count": {"count": "*"},
      "avg_order": {"avg": "amount"}
    },
    "having": {
      "total_sales": {"gt": 10000}
    }
  }'

Joins (Enterprise)

Join data across datasets:

curl -X POST \
  'https://api.gopie.app/v1/acme-corp/sales/query' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "from": "orders",
    "join": [
      {
        "table": "customers",
        "on": "orders.customer_id = customers.id"
      }
    ],
    "select": ["orders.*", "customers.name", "customers.email"],
    "where": "orders.status = 'completed'"
  }'

Rate Limiting and Usage

Rate Limits

API rate limits by plan:

PlanRequests/HourRequests/DayBurst Rate
Free1,00010,00010/second
Pro10,000100,00050/second
EnterpriseUnlimited*Unlimited*Custom

*Subject to fair use policy

Rate Limit Headers

Monitor your usage via response headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 950
X-RateLimit-Reset: 1609459200
X-RateLimit-RetryAfter: 3600

Handling Rate Limits

When rate limited, you'll receive:

{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded",
    "retry_after": 3600
  }
}

Best practices:

  • Implement exponential backoff
  • Cache responses when possible
  • Use webhooks for real-time updates
  • Consider upgrading your plan

Versioning and Compatibility

API Versions

GoPie APIs use semantic versioning:

  • v1 - Current stable version
  • v2 - Next version (when available)
  • beta - Preview features

Specify version in the URL:

https://api.gopie.app/v1/...  (stable)
https://api.gopie.app/v2/...  (future)
https://api.gopie.app/beta/... (preview)

Backward Compatibility

GoPie maintains backward compatibility:

  • Existing endpoints remain available
  • New fields are added, not removed
  • Breaking changes require new version
  • Deprecation notices provided 6 months ahead

Migration Guide

When upgrading API versions:

  1. Review changelog for differences
  2. Update API calls gradually
  3. Test in staging environment
  4. Monitor deprecated endpoint usage
  5. Complete migration before sunset date

OpenAPI/Swagger Documentation

Accessing Documentation

View interactive API docs:

https://api.gopie.app/v1/{organization}/{project}/docs

Features:

  • Try API calls directly
  • View request/response schemas
  • Download OpenAPI specification
  • Generate client SDKs

OpenAPI Specification

Download the spec for code generation:

curl https://api.gopie.app/v1/acme-corp/sales/openapi.json \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  > openapi.json

Use with tools like:

  • Swagger Codegen
  • OpenAPI Generator
  • Postman
  • Insomnia

Security Best Practices

API Key Management

  1. Never expose keys in client-side code

    // Bad
    fetch(url, {
      headers: {'Authorization': 'Bearer sk_live_abc123'}
    });
    
    // Good - Use server-side proxy
    fetch('/api/proxy/gopie', {
      headers: {'X-Session-Token': sessionToken}
    });
  2. Rotate keys regularly

    • Set up key rotation schedule
    • Use different keys for environments
    • Revoke compromised keys immediately
  3. Restrict key permissions

    • Read-only for public data
    • Limit to specific datasets
    • IP whitelist for production

CORS Configuration

Configure CORS for browser access:

{
  "cors": {
    "origins": ["https://myapp.com"],
    "methods": ["GET", "POST"],
    "headers": ["Authorization", "Content-Type"],
    "credentials": true
  }
}

Webhook Security

Verify webhook signatures:

const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const hmac = crypto.createHmac('sha256', secret);
  hmac.update(payload);
  const expectedSignature = hmac.digest('hex');
  return signature === expectedSignature;
}

Performance Optimization

Caching

Implement caching strategies:

// Client-side caching
const cache = new Map();

async function fetchData(endpoint) {
  if (cache.has(endpoint)) {
    return cache.get(endpoint);
  }
  
  const response = await fetch(endpoint);
  const data = await response.json();
  
  // Cache for 5 minutes
  cache.set(endpoint, data);
  setTimeout(() => cache.delete(endpoint), 300000);
  
  return data;
}

Batch Requests

Reduce API calls with batching:

curl -X POST \
  'https://api.gopie.app/v1/acme-corp/batch' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "requests": [
      {"method": "GET", "path": "/sales/orders/123"},
      {"method": "GET", "path": "/sales/customers/456"},
      {"method": "POST", "path": "/sales/orders/aggregate", "body": {...}}
    ]
  }'

Response Compression

Enable gzip compression:

curl -H 'Accept-Encoding: gzip' \
     -H 'Authorization: Bearer YOUR_API_KEY' \
     https://api.gopie.app/v1/acme-corp/sales/orders

Monitoring and Analytics

API Analytics Dashboard

Monitor your API usage:

  • Request volume and trends
  • Response time percentiles
  • Error rates and types
  • Top endpoints by usage
  • Geographic distribution

Custom Metrics

Track custom metrics:

# Add custom headers for tracking
curl -X GET \
  'https://api.gopie.app/v1/acme-corp/sales/orders' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'X-Client-Id: mobile-app-v2' \
  -H 'X-Request-Id: 123e4567-e89b-12d3-a456-426614174000'

What's Next?