Requirements • First setup • Gems • Endpoints
This project is a RoR API that reproduces the main behavior of Badi. The main features that our API implements are:
- Search locations based on user input
- Search rooms by location (bounding box)
- Detailed room representation
- Similar rooms based on location and price
- Ruby 2.6.5
- Rails > 6.0.2.1
- PostgreSQL 12
- PostGIS 12
Make sure all requirements are available and clone the repository:
git clone https://github.com/assimovt/badigeeks-api.gitInstall all the gems
$ bundle installAs the project uses dotenv, you must setup your environment credentials in side a new file:
$ cp .env .env.development.localOnce the credentials for the database are set, you should create the database
$ rails db:create- GET Location query
- URI: /locations?keyword=place
- Return all the locations that match the keyword parameter
- Uses Nominatim as search engine
- Working exemple
| Mandatory params | Value | Notes |
|---|---|---|
| keyword | “Any place you want to search rooms” | Must contain at least 3 letters to work properly |
- GET List rooms
- URI: /rooms?bounds=2.109375,41.345887,2.254601,41.445557&page=1&size=20&order_type=price&order=ASC
- Return all the rooms within the perimeter
- Working example
| Mandatory params | Value | Notes |
|---|---|---|
| bounds | “minimumLongitude, minimumLatitude, maximumLongitude, maximumLatitude” | Bounds represents the square where you want to look for rooms |
| Optional params | Value | Notes |
|---|---|---|
| page | 1…* | Overflow is handled |
| size | 1…* | Specify how many items per page. Overflow is handled |
| order_type | “the attribute you want to use to sort” | You can only sort by “price” at the moment |
| order | [ASC, asc, DESC, desc] | |
| min | 1...10000 | Limit minimum price |
| max | 1...10000 | Limit maximum price |
- GET Specific room
- URI: /rooms/:id
- Return the details of a specific room by the room id
- Working example
The current approach for the model structure can be found in the image below. It includes the defined models with its fields and associations among them.
In order to fill the database, you will have to execute the following command:
rake badi_api_request: request_fill_dbThis task scrapes the data from Badi’s API in order to use real data.

