Giter VIP home page Giter VIP logo

flight-api's Introduction

Flight-Search API

A RESTful API built using Spring Boot to search for available flights between given origins and destinations. It supports pagination and sorting by various parameters.

Features

  • Find list of flights from Origin to Destination.
  • Sort results based on multiple fields (e.g., price, departure time).
  • Paginate results.

Requirements

  • Java 11 or later
  • Maven

How to Run

  1. Clone the repository: git clone https://github.com/your-repo/flight-search-api.git
  2. Navigate to the project directory: cd flight-search-api
  3. Edit the application.properties for MySQL DB connection.
  4. Build the project: mvn clean install
  5. Run the application: mvn spring-boot:run

Endpoints

Get Flights

Request

Swagger UI : http://localhost:8080/swagger-ui/index.html

GET /flights?origin=AMS&destination=DEL
GET /flights?origin=AMS&destination=DEL&page=1&size=10
GET /flights?origin=AMS&destination=DEL&sortFields=price,departureTime&sortDirections=asc,desc&page=1&size=10

Parameters

  • origin (required): The origin airport code.
  • destination (required): The destination airport code.
  • sortFields (optional): The fields by which to sort the results. Comma-separated.
  • sortDirections (optional): The direction ('asc' or 'desc') for each sort field. Comma-separated.
  • page (optional): The page number for pagination. Default is 0.
  • size (optional): The number of records per page. Default is 10.

Response

Returns a JSON object containing the flight data and pagination information.

Dependencies

  • Spring Web
  • Spring Data JPA
  • H2 Database / MySQL

Add the following to your pom.xml:

<dependencies>
<!-- Spring Web -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Spring Data JPA -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- H2 Database -->
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>runtime</scope>
</dependency>
</dependencies>

Author contact details

flight-api's People

Contributors

yarish avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.