Skip to content

Backend sample test APIs

Funmilayo E. Olaiya edited this page Nov 7, 2020 · 20 revisions

Welcome to the code-jammers-backend wiki!

This wiki will walk you through on how to test all the present APIs in code jammers backend repo.

KeyNote: The APIs are well-validated. It's best to follow the error messages to get an understanding when something is not working as it should.

You can learn more about the project and how to get started here: https://github.com/devcareer/code-jammers-backend/blob/develop/README.md

  1. To sign up:

    POST http://localhost:3000/api/v1/users/signup
{
	"email": "[email protected]", // you can put your real email.
	"password": "123456",
	"username": "funmibaby"
}

A verification email will be sent to your email, open the email and click on the verify me button.

  1. To sign in:

    POST http://localhost:3000/api/v1/users/signin
{
	"email": "[email protected]",
	"password": "123456"
}
  1. To reset password:

    POST http://localhost:3000/api/v1/users/recover
{
	"email": "[email protected]"
}

Then in the email gotten, click on the reset password button and copy the link on the page.

Then: POST http://localhost:3000<the copied link>

{
	"newPassword": "123456"
}
  1. To update profile:

    PATCH http://localhost:3000/api/v1/user-profile
  • Authentication required after sign up/in: Bearer token
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "firstName": "Ufuoma",
    "lastName": "Ogodo",
    "profilePicture": "https://www.instagram.com/_bellogo/"
}
  1. To subscribe to the newsletter

    POST http://localhost:3000/api/v1/newsletter/subscribe
{
   "firstName": "Funmilayo",
   "email": "[email protected]"
}
  1. To make an admin send newsletters

    POST http://localhost:3000/api/v1/newsletter/admin/create_newsletter
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "title": "What is Lorem Ipsum?",
    "message": "Lorem Ipsum is simply dummy text of the printing"
}
  1. To unsubscribe from the newsletter

    GET http://localhost:3000/api/v1/newsletter/unsubscribe/:email

  2. For an admin to add a country

    POST http://localhost:3000/api/v1/admin/country

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
     "nameOfCountry": "Ghana",
     "gallery": "https://image.shutterstock.com/image-illustration/togo-flag-silk-260nw-419363206.jpg",
     "capital": "Lome",
     "population": 205,
     "officialLanguage": "English",
     "region": "West Africa",
     "currency": "CFA franc"
}
  1. For an admin to update a country

    PATCH http://localhost:3000/api/v1/admin/country/:countryId
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
     "nameOfCountry": "Togo",
     "gallery": "https://image.shutterstock.com/image-illustration/togo-flag-silk-260nw-419363206.jpg",
     "capital": "Lome",
     "population": 205,
     "officialLanguage": "English",
     "region": "West Africa",
     "currency": "CFA franc"
}
  1. For an admin to delete a country

DELETE http://localhost:3000/api/v1/admin/country/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
  1. For any user to get a country

GET http://localhost:3000/api/v1/country/:countryId

  1. For any user to get all countries

GET http://localhost:3000/api/v1/countries

  1. For an admin to add a state

POST http://localhost:3000/api/v1/admin/state/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "name": "Kano",
    "capital": "Ibadan",
    "gallery": "https://en.wikipedia.org/wiki/Lusaka#/mediaJPG"
}
  1. For an admin to update a state

PATCH http://localhost:3000/api/v1/admin/state/:stateId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "name": "Kano",
    "capital": "Kano",
    "gallery": "https://en.wikipedia.org/wiki/Lusaka#/mediaJPG"
}
  1. For an admin to delete a state

DELETE http://localhost:3000/api/v1/admin/state/:stateId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
  1. For any user to get a state

GET http://localhost:3000/api/v1/state/:stateId

  1. For any user to get all states

GET http://localhost:3000/api/v1/states

  1. For an admin to add a tourist center

POST http://localhost:3000/api/v1/admin/tourist-center/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "name": "Robben Island Museumm",
    "location": "Cape Town",
    "gallery": "https://www.fodors.com/assets/destinations/45/robben-island-prison-robben-island-cape-town-south-africa_main.jpg",
    "about": "Robben Island is an island in Table Bay, 6.9 kilometres west of the coast of Bloubergstrand, north of Cape Town, South Africa. It takes its name from the Dutch word for seals, hence the Dutch/Afrikaans name Robbeneiland, which translates to Seal Island"
}

  1. For an admin to update a tourist center

PATCH http://localhost:3000/api/v1/admin/tourist-center/:tourist-centerId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "name": "Robben Island Museum",
    "location": "Cape Town",
    "gallery": "https://www.fodors.com/assets/destinations/45/robben-island-prison-robben-island-cape-town-south-africa_main.jpg",
    "about": "Robben Island is an island in Table Bay, 6.9 kilometres west of the coast of Bloubergstrand, north of Cape Town, South Africa. It takes its name from the Dutch word for seals, hence the Dutch/Afrikaans name Robbeneiland, which translates to Seal Island"
}

  1. For an admin to delete a tourist center

DELETE http://localhost:3000/api/v1/admin/tourist-center/:tourist-centerId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
  1. For any user to get a tourist center

GET http://localhost:3000/api/v1/tourist-center/:tourist-centerId

  1. For any user to get all tourist centers

GET http://localhost:3000/api/v1/tourist-centers

  1. For an admin to add an ethnic group

POST http://localhost:3000/api/v1/admin/ethnic-group/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
            "name": "Igbo",
            "festivals": "New Yamm Festival",
            "dressing": "In the old days, some Igbo women celebrated their feast in ekwerike clothing. In other words, they tied thick fabric around their waist. Others preferred painting their bodies with ufle, nzu, edo, uri and other colored ornaments (instead of wearing clothing) and decorating their waist with bead accessories.",
            "language": "Igbo",
            "gallery": "https://unsplash.com/photos/eS_aZA5S42Y",
            "culturalPractices": "The Igbo people have a traditional religious belief that there is one creator, called ‘Chineke’ or ‘Chukwu’. The creator can be approached through many other deities and spirits in the form of natural objects, most commonly through the god of thunder called ‘Amadioha’."
}
  1. For an admin to update an ethnic group

PATCH http://localhost:3000/api/v1/admin/ethnic-group/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
            "name": "Igbo",
            "festivals": "New Yam Festival",
            "dressing": "In the old days, some Igbo women celebrated their feast in ekwerike clothing. In other words, they tied thick fabric around their waist. Others preferred painting their bodies with ufle, nzu, edo, uri and other colored ornaments (instead of wearing clothing) and decorating their waist with bead accessories.",
            "language": "Igbo",
            "gallery": "https://unsplash.com/photos/eS_aZA5S42Y",
            "culturalPractices": "The Igbo people have a traditional religious belief that there is one creator, called ‘Chineke’ or ‘Chukwu’. The creator can be approached through many other deities and spirits in the form of natural objects, most commonly through the god of thunder called ‘Amadioha’."
}
  1. For an admin to delete an ethnic group

DELETE http://localhost:3000/api/v1/admin/ethnic-group/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
  1. For any user to get an ethnic group

GET http://localhost:3000/api/v1/ethnic-group/:ethnic-group-id

  1. For any user to get all ethnic groups

GET http://localhost:3000/api/v1/ethnic-groups

  1. For an admin to add a type of food

POST http://localhost:3000/api/v1/admin/food:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "foodName": "Nsh",
    "methodOfPreparation": "Nshima is the staple carbohydrate of Zambia. It is made from corn that is processed into a fine white powder called ‘mealie meal’. It is cooked by mixing the corn meal with water which is brought to the boil as porridge (similar to grits). More cornmeal is added until it develops a thicker texture. The cornmeal can be substituted for cassava, sorghum and millet. Nshima is served with a protein (usually meat or fish) and one or two vegetables. Nshima can be enjoyed at any of the many traditional restaurants in Zambia as well as at boutique hotels.",
    "gallery":"https://images.unsplash.com/photo-1482049016688-2d3e1b311543?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
}
  1. For an admin to update a type of food

PATCH http://localhost:3000/api/v1/admin/food/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
{
    "foodName": "Nsh",
    "methodOfPreparation": "Nshima is the staple carbohydrate of Zambia. It is made from corn that is processed into a fine white powder called ‘mealie meal’. It is cooked by mixing the corn meal with water which is brought to the boil as porridge (similar to grits). More cornmeal is added until it develops a thicker texture. The cornmeal can be substituted for cassava, sorghum and millet. Nshima is served with a protein (usually meat or fish) and one or two vegetables. Nshima can be enjoyed at any of the many traditional restaurants in Zambia as well as at boutique hotels. ",
    "gallery":"https://images.unsplash.com/photo-1482049016688-2d3e1b311543?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
}
  1. For an admin to delete a type of food

DELETE http://localhost:3000/api/v1/admin/ethnic-group/:countryId

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of an admin, you can check the seeders file in the database folder
  • Add the token gotten from sign up/in to the Bearer field of postman/insomnia
  1. For any user to get a type of food

GET http://localhost:3000/api/v1/food/:food-id

  1. For any user to get all types of foods

GET http://localhost:3000/api/v1/food

Clone this wiki locally