API Overview
Introduction to the Mako Code API
The Mako Code API provides programmatic access to all Mako Code features for data analysis and visualization. This page provides an overview of the API structure and common patterns.
Base URL
The API is served from:
API documentation is available at /api/docs
in development mode.
CORS Support
The API supports Cross-Origin Resource Sharing (CORS) for the following origins:
Key Features
Code Execution
Execute Python code securely with access to data science libraries:
SQL Support
Execute SQL queries using the @sql
directive:
Data Management
Upload, list, and manage datasets in various formats (CSV, JSON, Parquet, Arrow).
User-Defined Functions
Save and reuse functions across your projects with metadata like descriptions and tags.
Version Control
Automatically track changes to your code with version history and restore capabilities.
Response Format
Most API endpoints return a consistent JSON format:
Or in case of errors:
Error Handling
The API uses standard HTTP status codes to indicate success or failure:
- 2xx: Success
- 4xx: Client error (invalid request)
- 5xx: Server error
Error responses include details about what went wrong.
Security
The API implements several security measures:
- Code validation before execution
- Restricted imports (only allows standard library and approved packages)
- Prevention of unsafe function calls (like
eval
andexec
) - Linting to catch potential issues
Available Endpoints
The API is organized around the following main resources:
For detailed information about each endpoint, see the Endpoints documentation.