4Geeks logo
4Geeks logo

Bootcamps

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Academy

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Full-Stack Software Developer - 16w

Data Science and Machine Learning - 16 wks

Search from all Lessons


LoginGet Started
← Back to Projects

Contact List API

Difficulty

  • intermediate

Average duration

16 hrs

Technologies

  • REST

  • Django

    Python

    Flask

  • APIs

Difficulty

  • intermediate

Average duration

16 hrs

Technologies

Signup and get access to similar projects

We will use it to give you access to your account.
Already have an account? Login here.

Difficulty

  • intermediate

Average duration

16 hrs

Technologies

Difficulty

  • intermediate

Average duration

16 hrs

Technologies

Weekly Coding Challenge

Every week, we pick a real-life project to build your portfolio and get ready for a job. All projects are built with ChatGPT as co-pilot!

Start the Challenge

Podcast: Code Sets You Free

A tech-culture podcast where you learn to fight the enemies that blocks your way to become a successful professional in tech.

Listen the podcast

Creating and maintaining REST APIs is THE everyday job for most of back-end developers, so it is a skill that we need to mature. In this project we'll practice every step of the API development process.

We are going to build the API that manages a contact-list database and publicly expose the endpoints so client applications (including ours) can use it. This time we'll include Groups, a new entity that will allow the system to group Contacts. Example: Work, Family, Friends. Hint: we can implement this logic by using a many-to-many relationship between the two tables.

πŸ“ Instructions

Create an API with the following endpoints:

  1. Get a list of all the Contacts GET /contact/all
  2. Create a new Contact POST /contact
  3. Get a specific Contact (with the Group objects it belongs to) GET /contact/{contact_id}
  4. Delete a Contact DELETE /contact/{contact_id}
  5. Update a Contact UPDATE /contact/{contact_id}
  6. Get a list of all the Group names and ids GET /group/all
  7. Create a new Group POST /group
  8. Get a specific Group (with all Contact objects related to it) GET /group/{group_id}
  9. Update a Group name UPDATE /group/{group_id}
  10. Delete a Group DELETE /group/{group_id}

A contact must have the following data-structure on the database:

1# Contact 2 id: (int, primary_key) 3 full_name: (string, mandatory) 4 email: (string, mandatory) 5 address: (string, optional) 6 phone: (string, optional) 7 groups: (list of foreign_key) 8 9# Group 10 id: (int, primary_key) 11 name: (string, mandatory) 12 contacts: (list of foreign_key)

Formal API Documentation

  1. GET /contact/all
1 REQUEST (application/json) 2 type: GET 3 body: null 4 RESPONSE (application/json) 5 code: 200 | 404 | 500 6 body: [ 7 { 8 "full_name": "Dave Bradley", 9 "email": "dave@gmail.com", 10 "address":"47568 NW 34ST, 33434 FL, USA", 11 "phone":"7864445566", 12 "groups": [2,3] 13 }, 14 ... 15 ]
  1. Create a new contact
1 REQUEST (application/json) 2 type: POST 3 path: /contact 4 body: { 5 "full_name": "Dave Bradley", 6 "email": "dave@gmail.com", 7 "address":"47568 NW 34ST, 33434 FL, USA", 8 "phone":"7864445566", 9 "groups": [2,3] 10 } 11 RESPONSE (application/json) 12 code: 200 | 400 | 500 13 body: { 14 "id": 12 15 "full_name": "Dave Bradley", 16 "email": "dave@gmail.com", 17 "address":"47568 NW 34ST, 33434 FL, USA", 18 "phone":"7864445566", 19 "groups": [2,3] 20 }
  1. Get a specific Contact
1 REQUEST (application/json) 2 type: GET 3 path: /contact/{contact_id} 4 RESPONSE (application/json) 5 code: 200 | 404 | 400 | 500 6 body:{ 7 "id": 12 8 "full_name": "Dave Bradley", 9 "email": "dave@gmail.com", 10 "address":"47568 NW 34ST, 33434 FL, USA", 11 "phone":"7864445566", 12 "groups": [ 13 { 14 "id": 2, 15 "name": "Family" 16 },{ 17 "id": 3, 18 "name": "Gamers" 19 } 20 ] 21 }
  1. Update a given contact
1 REQUEST (application/json) 2 type: PUT 3 path: /contact/{contact_id} 4 body: { 5 "full_name": "Dave Bradley", 6 "email": "dave@gmail.com", 7 "address":"47568 NW 34ST, 33434 FL, USA", 8 "phone":"7864445566", 9 "groups": [2,3] 10 } 11 RESPONSE (application/json) 12 code: 200 | 404 | 400 | 500 13 body:{ 14 "id": 12 15 "full_name": "Dave Bradley", 16 "email": "dave@gmail.com", 17 "address":"47568 NW 34ST, 33434 FL, USA", 18 "phone":"7864445566", 19 "groups": [2,3] 20 }
  1. Delete a contact by id
1 REQUEST (application/json) 2 type: DELETE 3 path: /contact/{contact_id} 4 body: null 5 RESPONSE (application/json) 6 code: 200 | 404 | 500 7 body: { 8 "deleted": { 9 "id": 12, 10 "full_name": "Dave Bradley", 11 } 12 }
  1. List all Groups
1 REQUEST (application/json) 2 type: GET 3 path: /group/ 4 body: null 5 RESPONSE (application/json) 6 code: 200 | 500 7 body: { 8 "data": [ 9 { 10 "id": 1, 11 "name": "Work" 12 },{ 13 "id": 2, 14 "name": "Gamers" 15 } 16 ] 17 }
  1. Get a specific Group
1 REQUEST (application/json) 2 type: GET 3 path: /group/{group_id} 4 RESPONSE (application/json) 5 code: 200 | 404 | 400 | 500 6 body:{ 7 "id": 2 8 "name": "Work", 9 "contacts": [ 10 { 11 "id": 12 12 "full_name": "Dave Bradley", 13 "email": "dave@gmail.com", 14 "address":"47568 NW 34ST, 33434 FL, USA", 15 "phone":"7864445566", 16 "groups": [2,3] 17 } 18 ] 19 }
  1. Update a given group's id
1 REQUEST (application/json) 2 type: PUT 3 path: /group/{group_id} 4 body: { 5 "name": "Beach Crew", 6 } 7 RESPONSE (application/json) 8 code: 200 | 404 | 400 | 500 9 body:{ 10 "id": 2 11 "name": "Beach Crew", 12 }
  1. Delete a group by id
1 REQUEST (application/json) 2 type: DELETE 3 path: /group/{group_id} 4 body: null 5 RESPONSE (application/json) 6 code: 200 | 404 | 500 7 body: { 8 "deleted": { 9 "id": 2, 10 "name": "Beach Crew", 11 } 12 }

πŸ’‘ How to start?

  1. Start by reading the instructions very carefully.
  2. Build the database model class Contact and Group.
  3. Implement the add methods (POST) to be able to add some contacts and groups into the database to make sure you have dummy data.
  4. Create the GET(all) endpoints. List contacts and list groups.
  5. Implement the rest of the endpoints.
  6. Connect your React Contact List application using fetch.

Hint: Use Postman as a testing tool before you connect your front end application (React Contact List).

πŸ“– Fundamentals

This exercise will make you practice the following fundamentals:

  1. Reading API documentations
  2. Building an RESTful API
  3. Building data models
  4. SQL Databases
  5. REST API's
  6. Python Flask
  7. Fetch and async

Difficulty

  • intermediate

Average duration

16 hrs

Technologies

Difficulty

  • intermediate

Average duration

16 hrs

Technologies

Signup and get access to similar projects

We will use it to give you access to your account.
Already have an account? Login here.

Difficulty

  • intermediate

Average duration

16 hrs

Technologies

Difficulty

  • intermediate

Average duration

16 hrs

Technologies

Weekly Coding Challenge

Every week, we pick a real-life project to build your portfolio and get ready for a job. All projects are built with ChatGPT as co-pilot!

Start the Challenge

Podcast: Code Sets You Free

A tech-culture podcast where you learn to fight the enemies that blocks your way to become a successful professional in tech.

Listen the podcast