#!/usr/bin/env bash # Travlix API v1 - signed request with curl + openssl. Usage: TLX_KEY=... TLX_SECRET=... ./sign.sh set -euo pipefail BASE="${TLX_BASE:-https://api.travlix.com}" tlx_call() { # method path [json-body] local method="$1" path="$2" body="${3:-}" ts nonce bh sig q p ts=$(date +%s); nonce=$(openssl rand -hex 16) p="${path%%\?*}"; q=""; [[ "$path" == *\?* ]] && q="${path#*\?}" bh=$(printf '%s' "$body" | openssl dgst -sha256 -hex | sed 's/^.* //') sig=$(printf '%s\n%s\n%s\n%s\n%s\n%s' "$method" "$p" "$q" "$ts" "$nonce" "$bh" | openssl dgst -sha256 -hmac "$TLX_SECRET" -hex | sed 's/^.* //') local args=(-sS -X "$method" "$BASE$path" -H 'Content-Type: application/json' -H "X-Api-Key: $TLX_KEY" -H "X-Timestamp: $ts" -H "X-Nonce: $nonce" -H "X-Signature: $sig") [ -n "$body" ] && args+=(--data-binary "$body") curl "${args[@]}"; echo } tlx_call GET /v1/wallet/balance tlx_call POST /v1/flight/search "{\"origin\":\"DEL\",\"destination\":\"BOM\",\"departure_date\":\"$(date -d '+30 days' +%F 2>/dev/null || date -v+30d +%F)\",\"adults\":1}"