All Projects → Raouf25 → Spring-Boot-efficient-search-API

Raouf25 / Spring-Boot-efficient-search-API

Licence: Apache-2.0 license
medium.com/quick-code/spring-boot-how-to-design-efficient-search-rest-api-c3a678b693a0?source=friends_link&sk=a9344c624d6e61b0fa8f42a9e1fcfcbe

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Spring-Boot-efficient-search-API

beacon-APIs
Collection of RESTful APIs provided by Ethereum Beacon nodes
Stars: ✭ 209 (+231.75%)
Mutual labels:  specification
specs
Kontalk specifications and documentation
Stars: ✭ 20 (-68.25%)
Mutual labels:  specification
test-suite
An automated test of Solid specification technical compliance
Stars: ✭ 20 (-68.25%)
Mutual labels:  specification
framework
Lightweight, open source and magic-free framework for testing solidity smart contracts.
Stars: ✭ 36 (-42.86%)
Mutual labels:  specification
LinqSpecs
A toolset for use the specification pattern in LINQ queries.
Stars: ✭ 161 (+155.56%)
Mutual labels:  specification
hcert-spec
Electronic Health Certificates Specification
Stars: ✭ 363 (+476.19%)
Mutual labels:  specification
openapi-types.ts
Generated TypeScript definitions based on GitHub's OpenAPI spec
Stars: ✭ 30 (-52.38%)
Mutual labels:  specification
openapi
GitHub's official OpenAPI spec with Octokit extensions
Stars: ✭ 24 (-61.9%)
Mutual labels:  specification
iqm-exm
IQM & EXM model format specs, Blender exporter, and LÖVE loader.
Stars: ✭ 35 (-44.44%)
Mutual labels:  specification
es-abstract
ECMAScript spec abstract operations.
Stars: ✭ 86 (+36.51%)
Mutual labels:  specification
gender-render
Template-system and proof-of-concept for rendering gender-neutral text-, email- and RPG-text-templates with the correct pronouns of all people involved.
Stars: ✭ 21 (-66.67%)
Mutual labels:  specification
kekiri
A .NET framework that supports writing low-ceremony BDD tests using Gherkin language
Stars: ✭ 19 (-69.84%)
Mutual labels:  specification
security-policy-specification-standard
This document proposes a way of standardising the structure, language, and grammar used in security policies.
Stars: ✭ 24 (-61.9%)
Mutual labels:  specification
openapi
OpenAPI 3 Specification for golang
Stars: ✭ 18 (-71.43%)
Mutual labels:  specification
cim-spec
This repository hosts the specification for the Cartographic Information Model
Stars: ✭ 45 (-28.57%)
Mutual labels:  specification
ortac
Runtime assertion checking based on Gospel specifications
Stars: ✭ 16 (-74.6%)
Mutual labels:  specification
Specification
Working towards a new TAP specification
Stars: ✭ 67 (+6.35%)
Mutual labels:  specification
ApiCenter
A repository for all your API specifications
Stars: ✭ 26 (-58.73%)
Mutual labels:  specification
falcon-apispec
apispec plugin that generates OpenAPI specification (aka Swagger Docs) for Falcon web applications.
Stars: ✭ 44 (-30.16%)
Mutual labels:  specification
Open-Water-Rate-Specification
A machine-readable format for storing and sharing water rate structures.
Stars: ✭ 18 (-71.43%)
Mutual labels:  specification

Spring Boot: How to design an efficient REST API?

Quality Gate Status BCH compliance

Resource collections are often enormous, and when some data has to be retrieved from them, it would be only not very efficient to always get the full list and browse it for specific items. Therefore we should design an optimized Search API.

A few of the essential features for consuming an API are:

  • Filtering: to narrow down the query results by specific parameters, eg. creation date, or country
GET /api/cars?country=USA
GET /api/cars?createDate=2019–11–11
  • Sorting: basically allows sorting the results ascending or descending by a chosen parameter or parameters, eg. by date
GET /api/cars?sort=createDate,asc
GET /api/cars?sort=createDate,desc
  • Paging:
    uses “size” to narrow down the number of results shown to a specific number and “offset” to specify which part of the results range to be shown — this is important in cases where the number of total results is greater than the one presented, this works like pagination you may encounter on many websites Usually, these features are used by adding a so-called query parameter to the endpoint that is being called.
GET /api/cars?limit=100
GET /api/cars?offset=2

All together:

GET /api/cars?country=USA&sort=createDate,desc&limit=100&offset=2

This query should result in the list of 100 cars from the USA, sorted descending by the creation date, and the presented records are on the second page, which means they are from a 101–200 record number range.

How to run the project

Clone source code from git
$  git clone https://github.com/Raouf25/Spring-Boot-efficient-search-API.git 
Build Docker image
$  docker build -t="spring-boot-efficient-search-api" --force-rm=true .

This will first run maven build to create jar package and then build hello-world image using built jar package.

Note: if you run this command for the first time, it will take some time to download the base image from DockerHub

Run Docker Container
$ docker run -p 8080:8080 -it --rm spring-boot-efficient-search-api
Test application
$  curl localhost:8080/api/cars/1

the response should be:

{
   "id":1,
   "manufacturer":"Acura",
   "model":"Integra",
   "type":"Small",
   "country":"Japon",
   "createDate":"1931-02-01"
}
Stop Docker Container:
docker stop `docker container ls | grep "spring-boot-efficient-search-api:*" | awk '{ print $1 }'`

Live Demo

This project is deployed in https://efficient-search-api.herokuapp.com/api/cars

Let's try: https://efficient-search-api.herokuapp.com/api/cars?country=USA&sort=createDate,desc&limit=100&offset=2

License

For more details please see this medium post .

Spring Boot Efficient Search Api Copyright © 2020 by Abderraouf Makhlouf [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].