Using the API Documentation#
This guide explains how to use the interactive API documentation for SmartEM Decisions services.
Overview#
SmartEM Decisions provides interactive API documentation built with Swagger UI, giving you:
Live API exploration - Try endpoints directly in your browser
Complete specifications - Full OpenAPI 3.0 documentation
Example requests/responses - See exactly what data to send and expect
Authentication helpers - Built-in tools for API authentication
Accessing the Documentation#
Online Documentation#
Visit the hosted API documentation at:
Athena Decision Service: Athena API Docs
SmartEM Core API: SmartEM API Docs
Local Documentation#
To run the documentation locally with a live mock server:
# Install mock dependencies
pip install -e ".[mock]"
# Start the Athena mock server
python -c "
from athena_api.mock import AthenaAPIServer
server = AthenaAPIServer()
server.run()
"
# Visit http://localhost:8000/docs
Using the Interactive Features#
Try It Out#
Expand an endpoint by clicking on it
Click “Try it out” to enable the interactive form
Fill in parameters using the provided form fields
Click “Execute” to make a real API call
View the response including status code, headers, and body
Authentication#
For endpoints requiring authentication:
Click the “Authorize” button at the top of the page
Enter your credentials (API key, bearer token, etc.)
Click “Authorize” to save credentials for all requests
Request Examples#
Each endpoint shows:
Parameter descriptions - What each field does
Example values - Sample data to help you understand the format
Schema definitions - Complete data structure specifications
Response examples - What to expect back from the API
API Specifications#
Understanding API Sources#
Athena Decision Service API - External service integration:
Source of Truth: External Athena service OpenAPI specification (
docs/athena-decision-service-api-spec.json
)Our Implementation: Python client and mock server generated from spec
Documentation: Based on the authoritative external specification
SmartEM Core API - Our implementation:
Source of Truth: Our FastAPI/Django implementation
Our Implementation: Backend service with business logic
Documentation: Generated from our actual API endpoints
Download Specifications#
You can download the raw OpenAPI specifications:
Athena API Spec - Official external specification
Athena Source Spec - Original specification file
SmartEM API Spec - Generated from our implementation
Using Specifications#
Import these into your favorite API tools:
Postman - Import → Link → Paste URL
Insomnia - Create → Import/Export → From URL
VS Code REST Client - Use with OpenAPI extensions
Code generators - Generate client libraries in various languages
Common Workflows#
Testing Decision Service Integration#
Start with session management:
POST /api/v1/Session # Register a new acquisition session
Register areas:
POST /api/v1/Area # Add grid squares and foil holes
Record decisions:
POST /api/v1/Decision # Log automated decisions
Store algorithm results:
POST /api/v1/AlgorithmResult # Save processing outcomes
Monitoring Acquisition Status#
Check application state:
GET /api/v1/CurrentApplicationState # Get current system status
Query area states:
GET /api/v1/Session/{sessionId}/AreaStates # Monitor area processing status
Retrieve decisions:
GET /api/v1/Session/{sessionId}/Decisions # Review automated decisions
Development Tips#
Mock Server for Development#
The Athena API includes a full mock server for development:
from athena_api.mock import AthenaAPIServer
# Create and configure mock server
server = AthenaAPIServer()
# Customize host/port
server.run(host="0.0.0.0", port=8080)
Client Library Usage#
Use the Python client library for programmatic access:
from athena_api import AthenaClient
from athena_api.model.request import Session
from uuid import uuid4
from datetime import datetime
# Connect to API
client = AthenaClient("http://localhost:8000")
# Create a session
session = Session(
sessionId=uuid4(),
sessionName="Test Session",
timestamp=datetime.now(),
gridType="HoleyCarbon"
)
# Register the session
response = client.register_session(session)
print(f"Session created: {response.sessionId}")
Error Handling#
The API follows standard HTTP status codes:
200-299: Success responses
400-499: Client errors (bad requests, missing data)
500-599: Server errors (system failures)
Check the API documentation for specific error responses and how to handle them.
Support#
For API-related questions:
Check the interactive documentation for endpoint details
Review the example code in this documentation
Examine the client library source code for usage patterns
Open an issue on the GitHub repository
The API documentation is automatically updated with each release, ensuring you always have access to the latest features and changes.