Server Integration — Ruby / Sinatra
Sinatra with the official pickpoint gem — exposes PickPoint to your frontend. The API key lives in an environment variable and never reaches the client.
1
Gemfile
# Gemfile
gem "pickpoint"
gem "sinatra"
gem "puma"
gem "dotenv"2
App setup & geocoding
# .env
PICKPOINT_KEY=your_key_here# app.rb
require "sinatra"
require "json"
require "pickpoint"
require "dotenv/load"
pp = Pickpoint::Client.new(
Pickpoint::Config.new(api_key: ENV.fetch("PICKPOINT_KEY"))
)# ── Geocoding ─────────────────────────────────────────────────────────────
get "/geo/forward" do
content_type :json
pp.forward(params.slice("q", "limit", "countrycodes", "viewbox", "language")).to_json
end
get "/geo/reverse" do
content_type :json
pp.reverse(params.slice("lat", "lon", "zoom", "language")).to_json
end
get "/geo/search" do
content_type :json
pp.search(params.slice("q", "limit", "viewbox", "countrycodes")).to_json
end3
Routing endpoints
# ── Routing ───────────────────────────────────────────────────────────────
post "/route" do
content_type :json
pp.route(JSON.parse(request.body.read)).to_json
end
post "/route/optimized" do
content_type :json
pp.optimized_route(JSON.parse(request.body.read)).to_json
end4
Device tracking - REST
# ── Device tracking - REST ────────────────────────────────────────────────
get "/devices" do
content_type :json
r = pp.devices.list
JSON.generate("data" => r.data.map(&:to_h), "total" => r.total)
endRun with bundle exec ruby app.rb. For the WebSocket subscriber relay, use a language with a tracking client — see the Node.js or Python examples.