Skip to content

meission/go-graphhopper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for openapi

Integrate A-to-B route planning, turn-by-turn navigation, route optimization, isochrone calculations, location clustering and other tools into your application.

Authentication
  1. Sign up for GraphHopper
  2. Create an API key

Authenticate to the API by passing your key as a query parameter in every request.

API Explorer

You can also try all API parts without registration in our API explorer.

Client Libraries

To speed up development and make coding easier, we offer a JavaScript client and a Java client.

Optimize Response Speed
  1. Reuse SSL/TLS sessions

You should utilize the SSL session to speed up responses after the initial response or use a library that does this. E.g. for Java the OkHttp library automatically reuses SSL/TLS sessions and also the browser takes care of this automatically. For python you can use the requests library: first you create a session (session = requests.Session()) and then do requests only with this session instead of directly using "requests".

  1. Bandwidth reduction

If you create your own client, make sure it supports http/2 and gzipped responses for best speed. If you use the Matrix, the Route Optimization API or the and want to solve large problems, we recommend you to reduce bandwidth by compressing your POST request and specifying the header as follows: Content-Encoding: gzip. This will also avoid the HTTP 413 error "Request Entity Too Large".

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.0.0
  • Package version: 1.0.0
  • Generator version: 7.12.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://www.graphhopper.com/

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/meission/go-graphhopper"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://graphhopper.com/api/1

Class Method HTTP request Description
ClusteringAPI AsyncClusteringProblem Post /cluster/calculate Batch Cluster Endpoint
ClusteringAPI GetClusterSolution Get /cluster/solution/{jobId} GET Batch Solution Endpoint
ClusteringAPI SolveClusteringProblem Post /cluster POST Cluster Endpoint
CustomProfilesAPI DeleteProfile Delete /profiles/{profileId} Delete a custom routing profile
CustomProfilesAPI GetProfile Get /profiles List your custom routing profiles
CustomProfilesAPI PostProfile Post /profiles Create a custom routing profile
GeocodingAPI GetGeocode Get /geocode Geocoding Endpoint
IsochronesAPI GetIsochrone Get /isochrone Compute an isochrone
MapMatchingAPI PostGPX Post /match Map-match a GPX file
MatricesAPI CalculateMatrix Post /matrix/calculate Submit a matrix computation job
MatricesAPI GetMatrix Get /matrix Compute a matrix
MatricesAPI GetMatrixSolution Get /matrix/solution/{jobId} Retrieve result of a matrix computation job
MatricesAPI PostMatrix Post /matrix Compute a matrix
RouteOptimizationAPI AsyncVRP Post /vrp/optimize Submit a route optimization job
RouteOptimizationAPI GetSolution Get /vrp/solution/{jobId} Retrieve solution of a route optimization job
RouteOptimizationAPI SolveVRP Post /vrp Solve a route optimization problem
RoutingAPI GetRoute Get /route Calculate a route
RoutingAPI PostRoute Post /route Calculate a route

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

api_key

  • Type: API key
  • API key parameter name: key
  • Location: URL query string

Note, each API key must be added to a map of map[string]APIKey where the key is: api_key and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"api_key": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

support@graphhopper.com

About

graphhopper openapi golang client

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages