aviasales

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2017 License: MIT Imports: 6 Imported by: 0

README

go-aviasales-api

Golang implementation Aviasales API for data access

GoDoc

Installation

Stable release (v1):

go get gopkg.in/liderman/go-aviasales-api.v1

Non stable release (master branch):

go get github.com/liderman/go-aviasales-api

Usage

Creates a new instance AviasalesApi:

aviaApi := aviasales.NewAviasalesApi("YOUR_TOKEN")

Getting directions in which the airline operates flights sorted by popularity:

airlineDirections, err := aviaApi.AirlineDirections("SU", 10)

Requirements

  • Need at least go1.5 or newer.

Documentation

You can read package documentation here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Airline

type Airline struct {
	Name     string `json:"name" bson:"name"`
	Alias    string `json:"alias" bson:"alias"`
	Iata     string `json:"iata" bson:"iata"`
	Icao     string `json:"icao" bson:"icao"`
	Callsign string `json:"callsign" bson:"callsign"`
	Country  string `json:"country" bson:"country"`
	IsActive bool   `json:"is_active" bson:"is_active"`
}

type Airport

type Airport struct {
	Code             string            `json:"code" bson:"code"`
	Name             string            `json:"name" bson:"name"`
	Coordinates      Coordinates       `json:"coordinates" bson:"coordinates"`
	TimeZone         string            `json:"time_zone" bson:"time_zone"`
	CountryCode      string            `json:"country_code" bson:"country_code"`
	CityCode         string            `json:"city_code" bson:"city_code"`
	NameTranslations map[string]string `json:"name_translations" bson:"name_translations"`
}

type Alliance

type Alliance struct {
	Name     string   `json:"name" bson:"name"`
	Airlines []string `json:"alias" bson:"alias"`
}

type AviasalesApi

type AviasalesApi struct {
	// contains filtered or unexported fields
}

func NewAviasalesApi

func NewAviasalesApi(token string) *AviasalesApi

NewAviasalesApi creates a new instance AviasalesApi.

func (*AviasalesApi) AirlineDirections

func (a *AviasalesApi) AirlineDirections(airlineCode string, limit int) (airlineDirections DataAirlineDirections, err error)

AirlineDirections returns the ways in which the airline operates flights sorted by popularity.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#08

Example URI: http://api.travelpayouts.com/v1/airline-directions?airline_code=SU&limit=10&token=YOUR_TOKEN

func (*AviasalesApi) CityDirections

func (a *AviasalesApi) CityDirections(origin string) (flights DataCityDirectionsFlight, err error)

CityDirections returns most popular destinations from the specified city.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#20

Example URI: http://api.travelpayouts.com/v1/city-directions?origin=MOW&token=YOUR_TOKEN

func (*AviasalesApi) DataAirlines

func (a *AviasalesApi) DataAirlines() (airlines []Airline, err error)

DataAirlines a list of airlines from the database.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#12

Example URI: http://api.travelpayouts.com/data/airlines.json

func (*AviasalesApi) DataAirlinesAlliances

func (a *AviasalesApi) DataAirlinesAlliances() (airlinesAlliances []Alliance, err error)

DataAirlinesAlliances a list of alliances from the database.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#13

Example URI: http://api.travelpayouts.com/data/airlines_alliances.json

func (*AviasalesApi) DataAirports

func (a *AviasalesApi) DataAirports() (airports []Airport, err error)

DataAirports a list of airports in the database.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#11

Example URI: http://api.travelpayouts.com/data/airports.json

func (*AviasalesApi) DataCities

func (a *AviasalesApi) DataCities() (cities []City, err error)

DataCities returns a list of cities in the database.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#10

Example URI: http://api.travelpayouts.com/data/cities.json

func (*AviasalesApi) DataCountries

func (a *AviasalesApi) DataCountries() (countries []Country, err error)

DataCountries returns a list of countries from the database.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#09

Example URI: http://api.travelpayouts.com/data/countries.json

func (*AviasalesApi) DataPlanes

func (a *AviasalesApi) DataPlanes() (planes []Plane, err error)

DataPlanes a list of planes from the database.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#14

Example URI: http://api.travelpayouts.com/data/planes.json

func (*AviasalesApi) DataRoutes

func (a *AviasalesApi) DataRoutes() (routes []Route, err error)

DataRoutes a list of routes from the database.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#15

Example URI: http://api.travelpayouts.com/data/routes.json

func (*AviasalesApi) PricesCalendar

func (a *AviasalesApi) PricesCalendar(input InputPricesCalendar) (flights DataFlightCalendar, err error)

PricesCalendar returns the cheapest ticket (without transfer, with one or two changes) for the specified direction for each day of the selected month.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#07

Example URI: http://api.travelpayouts.com/v1/prices/calendar?depart_date=2016-11&origin=MOW&destination=BCN&calendar_type=departure_date&token=YOUR_TOKEN

func (*AviasalesApi) PricesCheap

func (a *AviasalesApi) PricesCheap(input InputPricesCheap) (flights DataFlight, err error)

PricesCheap returns the cheapest direct, as well as 1 and 2 transfers to the chosen direction with filters by date of departure and return. Tickets return flight there and back. Note! If the request specifies the old date, as a result of his work is not an error, but no data will not be back.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#05

Example URI: http://api.travelpayouts.com/v1/prices/cheap?origin=MOW&destination=HKT&depart_date=2016-11&return_date=2016-12&token=YOUR_TOKEN

func (*AviasalesApi) PricesDirect

func (a *AviasalesApi) PricesDirect(input InputPricesCheap) (flights DataFlight, err error)

PricesDirect returns the cheapest ticket direct to the chosen direction with filters by date of departure and return.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#06

Example URI: http://api.travelpayouts.com/v1/prices/direct?origin=MOW&destination=LED&depart_date=2016-11&return_date=2016-12&token=YOUR_TOKEN

func (*AviasalesApi) PricesLatest

func (a *AviasalesApi) PricesLatest(input InputPricesLatest) (prices DataPrice, err error)

PricesLatest returns a list of the prices found aviasales users in the last 48 hours, in accordance with the exposed filters. Note! If you do not specify a starting point and destination, the API returns 30 for the cheapest tickets, which were found in the last 48 hours.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#02

Example URI: http://api.travelpayouts.com/v2/prices/latest?currency=rub&period_type=year&page=1&limit=30&show_to_affiliates=true&sorting=price&trip_class=0&token=YOUR_TOKEN

func (*AviasalesApi) PricesMonthMatrix

func (a *AviasalesApi) PricesMonthMatrix(input InputPricesMonthMatrix) (prices DataPrice, err error)

PricesMonthMatrix returns the price for each day of the month, grouped by the number of transfer. Note! If you do not specify a starting point and destination, the API returns a list of the cheapest tickets, which were found in the last 48 hours.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#03

Example URI: http://api.travelpayouts.com/v2/prices/month-matrix?currency=rub&origin=LED&destination=HKT&show_to_affiliates=true&token=YOUR_TOKEN

func (*AviasalesApi) PricesNearestPlacesMatrix

func (a *AviasalesApi) PricesNearestPlacesMatrix(input InputPricesNearestPlacesMatrix) (prices DataPriceNearest, err error)

PricesNearestPlacesMatrix returns prices directions between nearest to the target cities. Note! If you do not specify a starting point and destination, the API returns a list of the cheapest tickets, which were found in the last 48 hours.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#04

Example URI: http://api.travelpayouts.com/v2/prices/nearest-places-matrix?currency=rub&origin=LED&destination=HKT&show_to_affiliates=true&token=YOUR_TOKEN

func (*AviasalesApi) SetLogger

func (a *AviasalesApi) SetLogger(logger LoggerInterface)

func (*AviasalesApi) SpecialOffers added in v1.0.0

func (a *AviasalesApi) SpecialOffers() (specialOffers []SpecialOffer, err error)

SpecialOffers returns latest special offers from airlines.

Documentation: https://support.travelpayouts.com/hc/ru/articles/203956163#18

Example URI: http://api.travelpayouts.com/v2/prices/special-offers?token=YOUR_TOKEN

type City

type City struct {
	Code             string            `json:"code" bson:"code"`
	Name             string            `json:"name" bson:"name"`
	Coordinates      Coordinates       `json:"coordinates" bson:"coordinates"`
	TimeZone         string            `json:"time_zone" bson:"time_zone"`
	CountryCode      string            `json:"country_code" bson:"country_code"`
	NameTranslations map[string]string `json:"name_translations" bson:"name_translations"`
}

type Coordinates

type Coordinates struct {
	Lon float64 `json:"lon" bson:"lon"`
	Lan float64 `json:"lat" bson:"lat"`
}

type Country

type Country struct {
	Code             string            `json:"code" bson:"code"`
	Name             string            `json:"name" bson:"name"`
	Currency         string            `json:"currency" bson:"currency"`
	NameTranslations map[string]string `json:"name_translations" bson:"name_translations"`
}

type DataAirlineDirections

type DataAirlineDirections struct {
	Success  bool           `json:"success" bson:"success"`
	Data     map[string]int `json:"data" bson:"data"`
	Error    string         `json:"error" bson:"error"`
	Currency string         `json:"currency" bson:"currency"`
}

type DataCityDirectionsFlight

type DataCityDirectionsFlight struct {
	Success bool              `json:"success" bson:"success"`
	Data    map[string]Flight `json:"data" bson:"data"`
}

type DataFlight

type DataFlight struct {
	Success bool                         `json:"success" bson:"success"`
	Data    map[string]map[string]Flight `json:"data" bson:"data"`
}

type DataFlightCalendar

type DataFlightCalendar struct {
	Success bool                      `json:"success" bson:"success"`
	Data    map[string]FlightCalendar `json:"data" bson:"data"`
}

type DataPrice

type DataPrice struct {
	Success bool    `json:"success" bson:"success"`
	Data    []Price `json:"data" bson:"success"`
}

type DataPriceNearest

type DataPriceNearest struct {
	Success bool           `json:"success" bson:"success"`
	Data    []PriceNearest `json:"data" bson:"data"`
}

type Flight

type Flight struct {
	Price        int    `json:"price" bson:"price"`
	Airline      string `json:"airline" bson:"airline"`
	FlightNumber int    `json:"flight_number" bson:"flight_number"`
	DepartureAt  string `json:"departure_at" bson:"departure_at"`
	ReturnAt     string `json:"return_at" bson:"return_at"`
	ExpiresAt    string `json:"expires_at" bson:"expires_at"`
}

type FlightCalendar

type FlightCalendar struct {
	Price        int    `json:"price" bson:"price"`
	Airline      string `json:"airline" bson:"airline"`
	FlightNumber int    `json:"flight_number" bson:"flight_number"`
	DepartureAt  string `json:"departure_at" bson:"departure_at"`
	ReturnAt     string `json:"return_at" bson:"return_at"`
	ExpiresAt    string `json:"expires_at" bson:"expires_at"`
	Origin       string `json:"origin" bson:"origin"`
	Destination  string `json:"destination" bson:"destination"`
	Transfers    int    `json:"transfers" bson:"transfers"`
}

type InputPricesCalendar

type InputPricesCalendar struct {
	Origin       string
	Destination  string
	DepartDate   string
	ReturnDate   string
	CalendarType string
	TripDuration int
	Currency     string
}

type InputPricesCheap

type InputPricesCheap struct {
	Origin      string
	Destination string
	DepartDate  string
	ReturnDate  string
	Currency    string
}

type InputPricesLatest

type InputPricesLatest struct {
	Currency          string
	Origin            string
	Destination       string
	BeginningOfPeriod string
	PeriodType        string
	OneWay            bool
	Page              int
	Limit             int
	ShowToAffiliates  bool
	Sorting           string
	TripClass         int
	TripDuration      string
}

type InputPricesMonthMatrix

type InputPricesMonthMatrix struct {
	Currency         string
	Origin           string
	Destination      string
	ShowToAffiliates bool
	Month            string
}

type InputPricesNearestPlacesMatrix

type InputPricesNearestPlacesMatrix struct {
	Currency         string
	Origin           string
	Destination      string
	ShowToAffiliates bool
	DepartDate       string
	ReturnDate       string
}

type InputPricesWeekMatrix

type InputPricesWeekMatrix struct {
	Currency         string
	Origin           string
	Destination      string
	ShowToAffiliates bool
	DepartDate       string
	ReturnDate       string
}

type LoggerInterface

type LoggerInterface interface {
	Debug(...interface{})
}

type Plane

type Plane struct {
	Code string `json:"code" bson:"code"`
	Name string `json:"name" bson:"name"`
}

type Price

type Price struct {
	Actual           bool   `json:"actual" bson:"actual"`
	DepartDate       string `json:"depart_date" bson:"depart_date"`
	Destination      string `json:"destination" bson:"destination"`
	Distance         int    `json:"distance" bson:"distance"`
	FoundAt          string `json:"found_at" bson:"found_at"`
	NumberOfChanges  int    `json:"number_of_changes" bson:"number_of_changes"`
	Origin           string `json:"origin" bson:"origin"`
	ReturnDate       string `json:"return_date" bson:"return_date"`
	ShowToAffiliates bool   `json:"show_to_affiliates" bson:"show_to_affiliates"`
	TripClass        int    `json:"trip_class" bson:"trip_class"`
	Value            int    `json:"value" bson:"value"`
}

type PriceNearest

type PriceNearest struct {
	Origins      []string `json:"origins" bson:"origins"`
	Destinations []string `json:"destinations" bson:"destinations"`
	Prices       []Price  `json:"prices" bson:"prices"`
}

type Route

type Route struct {
	AirlineIata          string   `json:"airline_iata" bson:"airline_iata"`
	AirlineIcao          string   `json:"airline_icao" bson:"airline_icao"`
	DepartureAirportIata string   `json:"departure_airport_iata" bson:"departure_airport_iata"`
	DepartureAirportIcao string   `json:"departure_airport_icao" bson:"departure_airport_icao"`
	ArrivalAirportIata   string   `json:"arrival_airport_iata" bson:"arrival_airport_iata"`
	ArrivalAirportIcao   string   `json:"arrival_airport_icao" bson:"arrival_airport_icao"`
	Codeshare            bool     `json:"codeshare" bson:"codeshare"`
	Transfers            int      `json:"transfers" bson:"transfers"`
	Planes               []string `json:"planes" bson:"planes"`
}

type SpecialOffer added in v1.0.0

type SpecialOffer struct {
	Airline         string              `xml:"airline,attr" json:"airline" bson:"airline"`
	AirlineCode     string              `xml:"airline_code,attr" json:"airline_code" bson:"airline_code"`
	Title           string              `xml:"title,attr" json:"title" bson:"title"`
	Id              int                 `xml:"id,attr" json:"id" bson:"id"`
	Href            string              `xml:"href,attr" json:"href" bson:"href"`
	SaleDateBegin   int                 `xml:"sale_date_begin,attr" json:"sale_date_begin" bson:"sale_date_begin"`
	SaleDateEnd     int                 `xml:"sale_date_end,attr" json:"sale_date_end" bson:"sale_date_end"`
	FlightDateBegin int                 `xml:"flight_date_begin,attr" json:"flight_date_begin" bson:"flight_date_begin"`
	FlightDateEnd   int                 `xml:"flight_date_end,attr" json:"flight_date_end" bson:"flight_date_end"`
	Link            string              `xml:"link,attr" json:"link" bson:"link"`
	Description     string              `xml:"description" json:"description" bson:"description"`
	Conditions      string              `xml:"conditions" json:"conditions" bson:"conditions"`
	Routes          []SpecialOfferRoute `xml:"route" json:"routes" bson:"routes"`
}

type SpecialOfferRoute added in v1.0.0

type SpecialOfferRoute struct {
	FromIata       string `xml:"from_iata,attr" json:"from_iata" bson:"from_iata"`
	ToIata         string `xml:"to_iata,attr" json:"to_iata" bson:"to_iata"`
	FromName       string `xml:"from_name,attr" json:"from_name" bson:"from_name"`
	ToName         string `xml:"to_name,attr" json:"to_name" bson:"to_name"`
	Class          string `xml:"class,attr" json:"class" bson:"class"`
	OnewayPrice    string `xml:"oneway_price,attr" json:"oneway_price" bson:"oneway_price"`
	RoundtripPrice string `xml:"roundtrip_price,attr" json:"roundtrip_price" bson:"roundtrip_price"`
}

type XMLSpecialOffers added in v1.0.0

type XMLSpecialOffers struct {
	XMLName xml.Name       `xml:"offers"`
	Offers  []SpecialOffer `xml:"offer"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL