/directions-api-client

Ruby gem for Graphhopper API

Primary LanguageRuby

directions-api-client

GraphHopperClient - the Ruby gem for the GraphHopper Directions API

You use the GraphHopper Directions API to add route planning, navigation and route optimization to your software. E.g. the Routing API has turn instructions and elevation data and the Route Optimization API solves your logistic problems and supports various constraints like time window and capacity restrictions. Also it is possible to get all distances between all locations with our fast Matrix API.

This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.0.0
  • Package version: 0.11-SNAPSHOT
  • Build package: io.swagger.codegen.languages.RubyClientCodegen

Installation

Build a gem

To build the Ruby code into a gem:

gem build directions-api-client.gemspec

Then either install the gem locally:

gem install ./directions-api-client-0.11-SNAPSHOT.gem

(for development, run gem install --dev ./directions-api-client-0.11-SNAPSHOT.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'directions-api-client', '~> 0.11-SNAPSHOT'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:

gem 'directions-api-client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'directions-api-client'

api_instance = GraphHopperClient::GeocodingApi.new

key = "key_example" # String | Get your key at graphhopper.com

opts = { 
  q: "q_example", # String | If you do forward geocoding, then this would be a textual description of the address you are looking for
  locale: "locale_example", # String | Display the search results for the specified locale. Currently French (fr), English (en), German (de) and Italian (it) are supported. If the locale wasn't found the default (en) is used.
  limit: 56, # Integer | Specify the maximum number of returned results
  reverse: true, # BOOLEAN | Set to true to do a reverse Geocoding request, see point parameter
  point: "point_example", # String | The location bias in the format 'latitude,longitude' e.g. point=45.93272,11.58803
  provider: "provider_example" # String | Can be either, default, nominatim, opencagedata
}

begin
  #Execute a Geocoding request
  result = api_instance.geocode_get(key, opts)
  p result
rescue GraphHopperClient::ApiError => e
  puts "Exception when calling GeocodingApi->geocode_get: #{e}"
end

Documentation for API Endpoints

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

Class Method HTTP request Description
GraphHopperClient::GeocodingApi geocode_get GET /geocode Execute a Geocoding request
GraphHopperClient::IsochroneApi isochrone_get GET /isochrone Isochrone Request
GraphHopperClient::MatrixApi matrix_get GET /matrix Matrix API
GraphHopperClient::MatrixApi matrix_post POST /matrix Matrix API Post
GraphHopperClient::RoutingApi route_get GET /route Routing Request
GraphHopperClient::SolutionApi get_solution GET /vrp/solution/{jobId} Return the solution associated to the jobId
GraphHopperClient::VrpApi post_vrp POST /vrp/optimize Solves vehicle routing problems

Documentation for Models

Documentation for Authorization

api_key

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