Official Go client for the Nowah Travel API.
Zero external dependencies — stdlib net/http only.
go get github.com/Nowah-xyz/nowah-go-sdkRequires Go 1.21+.
package main
import (
"context"
"fmt"
"log"
nowah "github.com/Nowah-xyz/nowah-go-sdk"
)
func main() {
client := nowah.NewClient("your-api-key")
ctx := context.Background()
// Search for flights
result, err := client.SearchFlights(ctx, nowah.SearchFlightsParams{
Origin: "JFK",
Destination: "LAX",
DepartureDate: "2026-06-15",
Passengers: nowah.Passengers{Adults: 1},
CabinClass: (*nowah.CabinClass)(nowah.String(string(nowah.CabinEconomy))),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Found %d offers\n", result.Meta.TotalOffers)
}client := nowah.NewClient("your-api-key",
nowah.WithBaseURL("https://custom.api.com"),
nowah.WithHTTPClient(&http.Client{Timeout: 60 * time.Second}),
nowah.WithMaxRetries(2),
)// Search flights
result, err := client.SearchFlights(ctx, nowah.SearchFlightsParams{...})
// Search locations (airports, cities)
raw, err := client.SearchLocations(ctx, nowah.SearchLocationsOptions{Query: "tokyo"})
// Get a specific offer (with optional seat map)
raw, err := client.GetOffer(ctx, nowah.GetOfferParams{
OfferID: "off_123",
IncludeSeatMap: nowah.Bool(true),
})
// Get available services for an offer
raw, err := client.GetOfferServices(ctx, "off_123")raw, err := client.SearchHotels(ctx, nowah.SearchHotelsParams{
Latitude: 35.6762, Longitude: 139.6503,
CheckIn: "2026-07-01", CheckOut: "2026-07-05",
Guests: nowah.Int(2),
})
raw, err := client.GetHotelQuote(ctx, "rate_abc")raw, err := client.ListTrips(ctx, &nowah.ListTripsParams{Limit: nowah.Int(10)})
raw, err := client.GetTrip(ctx, "trip_123")
raw, err := client.CreateTrip(ctx, nowah.CreateTripParams{SelectedOfferID: "off_123"})
raw, err := client.UpdateTrip(ctx, nowah.UpdateTripParams{TripID: "trip_123", Name: nowah.String("Summer Trip")})
raw, err := client.CancelTrip(ctx, nowah.CancelTripParams{TripID: "trip_123"})
raw, err := client.GetTripDocuments(ctx, "trip_123")// Book a flight (idempotency key auto-generated)
raw, err := client.BookFlight(ctx, nowah.BookFlightParams{
TripID: "trip_123",
TravelerInfo: []nowah.TravelerInfo{{
GivenName: "Jane", FamilyName: "Doe",
BornOn: "1990-01-15", Gender: nowah.GenderFemale,
Email: "[email protected]", PhoneNumber: "+1234567890",
}},
})
raw, err := client.GetBookingFees(ctx)
// Book a hotel (idempotency key auto-generated)
raw, err := client.BookHotel(ctx, nowah.BookHotelParams{
TripID: "trip_123", RateID: "rate_abc",
Guests: []nowah.HotelGuest{{GivenName: "Jane", FamilyName: "Doe"}},
})raw, err := client.CreateCheckoutSession(ctx, nowah.CreateCheckoutSessionParams{
Amount: "150.00", Currency: "usd",
TripID: nowah.String("trip_123"),
})
raw, err := client.ListPaymentMethods(ctx)
raw, err := client.PayWithSavedCard(ctx, nowah.PayWithSavedCardParams{...})
raw, err := client.GetPaymentStatus(ctx, "pi_abc123")
raw, err := client.ManagePaymentMethod(ctx, nowah.ManagePaymentMethodParams{
PaymentMethodID: "pm_abc", Action: nowah.PaymentMethodDelete,
})raw, err := client.GetCancellationQuote(ctx, "ord_123")
raw, err := client.ConfirmCancellation(ctx, "cancel_123") // idempotent
raw, err := client.GetOrderServices(ctx, "ord_123")
raw, err := client.AddOrderServices(ctx, nowah.AddOrderServicesParams{ // idempotent
OrderID: "ord_123",
Services: []nowah.ServiceItem{{ID: "svc_1", Quantity: 1}},
Payment: nowah.OrderPayment{Type: nowah.PaymentBalance},
})
raw, err := client.CreateChangeRequest(ctx, nowah.CreateChangeRequestParams{...})
raw, err := client.ConfirmFlightChange(ctx, nowah.ConfirmFlightChangeParams{...}) // idempotentraw, err := client.GetSeatInfo(ctx, nowah.GetSeatInfoParams{
AirlineCode: "BA", AircraftType: "777",
Type: nowah.SeatInfoBest, CabinClass: (*nowah.CabinClass)(nowah.String(string(nowah.CabinEconomy))),
})
raw, err := client.GetSeatRecommendations(ctx, nowah.GetSeatRecommendationsParams{
AirlineCode: "BA", AircraftType: "777",
Preferences: &nowah.SeatPreferences{SeatType: (*nowah.SeatType)(nowah.String(string(nowah.SeatWindow)))},
})raw, err := client.GetFlightInfo(ctx, nowah.GetFlightInfoParams{FlightNumber: "BA123"})
raw, err := client.GetBookingTracking(ctx, "booking_123")
raw, err := client.GetAirportDelays(ctx, "JFK")raw, err := client.GetVisaRequirements(ctx, "US", "JP")
raw, err := client.GetWeather(ctx, nowah.GetWeatherParams{
Location: nowah.String("Tokyo"), Type: (*nowah.WeatherType)(nowah.String(string(nowah.WeatherForecast))),
})
raw, err := client.ConvertCurrency(ctx, nowah.ConvertCurrencyParams{
From: "USD", To: "JPY", Amount: nowah.Float64(100),
})
raw, err := client.GetSafetyInfo(ctx, "JP")raw, err := client.FindPois(ctx, nowah.FindPoisParams{
Query: nowah.String("ramen"), Lat: 35.6762, Lon: 139.6503,
})
raw, err := client.GenerateItinerary(ctx, nowah.GenerateItineraryParams{
Lat: nowah.Float64(35.6762), Lon: nowah.Float64(139.6503),
Interests: []string{"food", "culture"},
})raw, err := client.CheckClaimEligibility(ctx, nowah.CheckClaimEligibilityParams{
BookingID: "book_123", ClaimType: nowah.ClaimDelay,
})
raw, err := client.FileClaim(ctx, nowah.FileClaimParams{
BookingID: "book_123", ClaimType: nowah.ClaimDelay,
Description: "Flight delayed 4 hours", ContactEmail: "[email protected]",
})
raw, err := client.ListClaims(ctx, nil)raw, err := client.GetUsageStats(ctx, &nowah.GetUsageParams{
Period: (*nowah.UsagePeriod)(nowah.String(string(nowah.UsageMonth))),
})// Non-streaming
raw, err := client.ChatWithAgent(ctx, nowah.ChatWithAgentParams{
ThreadID: "thread_123", Message: "Find me a flight to Tokyo",
})
// Streaming
text, err := client.ChatWithAgentStream(ctx, nowah.ChatWithAgentStreamParams{
ThreadID: "thread_123", Message: "Find me a flight to Tokyo",
})import "errors"
raw, err := client.GetTrip(ctx, "trip_123")
if err != nil {
var apiErr *nowah.Error
if errors.As(err, &apiErr) {
fmt.Printf("Status: %d, Code: %s, Message: %s\n",
apiErr.StatusCode, apiErr.Code, apiErr.Message)
}
// Match sentinel errors
if errors.Is(err, nowah.ErrNotFound) {
fmt.Println("Trip not found")
}
if errors.Is(err, nowah.ErrUnauthorized) {
fmt.Println("Invalid API key")
}
if errors.Is(err, nowah.ErrRateLimit) {
fmt.Println("Rate limited, try again later")
}
}- Retries on 5xx and network errors (default: 1 retry)
- Exponential backoff (1s base)
- Never retries 4xx errors
- Respects
context.Contextcancellation
The following methods automatically generate and send an X-Idempotency-Key header:
BookFlightBookHotelConfirmCancellationAddOrderServicesConfirmFlightChange
Use pointer helpers to set optional fields:
nowah.String("value") // *string
nowah.Int(42) // *int
nowah.Float64(3.14) // *float64
nowah.Bool(true) // *boolApache 2.0 - see LICENSE.