@relive/graphhopper-api-client
Version:
Open source Javascript / Typescript client to the Graphhopper API, generated with OpenAPI
32 lines (21 loc) • 1.04 kB
Markdown
A wrapper around the Graphhopper API.
The code is generated from the [GraphHopper OpenAPI spec](https://docs.graphhopper.com/openapi.json) with `npm run generate`.
Besides this we also support a couple of APIs not in the OpenAPI spec: [src/experimentalAPI.ts](src/experimentalAPI.ts).
npm install @relive/graphhopper-api-client
import * as graphhopper from "@relive/graphhopper-api-client";
import { VehicleProfileId } from '@relive/graphhopper-api-client/build/generated/graphhopper-api/model';
// Endpoint of graphhopper-web
const GRAPHHOPPER_BASE_URI = "http://localhost:8989";
// Execute a routing request
const routingAPI = new graphhopper.RoutingAPIApi(undefined, GRAPHHOPPER_BASE_URI);
const routes = await routingAPI.getRoute({
point: [
[], // Amsterdam
[] // Rotterdam
].map(c => c.join()),
vehicle: VehicleProfileId.Bike,
elevation: false
});