Rest API for Northwind database
1.DDL_Statements.sql
File contains the DDL queries for creation of table in the northwind database.
2.Loading_data.sql
File contains script for loading data from .csv files.
Note: Please change the .csv file locations according to your local environment in this file.
Section2_Queries.sql
This contains below five queries:
- List all the products with cost above the average price of the products.
- Give the identifier, name, and total sales of employees, ordered by the employee identifier for employees who have sold more than 70 different products.
- Identify the customers who have active orders.
- Find the customer with maximum number of orders.
- List all the employees who have sold at least one of the products ‘Gravad Lax’ or ‘Mishi Kobe Niku’.
- Install Spring Tool Suite 4 using the link Download
- Download the Source code from the repository.
- Using STS4 import the code using maven and specify the pom.xml file.
- It will download all the dependencies required for the API.
- Open application.properties and change the MySql Database Credentials(Username and Password).
- Run as SpringBoot App.
- API should run.
BASE_URL = http://localhost:8080/api/v1
- Insert, update and select on customers
Insert : BASE_URL+/customers
POST Request
It should be accompanied with a JSON object in the body, similar to customer object structure.
For eg. { "customerId": "MIMEA", "companyName": "Milind Jain and Mehul Associates", "contactName": "Milind Jain", "contactTitle": "Co-Owner", "address": "71/48 Near K.V. No 5 Madhyam Marg Mansarovar", "city": "Jaipur", "region": "Rajasthan", "postalCode": "302020", "country": "India", "phone": "91-8947082516", "fax": "91-8947082516" }
Update : BASE_URL+/customers
POST Request
It should be accompanied with a JSON object in the body, similar to customer object structure.
For Eg. - Similar to the structure in insert mentioned above with updated values.
Select All Customers : BASE_URL+/customers
GET Request
Nothing to be given in BODY of Request.
Select Customer By ID : BASE_URL+/customers/{customerId}
GET Request
For eg. http://localhost:8080/api/v1/customers/MIMEA
- Insert, update and select on products
Insert : BASE_URL+/products
POST Request
It should be accompanied with a JSON object in the body, similar to products object structure.
For eg. { "productId": 1, "productName": "Chai", "supplier": { "supplierId": 2, "companyName": "New Orleans Cajun Delights", "contactName": "Shelley Burke", "contactTitle": "Order Administrator", "address": "P.O. Box 78934", "city": "New Orleans", "region": "LA", "postalCode": "70117", "country": "USA", "phone": "(100) 555-4822", "fax": null, "homePage": "#CAJUN.HTM#\r" }, "category": { "categoryId": 1, "categoryName": "Beverages", "description": "Soft drinks coffee teas beers and ales\r" }, "quantityPerUnit": "10 boxes x 20 bags", "unitPrice": 18.0, "unitsInStock": 39, "unitsOnOrder": 0, "reorderLevel": 10, "discontinued": 0 }
Update : BASE_URL+/products
POST Request
It should be accompanied with a JSON object in the body, similar to products object structure.
For Eg. - Similar to the structure in insert mentioned above with updated values.
Select All Products : BASE_URL+/products
GET Request
Nothing to be given in BODY of Request.
Select Product By ID : BASE_URL+/products/{productId}
GET Request
For eg. http://localhost:8080/api/v1/products/1
- Order history of given customer
URL - BASE_URL+/customers/orders/{customerId}
GET Request For eg. http://localhost:8080/api/v1/customers/orders/"MIMEA"
Note: You can also find the above specifications after deploying the rest api, just use the below links
For UI output
http://localhost:8080/api/v1/swagger-ui/index.html
For JSON Docs ouput http://localhost:8080/api/v1/v2/api-docs