How to retrieve data from a database
My Staff API allows you to retrieve data via HTTP requests. You can get all your registered employee data or the registered data from a specific employee record.
List all records data
Get all the registered employee data form your database.
- Run this
GETrequest to list all your registered employee data.
curl --location 'https://dummy.restapiexample.com/api/v1/employees'- You'll receive a response similar to this:
{
"status": "success",
"data": [
{
"id": 1,
"employee_name": "Tiger Nixon",
"employee_salary": 320800,
"employee_age": 61,
"profile_image": ""
},
{
"id": 2,
"employee_name": "Garrett Winters",
"employee_salary": 170750,
"employee_age": 63,
"profile_image": ""
},
{
"id": 3,
"employee_name": "Ashton Cox",
"employee_salary": 86000,
"employee_age": 66,
"profile_image": ""
}
],
"message": "Successfully! All records has been fetched."
}Retrieve data from a record
- Run this
GETrequest to list all your registered employee data.
curl --location 'https://dummy.restapiexample.com/api/v1/employees'- You'll receive a response similar to this:
{
"status": "success",
"data": [
{
"id": 1,
"employee_name": "Tiger Nixon",
"employee_salary": 320800,
"employee_age": 61,
"profile_image": ""
},
{
"id": 2,
"employee_name": "Garrett Winters",
"employee_salary": 170750,
"employee_age": 63,
"profile_image": ""
},
{
"id": 3,
"employee_name": "Ashton Cox",
"employee_salary": 86000,
"employee_age": 66,
"profile_image": ""
}
],
"message": "Successfully! All records has been fetched."
}- Copy the
idfor the record you want obtain the information. - Run this
GETrequest to retrieve all the registered data from a specific employee record.
curl --location 'https://dummy.restapiexample.com/api/v1/employee/<id>'💡 Replace
<id>for the ID of your employee in your database.
- You'll receive a response similar to this:
{
"status": "success",
"data": {
"id": 3,
"employee_name": "Ashton Cox",
"employee_salary": 86000,
"employee_age": 66,
"profile_image": ""
},
"message": "Successfully! Record has been fetched."
}