Documentation menu

SDKs

Ruby SDK

The official Wayline SDK for Ruby: Ruby 2.6+. Standard library Net::HTTP, no runtime dependencies.

Install

RubyGems
bundle add wayline
# or: gem install wayline

Quickstart

Set WAYLINE_API_KEY to a test key (see the Quickstart), then:

Ruby
require "wayline"

client = Wayline::Client.new(api_key: ENV.fetch("WAYLINE_API_KEY"))

d = client.distance(origin: [23.7925, 90.4078], destination: "23.733,90.4172", units: "imperial")
puts d["distance_miles"], d["duration_seconds"]

m = client.matrix(origins: [[23.7925, 90.4078]], destinations: [[23.733, 90.4172]])
puts m["rows"][0]["elements"][0]["duration_seconds"]

Errors

Non-2xx responses raise a typed error after retries are exhausted. Branch on code — the full list is in the error reference.

Error handling
begin
  client.distance(origin: "0,0", destination: "0,1")
rescue Wayline::Error => e
  puts e.code, e.status, e.request_id
end

Configuration

OptionDefaultDescription
API keyWAYLINE_API_KEYYour live or test key. Never logged.
Base URLhttps://api.wayline.cloudOverride for staging or a proxy.
Timeout30 secondsPer attempt.
Max retries3For 429 and 5xx, with exponential backoff + jitter, honoring Retry-After.

Source and releases

Package: wayline on RubyGems. Source: packages/sdk-ruby. Versions follow semantic versioning; see the CHANGELOG in the package and our product changelog.

Was this page helpful?