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.
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
Request Body
object
Insert a new record into product table.
Example Value | Schema (Request Body which is required to be passed)
Schema Used: CreateProductDTO
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
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
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
id
number
any number from one to infinity -> possible values: ( 1 ... n )the product
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
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
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
string
name of the product -> will be filtered using like clause
Query Parameters
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
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?