Auto-generated REST APIs that agents can consume for database operations. GibsonAI automatically creates REST endpoints based on your database schema, providing immediate API access for AI agents.

Key Features

Auto-Generated REST APIs

  • Schema-Based Generation: APIs automatically generated from database schemas
  • CRUD Operations: Full Create, Read, Update, Delete operations
  • Immediate Availability: APIs available as soon as schema is created
  • Automatic Updates: APIs update when schema changes

Agent-Optimized Endpoints

  • RESTful Design: Standard REST API patterns
  • JSON Response Format: Consistent JSON responses
  • Error Handling: Comprehensive error responses
  • Data Validation: Built-in request validation

Text-to-SQL Integration

  • Natural Language Queries: Convert natural language to SQL
  • Complex Queries: Handle multi-table joins and aggregations
  • Safe Execution: Protected query execution
  • Flexible Results: Return results in agent-friendly formats

Implementation Examples

Basic CRUD Operations

import requests

# Base API URL
BASE_URL = "https://api.gibsonai.com/v1/-"
headers = {"Authorization": "Bearer your_api_key"}

# GET: Retrieve all records
response = requests.get(f"{BASE_URL}/customers", headers=headers)
customers = response.json()

# GET: Retrieve specific record
response = requests.get(f"{BASE_URL}/customers/123", headers=headers)
customer = response.json()

# POST: Create new record
new_customer = {
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "+1-555-0123"
}
response = requests.post(f"{BASE_URL}/customers", json=new_customer, headers=headers)
created_customer = response.json()

# PUT: Update existing record
updated_data = {"phone": "+1-555-0456"}
response = requests.put(f"{BASE_URL}/customers/123", json=updated_data, headers=headers)
updated_customer = response.json()

# DELETE: Remove record
response = requests.delete(f"{BASE_URL}/customers/123", headers=headers)

Text-to-SQL Queries

# Natural language queries through API
query_request = {
    "query": "Show me all customers who placed orders in the last 30 days"
}

response = requests.post(
    f"{BASE_URL}/query",
    json=query_request,
    headers=headers
)

results = response.json()
print(f"Found {len(results)} customers")

# Complex analytical queries
query_request = {
    "query": "What is the average order value by customer segment for this month?"
}

response = requests.post(
    f"{BASE_URL}/query",
    json=query_request,
    headers=headers
)

analytics = response.json()

Agent Integration Example

class CustomerServiceAgent:
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = "https://api.gibsonai.com/v1/-"
        self.headers = {"Authorization": f"Bearer {api_key}"}

    def get_customer_info(self, customer_id):
        """Get customer information"""
        response = requests.get(
            f"{self.base_url}/customers/{customer_id}",
            headers=self.headers
        )
        return response.json()

    def get_order_history(self, customer_id):
        """Get customer order history using natural language"""
        query = f"Show me all orders for customer {customer_id} ordered by date"
        response = requests.post(
            f"{self.base_url}/query",
            json={"query": query},
            headers=self.headers
        )
        return response.json()

    def create_support_ticket(self, customer_id, issue):
        """Create new support ticket"""
        ticket_data = {
            "customer_id": customer_id,
            "issue": issue,
            "status": "open",
            "created_at": "2024-01-15T10:30:00Z"
        }
        response = requests.post(
            f"{self.base_url}/support-tickets",
            json=ticket_data,
            headers=self.headers
        )
        return response.json()

Error Handling

def safe_api_call(endpoint, method="GET", data=None):
    """Safe API call with error handling"""
    try:
        if method == "GET":
            response = requests.get(f"{BASE_URL}/{endpoint}", headers=headers)
        elif method == "POST":
            response = requests.post(f"{BASE_URL}/{endpoint}", json=data, headers=headers)

        response.raise_for_status()
        return response.json()

    except requests.exceptions.HTTPError as e:
        print(f"HTTP Error: {e.response.status_code}")
        print(f"Response: {e.response.text}")
        return None
    except requests.exceptions.RequestException as e:
        print(f"Request Error: {e}")
        return None

API Endpoints

Standard Table Endpoints

For each table in your schema, GibsonAI automatically generates:

GET    /v1/-/table-name           # List all records
GET    /v1/-/table-name/{id}      # Get specific record
POST   /v1/-/table-name           # Create new record
PUT    /v1/-/table-name/{id}      # Update existing record
DELETE /v1/-/table-name/{id}      # Delete record

Special Endpoints

POST   /v1/-/query                # Text-to-SQL queries
GET    /v1/-/schema               # Get database schema
GET    /v1/-/health               # API health check

Query Parameters

Filtering and Pagination

# Filter records
params = {
    "status": "active",
    "created_after": "2024-01-01"
}
response = requests.get(f"{BASE_URL}/customers", params=params, headers=headers)

# Pagination
params = {
    "page": 2,
    "limit": 50
}
response = requests.get(f"{BASE_URL}/orders", params=params, headers=headers)

# Sorting
params = {
    "sort": "created_at",
    "order": "desc"
}
response = requests.get(f"{BASE_URL}/products", params=params, headers=headers)

Agent Use Cases

Data Retrieval

Perfect for agents that need to:

  • Look up customer information
  • Retrieve order history
  • Access product catalogs
  • Query analytics data

Data Creation

Enable agents to:

  • Create new customer records
  • Generate support tickets
  • Log user interactions
  • Store processed data

Data Updates

Allow agents to:

  • Update customer preferences
  • Modify order statuses
  • Change product information
  • Track interaction history

Complex Queries

Support agents with:

  • Multi-table joins
  • Aggregation queries
  • Time-based filtering
  • Conditional logic

MCP Server Integration

Connect AI tools through MCP server:

# Example MCP server configuration for API access
mcp_config = {
    "server_name": "gibsonai-api",
    "base_url": "https://api.gibsonai.com/v1/-",
    "authentication": {
        "type": "bearer",
        "token": "your_api_key"
    },
    "capabilities": [
        "query_database",
        "create_records",
        "update_records",
        "delete_records"
    ]
}

Benefits for AI Agents

  • Immediate Access: APIs available instantly when schema is created
  • No Coding Required: Auto-generated based on database schema
  • Natural Language: Query database using natural language
  • Consistent Interface: Standard REST API patterns
  • Error Handling: Built-in error handling and validation
  • Scalable: Handles high-volume agent requests
  • Secure: Authentication and authorization built-in

Getting Started

  1. Create Database Schema: Use natural language to define your schema
  2. Generate Models: Create Python models with Gibson CLI
  3. Deploy Schema: Apply changes to get APIs
  4. Test Endpoints: Use the auto-generated API endpoints
  5. Connect Agents: Integrate agents with the APIs

OpenAPI Documentation

Each GibsonAI project provides:

  • Complete OpenAPI specification
  • Interactive API documentation
  • Code examples in multiple languages
  • Authentication details
  • Error response formats

Access your OpenAPI spec through the project settings in Gibson Studio.