API Overview
The Geoapify Route Optimization SDK provides a structured, TypeScript-first interface for interacting with the Geoapify Route Planner API. It simplifies the process of building and sending optimization requests, interpreting results, modifying assignments, and visualizing agent plans.
Modules
The SDK is organized into three key parts:
1. Core Classes
Class | Purpose |
---|---|
RoutePlanner |
Build and execute route planning requests |
RoutePlannerResult |
Parse and analyze route results |
RoutePlannerResultEditor |
Reassign or modify jobs/shipments |
RoutePlannerTimeline |
Render timelines for UI/visualization |
2. Entities (Input Objects)
Use these to define the input for your route plan:
Entity | Description |
---|---|
Agent |
Represents a resource (driver, worker, vehicle) |
Job |
Task or delivery to perform at a location |
Shipment |
Pickup + delivery pair |
Location |
Reusable named coordinate reference |
Avoid |
Travel restrictions (e.g., avoid toll roads) |
3. Entities (Result Objects)
These classes help interpret and structure the result of the route planner:
Entity | Description |
---|---|
AgentSolution |
Full plan for an agent: route, actions, timeline |
Waypoint |
Stops where agent performs tasks |
RouteAction |
Actions like pickup, delivery, break |
RouteLeg |
Segment between waypoints |
JobSolution |
Links a job to an agent and timeline |
ShipmentSolution |
Links a shipment to agent and execution steps |
Typical Flow
// 1. Build input
const planner = new RoutePlanner({ apiKey: "YOUR_API_KEY" });
planner
.setMode("drive")
.addAgent(new Agent().setStartLocation(...))
.addJob(new Job().setLocation(...));
// 2. Execute
const result = await planner.plan();
// 3. Explore result
const agents = result.getAgentSolutions();
const waypoints = result.getAgentWaypoints("agent-1");
// 4. Modify if needed
const editor = new RoutePlannerResultEditor(result);
await editor.assignJobs("agent-2", ["job-3"]);
UI Integration
- Use
RoutePlannerTimeline
to create interactive, embeddable views of agent schedules. - Build dashboards, map overlays, or edit tools on top of these components.