Skip to content

API Debugging Guide

This is a quick guide for scraping flights.

Prerequisites

Screenshots in this guide will be using the recommended software. You are welcome to use whatever development environment you'd like.

Finding the Search API

After you have selected an airline to search, navigate to their website. This guide will use Aer Lingus as an example.

  1. Open your networking tab in developer tools and monitor XMLHttpRequests. Make sure to disable cache and enable full logs. Screenshot
  2. Search for a random flight using the web interface. I typically choose LAX to LHR with random dates as there's typically flights available. If there isn't one, pick a route that this carrier services. Screenshot
  3. Find the request that is most likely to correspond to a search for flights. Note request headers, parameters, and request body as well as response headers and body. This is usually a GET or POST request. Request data usually includes information about the airports and dates, and response data usually includes information including flights and prices. Please note sometimes this is separated into multiple requests. Screenshot
  4. Import this request into your REST API client. Replay the request to verify you can still make the request. (If you can't, you'll need to skip to the advanced debugging section.) Screenshot
  5. Disable headers and query parameters until you found the minimum parameters required to execute a successful search. Document all the search parameters in a note file for later use.

Session Tokens

Some airlines use session tokens. In this example, Aer Lingus uses cookies to ensure that the session is recent. You'll have to backtrack and figure out how to store your session manually. I don't have time to write this guide, so you can simply make a note of it and not do this part if you can't figure it out.

Advanced Debugging

If you can't make the request after importing it into a REST client, the airline uses tactics to prevent you from scraping their flights. This is highly unlikely so the fact that you are reading this section means you can also figure it out on your own. If you can't, make a note of it and pick another airline.