Skyscanner API Objective-C
You can use the Skyscanner Flight Search API with Objective-C by utilizing unirest.
Requirements
The Unirest-Obj-C client library requires ARC (Automatic Reference Counting) to be enabled in your Xcode project. To enable ARC select your project or target and then go to Build Settings and under the section Apple LLVM compiler 3.0 – Language you will see the option Objective-C Automatic Reference Counting:
For existing projects, fortunately, Xcode offers a tool to convert existing code to ARC, which is available at Edit -> Refactor -> Convert to Objective-C ARC
Installing & Making a Request
Download the Objective-C Unirest Library from GitHub (or clone the repo) and import the folder into your project. You can also install Unirest-obj-c with CocoaPods.
Using CocoaPods
If you decide to use CocoaPods, create a Podfile file in your project’s folder:
$ edit Podfile platform :ios, '5.0' pod 'Unirest', '~> 1.1.4'
and then execute pod install. Make sure to always open the Xcode workspace instead of the project file when building your project:
$ open App.xcworkspace
Now you can import your dependencies:
#import <UNIRest.h> NSDictionary *headers = @{@"Authorization": @"", @"X-RapidAPI-Key": @API_KEY, @"Content-Type": @"application/x-www-form-urlencoded"}; UNIUrlConnection *asyncConnection = [[UNIRest post:^(UNISimpleRequest *request) { [request setUrl:@API_URL]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
How to Start
- Navigate to the Skyscanner Flight Search API Documentation Page.
- Select an endpoint you would like to use and select Objective-C from the Code Snippet dropdown.
- Copy the code snippet and apply it to your application!
What data is available with the Skyscanner Flight Search API?
Browse the available API endpoints & example code snippets below for available data & datasets for flights using Skyscanner API (in Objective-C).
Live Flight Search
POST Create Session
Create a flight search session. A successful response contains no content. The session key to poll the results are provided in the Location header of the response. The last value of the location header contains the session key which is required when polling the session.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY", @"Content-Type": @"application/x-www-form-urlencoded"}; NSDictionary *parameters = @{@"inboundDate": @"2019-09-10", @"cabinClass": @"business", @"children": @(0), @"infants": @(0), @"country": @"US", @"currency": @"USD", @"locale": @"en-US", @"originPlace": @"SFO-sky", @"destinationPlace": @"LHR-sky", @"outboundDate": @"2019-09-01", @"adults": @(1)}; UNIUrlConnection *asyncConnection = [[UNIRest post:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/pricing/v1.0"]; [request setHeaders:headers]; [request setParameters:parameters]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
GET Poll Session Results
Get itineraries from a created session.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/pricing/uk2/v1.0/{sessionkey}?pageIndex=0&pageSize=10"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
Places
GET List Places
Get a list of places that match a query string.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/autosuggest/v1.0/UK/GBP/en-GB/?query=Stockholm"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
Browse Flight Prices
GET Browse Quotes
Retrieve the cheapest quotes from our cache prices.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/browsequotes/v1.0/US/USD/en-US/SFO-sky/JFK-sky/2019-01-01?inboundpartialdate=2019-09-01"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
GET Browse Routes
Retrieve the cheapest routes from our cache prices. Similar to the Browse Quotes API but with the routes built for you from the individual quotes.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/browseroutes/v1.0/US/USD/en-US/SFO-sky/ORD-sky/2019-01-01?inboundpartialdate=2019-09-01"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
GET Browse Dates
Retrieve the cheapest dates for a given route from our cache.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/browsedates/v1.0/US/USD/en-US/SFO-sky/LAX-sky/2019-01-01?inboundpartialdate=2019-09-01"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
GET Browse Dates Inbound
Retrieve the cheapest dates for a given route from our cache. Must include inboundpartialdate
.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/browsedates/v1.0/{country}/{currency}/{locale}/{originplace}/{destinationplace}/{outboundpartialdate}/{inboundpartialdate}"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
GET Browse Quotes Inbound
Retrieve the cheapest quotes from our cache prices. Must include inboundpartialdate.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/browsequotes/v1.0/{country}/{currency}/{locale}/{originplace}/{destinationplace}/{outboundpartialdate}/{inboundpartialdate}"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
GET Browse Routes Inbound
Retrieve the cheapest routes from our cache prices. Similar to the Browse Quotes API but with the routes built for you from the individual quotes. Must include inboundpartialdate
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/browseroutes/v1.0/{country}/{currency}/{locale}/{originplace}/{destinationplace}/{outboundpartialdate}/{inboundpartialdate}"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
Localisation
GET List markets
Retrieve the market countries that we support. Most suppliers (airlines, travel agents and car hire dealers) set their fares based on the market (or country of purchase). It is, therefore, necessary to specify the market country in every query.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/reference/v1.0/countries/en-US"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];
GET Currencies
Retrieve the currencies that we support.
NSDictionary *headers = @{@"X-RapidAPI-Host": @"skyscanner-skyscanner-flight-search-v1.p.rapidapi.com", @"X-RapidAPI-Key": @"SIGN-UP-FOR-KEY"}; UNIUrlConnection *asyncConnection = [[UNIRest get:^(UNISimpleRequest *request) { [request setUrl:@"https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/reference/v1.0/currencies"]; [request setHeaders:headers]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];