Skip to content

Backend sample test APIs

Funmilayo E. Olaiya edited this page Nov 20, 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 sign up with google

    http://localhost:3000/api/v1/auth/google/signup
    
  2. To sign in with google

    http://localhost:3000/api/v1/auth/google/signin
    
  3. 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

  2. For any user to get all countries

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

  3. 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

  2. For any user to get all states

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

  3. 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

  2. For any user to get all tourist centers

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

  3. For an admin to add an ethnic group

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

  • 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/:ethnic-group-Id
  • 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/:ethnic-group-Id
  • 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

  2. For any user to get all ethnic groups

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

  3. For an admin to add a type of food

    POST http://localhost:3000/api/v1/admin/food/:food-Id

  • 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/:food-Id
  • 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/food/::food-Id
  • 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

  2. For any user to get all types of foods

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

  3. For an admin to add a historical fact

    POST http://localhost:3000/api/v1/admin/historical-food/:historical-fact-Id

  • 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
{
  "location": "Lekki",
  "about": "Write anything about Lekki here",
  "gallery": "put gallery URL here"
 }

  1. For an admin to update a historical fact

    PATCH http://localhost:3000/api/v1/admin/historical-food/:historical-fact-Id
  • 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
{
  "location": "Lekki",
  "about": "Write anything about Lekki here",
  "gallery": "put gallery URL here"
 }

  1. For an admin to delete a historical fact

    DELETE http://localhost:3000/api/v1/admin/historical-food/:historical-fact-Id
  • 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 anyone to get a historical fact

    GET http://localhost:3000/api/v1/historical-fact/:historical-fact-Id

  2. For anyone to get all historical facts

    GET http://localhost:3000/api/v1/historical-fact

  3. For anyone to get all historical facts by location

    GET http://localhost:3000/api/v1/historical-fact/location/:locationName

  4. For a user to add a comment

    POST http://localhost:3000/api/v1/comment/:related-id

  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of any user, 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
{
  "comment": "I love this place in Lekki, I was there in..."
 }
  1. For a user to get one comment

    GET http://localhost:3000/api/v1/comment/<comment-id>
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of any user, 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 a user to get all comments

    GET http://localhost:3000/api/v1/comments
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of any user, 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 a user to update a comment

    PATCH http://localhost:3000/api/v1/comment/<comment-id>
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of any user, 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
{
  "comment": "I love this place in Lekki, I was there in March this year.",
  "relatedId": "<the-related-id>"
 }
  1. For a user to delete a comment

    DELETE http://localhost:3000/api/v1/comment/<comment-id>
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of any user, 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 an admin to deactivate a user

    POST http://localhost:3000/api/v1/admin/deactivate-user/:<user-id>
  • 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 an admin to activate a user

    POST http://localhost:3000/api/v1/admin/activate-user/:<user-id>
  • 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 an admin to add music

    POST http://localhost:3000/api/v1/admin/music/:music-id
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of any user, 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
{
    "category": "Afrobeat",
    "gallery": "https://s3.amazonaws.com/allaboutjazz/photos/a_large/14527396bb98bcb8b452e1a422196975.jpg",
    "information": "Afrobeat is a music genre which involves the combination of elements of West African musical styles such as fuji music, Yoruba, and highlife with American funk and jazz influences, with a focus on chanted vocals, complex intersecting rhythms, and percussion. "
}
  1. For an admin to update music

    PATCH http://localhost:3000/api/v1/admin/music/:music-id
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of any user, 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
{
    "category": "Afrobeat",
    "gallery": "https://s3.amazonaws.com/allaboutjazz/photos/a_large/14527396bb98bcb8b452e1a422196975.jpg",
    "information": "Afrobeat is a music genre which involves the combination of elements of West African musical styles such as fuji music, Yoruba, and highlife with American funk and jazz influences, with a focus on chanted vocals, complex intersecting rhythms, and percussion. "
}
  1. For an admin to delete music

    DELETE http://localhost:3000/api/v1/admin/music/:music-id
  • Authentication required after sign up/in: Bearer token
  • Make sure the sign in details are that of any user, 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 music

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

  2. For any user to get all musics

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

Clone this wiki locally