Module graphhopper.directions

ballerinax/graphhopper.directions Ballerina library

2.0.0

Overview

GraphHopper Directions API provides route planning, turn-by-turn navigation, route optimization, isochrone calculation, geocoding, matrix calculation, map matching, location clustering and custom routing profiles for building location-aware applications.

The GraphHopper Directions connector lets Ballerina integrations call these services through a typed client. It supports version 1.0.0 of the GraphHopper Directions API and authenticates with an API key.

Key features

  • Calculate routes between two or more points with turn-by-turn instructions
  • Compute travel time and distance matrices, synchronously or as asynchronous jobs
  • Solve vehicle routing and clustering problems for delivery and service fleets
  • Generate isochrones that show the area reachable within a time or distance limit
  • Search addresses and places with forward and reverse geocoding
  • Map-match GPX tracks and manage custom routing profiles

Setup guide

To use the GraphHopper Directions connector, you need an API key.

  1. Sign up for GraphHopper or log in to your existing account.

  2. Open the GraphHopper dashboard and create an API key by following the API key guide.

  3. Copy the generated key and keep it safe. The connector sends it as the key query parameter in every request.

Quickstart

To use the graphhopper.directions connector in your Ballerina application, update the .bal file as follows:

Step 1: Import the module

Copy
import ballerinax/graphhopper.directions;

Step 2: Instantiate a new connector

  1. Create a Config.toml file and configure the obtained API key as follows:
Copy
apiKey = "<Your GraphHopper API Key>"
  1. Create a directions:ApiKeysConfig and initialize the client.
Copy
configurable string apiKey = ?;

final directions:Client graphhopper = check new ({'key: apiKey});

Step 3: Invoke the connector operation

Calculate a route between two points:

Copy
public function main() returns error? {
    directions:RouteResponse _ = check graphhopper->getRoute(point = ["52.517037,13.388860", "52.525439,13.413000"], profile = "car");
}

Step 4: Run the Ballerina application

Copy
bal run

Examples

The GraphHopper Directions connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering the following use cases:

  1. Route travel planner - Geocode two addresses, calculate the car route between them and compute the area reachable from the origin.
  2. Delivery route optimization - Submit a delivery optimization job for a van and poll until the optimized route is ready.

Import

import ballerinax/graphhopper.directions;Copy

Other versions

See more...

Metadata

Released date: about 16 hours ago

Version: 2.0.0

License: Apache-2.0


Security

Direct vulnerabilities: No known direct vulnerabilities

Indirect vulnerabilities: 

Checked on 2026-11-20 via OSV.dev


Compatibility

Platform: any

Ballerina version: 2201.12.0

GraalVM compatible: Yes


Pull count

Total: 45

Current verison: 1


Weekly downloads


Source repository


Keywords

Vendor/GraphHopper

Area/Developer Tools

Type/Connector

GraphHopper Directions


Contributors