Basic Integration
Get started with integrating Gerra's API into your application
Basic Integration
This guide walks you through integrating Gerra's API to control your mecha.
Prerequisites
- Gerra API Token (see Quick Start)
- Access to a Gerra-compatible mecha
Authentication
All API requests require authentication via the gerra-api-key
header:
curl "https://api.gerra.com/endpoint" \
-H "gerra-api-key: YOUR_TOKEN"
Basic Workflow
A typical workflow for controlling a mecha follows these steps:
- Initialize the mecha
- Send movement commands
- Terminate the session when done
1. Initialize the Mecha
curl -X POST "https://api.gerra.com/mecha/action/initialize?mecha_id=MECHA_ID" \
-H "gerra-api-key: YOUR_TOKEN"
2. Move the Mecha
curl -X POST "https://api.gerra.com/mecha/action/move?mecha_id=MECHA_ID" \
-H "Content-Type: application/json" \
-H "gerra-api-key: YOUR_TOKEN" \
-d '[{"x": 0, "y": 1}]'
3. Stop and Reset the Mecha
curl -X POST "https://api.gerra.com/mecha/action/rest?mecha_id=MECHA_ID" \
-H "gerra-api-key: YOUR_TOKEN"
Error Handling
Always implement error handling in your application:
try:
response = requests.post(
"https://api.gerra.com/mecha/action/move",
params={"mecha_id": "MECHA_ID"},
headers=headers,
json=waypoints
)
response.raise_for_status() # Raises an exception for 4XX/5XX responses
print("Movement successful")
except requests.exceptions.RequestException as e:
print(f"Error during mecha operation: {e}")
# Implement recovery logic
System Architecture
graph LR
A[Your Application] -->|API Requests| B[Gerra API]
B --> C[Mecha Controller]
C --> D[Physical Mecha]
Next Steps
- Explore the API Reference for all available endpoints
- Learn about Path Planning techniques
- Set up Real-time Control with WebSockets