Easy access from R to the QPX Express Airfare API
You can install the package using the devtools package as follows:
devtools::install_github("RossiLorenzo/QPXapi")
There is only one exported function in the package called QPX
. Using this function you'll connect to the API and download the JSON data obtained. You can then choose to get the results as they are or reshaped in a R data.frame (only a subset of fields). For example:
res <- QPX(apikey = "yourapikey", origin = "PSA", destination = "LON", date = Sys.Date() + 1)
this call will return the flights from Pisa to London for tomorrow in a R data.frame
In order to use this package you need to obtain an API key. You can find a comprehensive guide on how to do this HERE. The main steps are:
- If you don't have one, get a Google account
- Go to the Google Developers Console
- Create a New Project and give it the name you like the most
- On the sidebar menu click on APIs & Auth -> APIs
- In the search box digit QPX and then click on the result (QPX Express Airfare API)
- Click on the blue button: 'Enable API'
- In the sidebar menu select Credentials
- Click on Add credentials and then choose API key -> server key
- Create the key
- You should now have you personal API key. Do not share it with anyone.