/formula-one-api

Formula One api

Primary LanguageJava

Formula-one-api

About

This project is an api (similar to Ergast) for getting formula one data in a restful representation. I made this project to learn and use Spring, REST & JPA/Hibernate and to test on different relational databases.

The following topics are covered:

  • A relational database that holds data about Formula One.
  • A REST service that exposes the data in the database.
  • Rest documentation with swagger

Quick start guide

Import database data:

MySQL

In MySQL Workbench:

  1. Click on Server tab
  2. Click on Data import menu
  3. Select import from Self-Contained file and navigate to the MySQL sql script
  4. Press Start import

With command line:

mysql -u username -p password f1db < /path/to/f1dbmysql20150323.sql

Postgresql:

In pgAdmin3:

  1. select the required target schema in object tree
  2. Click on Plugins/PSQL Console
  3. Write: \i /path/to/yourfile.sql
  4. Press enter

With command line:

psql -U postgres -d f1db -f /path/to/f1dbpostgresql20150323.sql

SQL scripts:

Configure application

Adjust application.properties to let it work on your local setup.

examples:

Running this application

To run this project: Navigate to main with command line tool

  • mvn clean install

Than navigate to main/rest with command line tool to run it

  • mvn clean jetty:run -P dev

Then point your browser to the Swagger api documentation link available at: http://localhost:8080/swagger-ui.html

It will provide an user interface which visualizes an applications JSON api.

Note: still XML representation is also supported in my REST webservice but not available in Swagger because it only supports JSON.

Technologies:

TODO:

  • Enable and configure travis-ci for running builds/tests
  • A lot more api endpoints that need to be added

Attribution

  • Thanks to Ergast for the usage and keeping the database up to date
  • Thanks to Spring for the useful guides
  • Thanks to pkainulainen for the useful tutorials and examples
  • Thanks to lanyrd for his mysql to postgresql script converter