Geofox.Client (geofox_ex v0.1.0)
View SourceHTTP client for the HVV Geofox API.
This module provides a unified interface for making HTTP requests to the Geofox API with proper HMAC-SHA1 authentication and response processing.
Authentication
The Geofox API requires HMAC-SHA1 authentication using these headers:
geofox-auth-user: Application ID (provided by HBT GmbH)geofox-auth-signature: HMAC-SHA1 signature of the request bodygeofox-auth-type: Always "HmacSHA1"
Rate Limiting
The API has a rate limit of approximately 1 request per second on average. Exceeding this will result in temporary access suspension.
Summary
Functions
Make a GET request to the Geofox API.
Create a new Geofox API client.
Make a POST request to the Geofox API.
Types
@type t() :: Req.Request.t()
Functions
Make a GET request to the Geofox API.
Less commonly used for the Geofox API since most endpoints are POST, but included for completeness.
Create a new Geofox API client.
Options
:base_url- Base URL for the API (default: "https://gti.geofox.de"):timeout- Request timeout in milliseconds (default: 30000):headers- Additional headers to include in requests:user- Application ID for authentication (required for most endpoints):password- Password for HMAC-SHA1 signature generation (required for auth):platform- Platform identifier (e.g., "ios", "android", "web", "mobile"):retry- Retry configuration (default: false):max_retries- Maximum number of retries (default: 3)
Examples
# Public endpoints (no auth required)
client = Geofox.Client.new()
# Authenticated client
client = Geofox.Client.new(
user: "your_user_id",
password: "your_secret_key",
platform: "web"
)
Make a POST request to the Geofox API.
Parameters
client- The Req client instancepath- API endpoint path (e.g., "/gti/public/getRoute")body- Request body (will be JSON encoded)opts- Additional request options
Returns
{:ok, response_body}- Success with parsed response{:error, reason}- Error with reason
Examples
request_body = %{
language: "de",
version: 1,
filterType: "NO_FILTER"
}
case Geofox.Client.post(client, "/gti/public/init", request_body) do
{:ok, response} -> IO.inspect(response)
{:error, error_reason} -> IO.puts("Error: " <> inspect(error_reason))
end