To start running the program you need a MySQL database, PHPStorm or a similar IDE.
To use the database you need to create a .env file in the root directory which contains the information for your database connection.
DB_HOST=host
DB_USER=user
DB_PASS=password
DB_NAME=database
Start the server with node server.js. Now you can start using the API.
This is a RESTful API used to get technical information regarding smartphones and phablets.
The API responds in JSON format.
-
Base URL
/api/v1
-
URL
/manufacturers
-
Optional URL Params
no params -
Sample Call:
GET http://localhost:8081/api/v1/manufacturers -
Response:
- Code: 200
- Content:
["apple", "samsung", "huawei"]
- Code: 200
-
URL
/manufacturers/:mfr
-
Optional URL Params
fields=[id,model,releaseDate,weight,displaySize,resolution,cameraRes,batteryCpty,os,osVersion,category]
afterDate=[date]
beforeDate=[date]
minWeight=[integer]
maxWeight=[integer]
minDisplaySize=[float]
maxDisplaySize=[float]
minCameraRes=[integer]
minCameraRes=[integer]
minBatteryCpty=[integer]
minBatteryCpty=[integer]
minOsVersion=[float]
maxOsVersion=[float]
-
Sample Call:
GET http://localhost:8081/api/v1/manufacturers/samsung?fields=id,model,weight,displaySize&minDisplaySize=6.8 -
Response:
- Code: 200
- Content:
[{"Model_id":1,"Model_name":"Samsung Galaxy S20 Ultra 5G","Weight_g":500,"Display_size_inch":6.9},{"Model_id":4,"Model_name":"Samsung Galaxy Note10+ 5G","Weight_g":198,"Display_size_inch":6.8}]
- Code: 200
-
URL
/manufacturers/:mfr/:id
-
Optional URL Params
fields=[id,model,releaseDate,weight,displaySize,resolution,cameraRes,batteryCpty,os,osVersion,category] -
Sample Call:
GET http://localhost:8081/api/v1/manufacturers/samsung/1?fields=model,category -
Response:
- Code: 200
- Content:
[{"Model_name":"Samsung Galaxy S20 Ultra 5G","Category":"phablet"}]
- Code: 200
-
URL
/smartphones/phablets -
Optional URL Params
fields=[id,model,releaseDate,weight,displaySize,resolution,cameraRes,batteryCpty,os,osVersion,category]
afterDate=[date]
beforeDate=[date]
minWeight=[integer]
maxWeight=[integer]
minDisplaySize=[float]
maxDisplaySize=[float]
minCameraRes=[integer]
minCameraRes=[integer]
minBatteryCpty=[integer]
minBatteryCpty=[integer]
minOsVersion=[float]
maxOsVersion=[float]
-
Sample Call:
GET http://localhost:8081/api/v1/smartphones?fields=model&minBatteryCpty=3000 -
Response:
- Code: 200
- Content:
[{"Model_name":"Apple iPhone 11 Pro MAX"},{"Model_name":"Samsung Galaxy Z Flip"}]
- Code: 200
-
URL
/manufacturers
-
JSON Body
{"manufacturer":"Huawei"} -
Sample Call:
POST http://localhost:8081/api/v1/manufacturers -
Response:
- Code: 200
-
URL
/manufacturers/:mfr
-
JSON Body
{"Model_name": "Samsung Galaxy S20 Ultra 5G","Release_date": "2020-03-05","Weight_g": 222,"Display_size_inch": 6.9,"Resolution": "1440x3200","Camera": 108,"Battery_capacity": 5000,"Operating_system": "Android","OS_version": 10,"Category": "Phablet"} -
Sample Call:
POST http://localhost:8081/api/v1/manufacturers/samsung -
Response:
- Code: 200
-
URL
/manufacturers/:mfr
-
JSON Body
{"manufacturer": "Googel"} -
Sample Call:
PUT http://localhost:8081/api/v1/manufacturers/google -
Response:
- Code: 200
-
URL
/manufacturers/:mfr/:id
-
JSON Body
{"release_date": "2019-10-21", "battery_capacity": 4000, "os_version": 10} -
Sample Call:
PUT http://localhost:8081/api/v1/manufacturers/apple/1 -
Response:
- Code: 200
-
URL
/manufacturers/:mfr
-
Optional URL Params
no params -
Sample Call:
DELETE http://localhost:8081/api/v1/manufacturers/huawei -
Response:
- Code: 200
-
URL
/manufacturers/:mfr/:id
-
Optional URL Params
no params -
Sample Call:
DELETE http://localhost:8081/api/v1/manufacturers/samsung/1 -
Response:
- Code: 200