Product API

API related to the product pagination API.

How to use Example section of Each API Endpoint ?

If the application is currently running and records are loaded into the database, clicking on an example will cause the web browser to open a new tab and render the API outcome.

An Example is shown here below.

Using Swagger API UI to test URL endpoints

Alternatively, to test the API endpoint u can turn on the Swagger API UI and test it directly with the application.

Get All Product

GET http://localhost:5000/product

Get all the records w/o sorting or pagination involved. No parameters are required to be passed in order to use this API. An API which helps to get all the products from the product's table.

[
  {
    "id": 477,
    "name": "A/C Shirt - M",
    "description": "shirts",
    "price": 79
  },
  {
    "id": 311,
    "name": "Active Briefs - W",
    "description": "bras",
    "price": 24
  },
  {
    "id": 312,
    "name": "Active Hipster - W",
    "description": "bras",
    "price": 24
  },
  {
    "id": 308,
    "name": "Active Mesh Bra - W",
    "description": "bras",
    "price": 45
  }
]

Insert A New Product Listing

POST http://localhost:5000/product

Insert a new product object that needs to be added to the product listing, No parameters required to be passed.

Request Body

Name
Type
Description

Request Body

object

Insert a new record into product table.

{
  "id": 501,
  "name": "string",
  "description": "string",
  "price": "0.00"
}

Example Value | Schema (Request Body which is required to be passed)

Schema Used: CreateProductDTO

{
  "name": "string",
  "description": "string",
  "price": 0
}

CreateProductDTO

Key

Datatype

Description

name*

string

the title of the product

description*

string

the description describing the category of the product which it falls under

price*

number

minimum: 0 maximum: 9999 default: 0

the price of the product, accepts a number up to 2 decimal points

Get All Products + Sorting

GET http://localhost:5000/product/sortby

Get all the records + allows single or multiple sorting 1. optional to pass {orderByName} -> if passed as PARAM_QUERY will sort based on possible values 2. optional to pass {orderByPrice} -> if passed as PARAM_QUERY will sort based on possible values 3. if multiple sort is specified, then it will be sorted by name then price. 4. if other values is provided to orderByName / orderByPrice, it will disregard the value and sort it in ascending order.

Query Parameters

Name
Type
Description

orderByPrice

string

Accepts asc sort by Ascending Order desc sort by Descending Order

orderByName

string

Accepts asc sort by Ascending Order desc sort by Descending Order

[
  {
    "id": 477,
    "name": "A/C Shirt - M",
    "description": "shirts",
    "price": 79
  },
  {
    "id": 311,
    "name": "Active Briefs - W",
    "description": "bras",
    "price": 24
  },
  {
    "id": 312,
    "name": "Active Hipster - W",
    "description": "bras",
    "price": 24
  }
]

Get One Product by ID Only

GET http://localhost:5000/product/filterById/{id}

get one product by ID, only numbers(integer) are accepted. If product ID does not exist, it will return 404 error. Currently data preparation ID's are (1 - 500) are valid records. ID 501 and later does not exist unless added. Can use these data for data testing scenarios.

Path Parameters

Name
Type
Description

id

number

any number from one to infinity -> possible values: ( 1 ... n )the product

{
  "id": 20,
  "name": "Micro Puff Jacket - W",
  "description": "jackets",
  "price": 249
}

Get Products by filtering price + sorting

GET http://localhost:5000/product/filterByPrice

get products by filtering price (within min - max range) or (>= min) or (<= max) then sorting 1. {minprice} - OPTIONAL_PARAMETER, query will still work w/o min price input 2. {maxprice) - OPTIONAL_PARAMETER, query will still work w/o max price input 3. optional to pass {orderByName} -> query will still work w/o inputing min or max value 4. optional to pass {orderByPrice} -> query will still work w/o input min or max value 5. if multiple sort is specified, then it will be sorted by name then price. 6. if other values is provided to orderByName / orderByPrice, it will disregard the value and sort it in ascending order.

Query Parameters

Name
Type
Description

minprice

number

minimum price - cannot be less than 0

maxprice

number

max maximum price - cannot be more than 9999

orderByPrice

string

Accepts asc sort by Ascending Order desc sort by Descending Order

orderByName

string

Accepts asc sort by Ascending Order desc sort by Descending Order

[
  {
    "id": 314,
    "name": "Sender Hipster - W",
    "description": "bras",
    "price": 18
  },
  {
    "id": 315,
    "name": "Sender Briefs - W",
    "description": "bras",
    "price": 18
  }
]

Get Products by filtering name + sorting

GET http://localhost:5000/product/filterByName/{name}

get products by filtering name using the like clause + sorting 1. {name) - REQUIRED PARAMETER, query will search for name of product and returns the product name which has the text name in it 2. optional to pass {orderByName} -> query will still work w/o inputing min or max value 3. optional to pass {orderByPrice} -> query will still work w/o input min or max value 4. if multiple sort is specified, then it will be sorted by name then price. 5. if other values is provided to orderByName / orderByPrice , it will disregard the value and sort it in ascending order.

Path Parameters

Name
Type
Description

name

string

name of the product -> will be filtered using like clause

Query Parameters

Name
Type
Description

orderByPrice

string

Accepts asc sort by Ascending Order desc sort by Descending Order

orderByName

string

Accepts asc sort by Ascending Order desc sort by Descending Order

[
  {
    "id": 1,
    "name": "Better Sweater 1/4-Zip - W",
    "description": "jackets",
    "price": 99.1
  },
  {
    "id": 2,
    "name": "Better Sweater Jacket - W",
    "description": "jackets",
    "price": 139.2
  },
  {
    "id": 8,
    "name": "Down Sweater - W",
    "description": "jackets",
    "price": 229
  },
  {
    "id": 17,
    "name": "Down Sweater Hoody - W",
    "description": "jackets",
    "price": 279
  }
]

For checking the object structure(DTO) that was sent or received via API, do check the DTO used in the Application page.

Last updated

Was this helpful?