Versions in this module Expand all Collapse all v1 v1.0.0 Nov 15, 2026 Changes in this version + const DefaultBaseURL + const DefaultTimeout + const DefaultWebhookTolerance + const DeliveryAttemptHeader + const EventIDHeader + const EventTypeHeader + const MaxWebhookBodyBytes + const SignatureHeader + const SubscriptionIDHeader + const TimestampHeader + const Version + var ErrBadRequest = errors.New("flightbyte: bad request") + var ErrEmptySecret = errors.New("flightbyte: the webhook signing secret is empty") + var ErrForbidden = errors.New("flightbyte: forbidden") + var ErrInvalidSignature = errors.New("flightbyte: invalid webhook signature") + var ErrNotFound = errors.New("flightbyte: not found") + var ErrPaymentRequired = errors.New("flightbyte: payment required") + var ErrRateLimited = errors.New("flightbyte: rate limited") + var ErrServer = errors.New("flightbyte: server error") + var ErrUnauthorized = errors.New("flightbyte: unauthorized") + var ErrUpstream = errors.New("flightbyte: upstream unavailable") + var FlightChangeTypes = []FlightChangeType + func FormatDate(t time.Time) string + func MaskSecret(secret string) string + func Ptr[T any](v T) *T + func SignWebhook(payload []byte, secret string, at time.Time) string + func VerifyWebhook(payload []byte, signature, secret string, opts ...VerifyOption) error + func WebhookHandler(secret string, handle func(context.Context, *WebhookEvent) error, ...) http.Handler + type APIError struct + Balance *int + Body map[string]any + CapCents *int + Code string + ExpiresAt *time.Time + Header http.Header + Legs []AmbiguousLeg + Limit *int + Messages []string + RawBody []byte + RequestID string + ResetsAt *time.Time + RetryAfter time.Duration + StatusCode int + Used *int + Window string + func (e *APIError) Error() string + func (e *APIError) Is(target error) bool + type Airport struct + City string + Code string + Country CountryRef + IATA string + ICAO string + Name string + State string + Timezone string + type AmbiguousLeg struct + Carrier string + Destination string + FlightID string + Origin string + ScheduledDepartureLocal string + type Carrier struct + IATA string + ICAO string + Name string + type Client struct + Countries *CountriesService + Flights *FlightsService + Subscriptions *SubscriptionsService + func NewClient(apiKey string, opts ...Option) (*Client, error) + func (c *Client) BaseURL() string + func (c *Client) LastRateLimit() *RateLimit + type Codeshare struct + Carrier string + FlightNumber string + Name string + type ConnectionError struct + Err error + Method string + URL string + func (e *ConnectionError) Error() string + func (e *ConnectionError) Unwrap() error + type CountriesService struct + func (s *CountriesService) FlagURL(code string, square bool) string + func (s *CountriesService) Get(ctx context.Context, code, lang string) (*Country, error) + func (s *CountriesService) List(ctx context.Context, lang string) ([]Country, error) + type Country struct + Alpha2 string + HasFlag bool + type CountryRef struct + Code string + Emoji string + FlagSVG string + FlagSVGSquare string + Name string + type CreateSubscriptionParams struct + Carrier string + Date string + DelayThresholdMinutes *int + Destination string + Events []FlightChangeType + FlightID string + FlightNumber string + Headers map[string]string + IdempotencyKey string + Metadata map[string]string + Origin string + Secret string + WebhookURL string + type CreatedSubscription struct + Flight *Flight + Reused bool + Secret string + type Delivery struct + At time.Time + Attempt int + ChangeTypes []FlightChangeType + DurationMs int + Error string + EventID string + HTTPStatus *int + Status DeliveryStatus + type DeliveryStatus string + const DeliveryDelivered + const DeliveryFailed + func (s DeliveryStatus) Known() bool + type Endpoint struct + Airport Airport + Baggage string + BestTimeUTC *time.Time + DelayMinutes *int + Gate string + Terminal string + Times EndpointTimes + type EndpointTimes struct + ActualGate *FlightTime + ActualRunway *FlightTime + EstimatedGate *FlightTime + EstimatedRunway *FlightTime + ScheduledGate *FlightTime + ScheduledRunway *FlightTime + func (t EndpointTimes) BestGate() *FlightTime + type Equipment struct + IATA string + Name string + Source string + TailNumber string + type Flight struct + Alternates []FlightLeg + Arrival Endpoint + Cached bool + Carrier Carrier + CarrierCode string + Codeshares []Codeshare + Date string + Departure Endpoint + Diverted *Endpoint + Duration FlightDuration + Equipment Equipment + FetchedAt time.Time + Fingerprint string + FlightKey string + FlightNumber string + OperatedBy string + ProviderFlightID string + Status FlightStatus + Timeline []TimelineEntry + type FlightChange struct + DeltaMinutes *int + From any + Message string + Path string + To any + Type FlightChangeType + type FlightChangeType string + const ChangeAircraft + const ChangeArrivalActual + const ChangeArrivalEstimated + const ChangeArrivalGate + const ChangeArrivalScheduled + const ChangeArrivalTerminal + const ChangeArrived + const ChangeBaggage + const ChangeCancelled + const ChangeCodeshares + const ChangeDelayDecreased + const ChangeDelayIncreased + const ChangeDeparted + const ChangeDepartureActual + const ChangeDepartureEstimated + const ChangeDepartureGate + const ChangeDepartureScheduled + const ChangeDepartureTerminal + const ChangeDiverted + const ChangeReinstated + const ChangeRoute + const ChangeStatus + const ChangeTailNumber + func (t FlightChangeType) Known() bool + type FlightDuration struct + ActualMinutes *int + EstimatedMinutes *int + ScheduledMinutes *int + type FlightLeg struct + ArrivalIATA string + Carrier string + DepartureIATA string + ProviderFlightID string + ScheduledArrivalLocal string + ScheduledDepartureLocal string + Selected bool + type FlightParams struct + Carrier string + Date string + Destination string + FlightID string + FlightNumber string + Origin string + Refresh bool + type FlightPhase string + const PhaseArrived + const PhaseBoarding + const PhaseCancelled + const PhaseDeparted + const PhaseDiverted + const PhaseEnRoute + const PhaseLanded + const PhaseRedirected + const PhaseScheduled + const PhaseUnknown + func (p FlightPhase) IsTerminal() bool + func (p FlightPhase) Known() bool + type FlightStatus struct + ArrivalGateDelayMinutes *int + Cancelled bool + Code string + Color string + Delayed bool + DepartureGateDelayMinutes *int + Description string + Diverted bool + Label string + Phase FlightPhase + type FlightTime struct + Local string + Timezone string + UTC time.Time + type FlightTimeline struct + Count int + Entries []TimelineEntry + FlightKey string + type FlightsService struct + func (s *FlightsService) Get(ctx context.Context, params FlightParams) (*Flight, error) + func (s *FlightsService) Timeline(ctx context.Context, params FlightParams) (*FlightTimeline, error) + type ListSubscriptionsParams struct + Carrier string + Date string + FlightNumber string + Limit int + Offset int + Status SubscriptionStatus + type Option func(*Client) error + func WithBaseURL(baseURL string) Option + func WithHTTPClient(httpClient *http.Client) Option + func WithTimeout(timeout time.Duration) Option + func WithUserAgent(userAgent string) Option + type RateLimit struct + Day *RateLimitWindow + Minute *RateLimitWindow + Month *RateLimitWindow + type RateLimitWindow struct + Limit int + Remaining int + ResetAt time.Time + func (w RateLimitWindow) String() string + type Subscription struct + Carrier string + CreatedAt time.Time + Date string + DelayThresholdMinutes int + DeliveredCount int + Events []FlightChangeType + FailedCount int + FlightKey string + FlightNumber string + FlightResolved bool + Headers map[string]string + ID string + LastChangeAt *time.Time + LastDeliveryAt *time.Time + LastPolledAt *time.Time + Metadata map[string]string + SecretHint string + Status SubscriptionStatus + StatusReason string + UpdatedAt time.Time + WebhookURL string + type SubscriptionPage struct + Items []Subscription + Limit int + Offset int + Total int + func (p *SubscriptionPage) HasMore() bool + func (p *SubscriptionPage) NextOffset() int + type SubscriptionStatus string + const StatusActive + const StatusCompleted + const StatusPaused + const StatusPending + const StatusSuspended + func (s SubscriptionStatus) Known() bool + type SubscriptionsService struct + func (s *SubscriptionsService) All(ctx context.Context, params ListSubscriptionsParams) iter.Seq2[*Subscription, error] + func (s *SubscriptionsService) Create(ctx context.Context, params CreateSubscriptionParams) (*CreatedSubscription, error) + func (s *SubscriptionsService) Delete(ctx context.Context, id string) error + func (s *SubscriptionsService) Deliveries(ctx context.Context, id string, limit int) ([]Delivery, error) + func (s *SubscriptionsService) Events(ctx context.Context, id string, limit int) ([]WebhookEvent, error) + func (s *SubscriptionsService) Get(ctx context.Context, id string) (*Subscription, error) + func (s *SubscriptionsService) List(ctx context.Context, params ListSubscriptionsParams) (*SubscriptionPage, error) + func (s *SubscriptionsService) Pause(ctx context.Context, id string) (*Subscription, error) + func (s *SubscriptionsService) Resume(ctx context.Context, id string) (*Subscription, error) + func (s *SubscriptionsService) RotateSecret(ctx context.Context, id string) (string, error) + func (s *SubscriptionsService) Secret(ctx context.Context, id string) (string, error) + func (s *SubscriptionsService) SendTest(ctx context.Context, id string) (string, error) + func (s *SubscriptionsService) Update(ctx context.Context, id string, params UpdateSubscriptionParams) (*Subscription, error) + type TimelineEntry struct + Events []string + OccurredAt time.Time + Source string + Title string + type UpdateSubscriptionParams struct + DelayThresholdMinutes *int + Events []FlightChangeType + Headers map[string]string + Metadata map[string]string + WebhookURL string + type VerifyOption func(*verifyConfig) + func WithErrorHandler(report func(r *http.Request, event *WebhookEvent, err error)) VerifyOption + func WithNow(now time.Time) VerifyOption + func WithTolerance(tolerance time.Duration) VerifyOption + type WebhookEvent struct + Changes []FlightChange + CreatedAt time.Time + Flight *Flight + FlightKey string + ID string + Metadata map[string]string + PreviousFetchedAt *time.Time + SubscriptionID string + Type WebhookEventType + func ConstructWebhookEvent(payload []byte, signature, secret string, opts ...VerifyOption) (*WebhookEvent, error) + type WebhookEventType string + const EventFlightUpdated + const EventSubscriptionActivated + const EventSubscriptionCompleted + const EventSubscriptionCreated + const EventSubscriptionSuspended + const EventSubscriptionTest + func (t WebhookEventType) Known() bool + type WebhookSignatureError struct + Reason string + func (e *WebhookSignatureError) Error() string + func (e *WebhookSignatureError) Is(target error) bool