Product Pagination API

API related to the product pagination API.

Product Pagination API of Each API Endpoint ?

All the pagination API have been abbreviated with "/pg" at end of the url to differentiate the difference between using the pagination API.

How to use Example section ?

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 using Pagination

GET http://localhost:5000/product/pg

Get all the records with pagination queries which required to be passed. 1. required QUERY_PARAM {currentPage} -> specify the current page 2. required QUERY_PARAM {itemPerPage} -> specify the max item per page Available metadata required: (currentPage , itemPerPage, totalItems, totalPages) Returns a list of ProductDTO object for the current page selected.

Query Parameters

Name
Type
Description

itemPerPage

number

specify max number of items per page -> (min: 10, max:50)

currentPage

number

specify which page to retrieve

{
  "currentPage": 1,
  "itemPerPage": 10,
  "totalItems": 501,
  "totalPages": 51,
  "data": [
    {
      "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
    },
    {
      "id": 186,
      "name": "Ahnya Pants - W",
      "description": "pants",
      "price": 79
    },
    {
      "id": 487,
      "name": "Airchaser Shirt - M",
      "description": "shirts",
      "price": 49
    },
    {
      "id": 354,
      "name": "Airshed Pro Pullover - M",
      "description": "jackets",
      "price": 129
    },
    {
      "id": 55,
      "name": "Airshed Pro Pullover - W",
      "description": "jackets",
      "price": 129
    },
    {
      "id": 175,
      "name": "All Seasons Hemp Canvas Bib Overalls - W",
      "description": "pants",
      "price": 99
    },
    {
      "id": 68,
      "name": "All Seasons Hemp Canvas Chore Coat - W",
      "description": "jackets",
      "price": 129
    }
  ]
}

Get All Products + Sorting with pagination

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

Get all the records with pagination queries which required to be passed with optional sorting param query to be passed. ### Required Parameters ### 1. required QUERY_PARAM {currentPage} -> specify the current page 2. required QUERY_PARAM {itemPerPage} -> specify the max item per page Available metadata returned: (currentPage, itemPerPage, totalItems, totalPages) returns a list of ProductDTO object for the current page selected ### Optional Parameters ### 3. optional to pass {orderByName} -> if passed as PARAM_QUERY will sort based on possible values 4. optional to pass {orderByPrice} -> if passed as PARAM_QUERY will sort based on possible values 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

itemPerPage

number

specify max number of items per page -> (min: 10, max:50)

currentPage

number

specify which page to retrieve

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

{
  "currentPage": 1,
  "itemPerPage": 10,
  "totalItems": 501,
  "totalPages": 51,
  "data": [
    {
      "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
    },
    {
      "id": 186,
      "name": "Ahnya Pants - W",
      "description": "pants",
      "price": 79
    },
    {
      "id": 487,
      "name": "Airchaser Shirt - M",
      "description": "shirts",
      "price": 49
    },
    {
      "id": 354,
      "name": "Airshed Pro Pullover - M",
      "description": "jackets",
      "price": 129
    },
    {
      "id": 55,
      "name": "Airshed Pro Pullover - W",
      "description": "jackets",
      "price": 129
    },
    {
      "id": 175,
      "name": "All Seasons Hemp Canvas Bib Overalls - W",
      "description": "pants",
      "price": 99
    },
    {
      "id": 68,
      "name": "All Seasons Hemp Canvas Chore Coat - W",
      "description": "jackets",
      "price": 129
    }
  ]
}

Get Products by filtering price + sorting with pagination

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

get products by filtering price (within min - max range) or (>= min) or (<= max) then sorting with pagination ### required Parameters ### 1. required QUERY_PARAM {currentPage} -> specify the current page 2. required QUERY_PARAM {itemPerPage} -> specify the max item per page Available metadata returned: (currentPage, itemPerPage, totalItems, totalPages) returns a list of ProductDTO object for the current page selected ### optional Parameters ### 3. {minprice} - OPTIONAL_PARAMETER, query will still work w/o min price input 4. {maxprice) - OPTIONAL_PARAMETER, query will still work w/o max price input 5. optional to pass {orderByName} -> query will still work w/o inputing min or max value 6. optional to pass {orderByPrice} -> query will still work w/o input min or max value 7. if multiple sort is specified, then it will be sorted by name then price. 8. if other values is provided to orderByName / orderByPrice, it will disregard the value and sort it in ascending order.

Query Parameters

Name
Type
Description

itemPerPage

string

specify the max item per page (min: 10, max: 50)

currentPage

number

specify which page to retrieve

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

{
  "currentPage": 1,
  "itemPerPage": 10,
  "totalItems": 2,
  "totalPages": 1,
  "data": [
    {
      "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 with pagination

GET http://localhost:5000/product/pg/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

{
  "currentPage": 1,
  "itemPerPage": 10,
  "totalItems": 30,
  "totalPages": 3,
  "data": [
    {
      "id": 107,
      "name": "Organic Cotton Spring Sweater Tank - W",
      "description": "sweaters",
      "price": 79
    },
    {
      "id": 19,
      "name": "Better Sweater Vest - W",
      "description": "jackets",
      "price": 99
    },
    {
      "id": 328,
      "name": "Better Sweater 1/4 Zip - M",
      "description": "jackets",
      "price": 99
    },
    {
      "id": 332,
      "name": "Better Sweater Vest - M",
      "description": "jackets",
      "price": 99
    },
    {
      "id": 460,
      "name": "Fog Cutter Sweater - M",
      "description": "sweaters",
      "price": 99
    },
    {
      "id": 1,
      "name": "Better Sweater 1/4-Zip - W",
      "description": "jackets",
      "price": 99.1
    },
    {
      "id": 31,
      "name": "Lightweight Better Sweater Marsupial Pullover - W",
      "description": "jackets",
      "price": 119
    },
    {
      "id": 106,
      "name": "Long-Sleeved Organic Cotton Spring Sweater - W",
      "description": "sweaters",
      "price": 119
    },
    {
      "id": 392,
      "name": "Better Sweater Rib Knit 1/4-Zip - M",
      "description": "jackets",
      "price": 119
    },
    {
      "id": 435,
      "name": "Better Sweater Henley Pullover - M",
      "description": "fleece",
      "price": 119
    }
  ]
}

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?