Contact Book Server is a Flask API which provides basic CRUD functionalities for a Address Book App.
- Python
- Flask
- MongoDb
- Make sure you have Python3
- pip install -r requirements.txt
- Run
python3 server.py
User must login with the regitered username and password. The response will be a JWT-Token which will be needed to access other APIs
{
"user":"test"
}
{
"success": "success",
"token": "***jwt-token***",
"user": "test"
}
Create a new contact and add to Database. Contact to add must have a unique email id
{
"jwt_token":"***jwt-token***",
"email":"superman@dc.com",
"name":"Kent Clarke"
}
{
"message": "",
"status": "success"
}
{
"message": "Email Exists",
"status": "error"
}
List all the contacts associated with the current user.
{
"jwt_token":"***jwt-token***"
}
{
"message": "",
"results": [
{
"contact_id": "60g33",
"email": "steverogers@avengers.com",
"name": "Steve Rogers"
},
{
"contact_id": "2j1d1",
"email": "thor@avengers.com",
"name": "Thor Odinson"
}
],
"status": "success"
}
API also supports Pagination with result limit within a page
eg:
/list_contacts/page=1&limit=10
Removes the contact from current users contact list.
{
"jwt_token":"***jwt-token***",
"contact_id" : "60g33"
}
{
"message": "",
"status": "success"
}
API returns a list of contacts matching either name or email. The search is done by MondoDB text search index.
{
"jwt_token":"***jwt-token***",
"search_string":"superman"
}
{
"message": "",
"results": [
{
"contact_id": "jj4gd",
"email": "superman@dc.com",
"name": "Kent Clarke",
"score": 0.6666666666666666
}
],
"status": "success"
}
Updates the current users name, email or both.
{
"jwt_token":"***jwt-token***",
"email" : "brucewayne@wayneindustries.com",
"name" : "Bruce Wayne",
"contact_id" : "7440f",
"fields_to_update": ["email","name"]
}
{
"message": "",
"status": "success"
}
Add existing contact to current users contact list.
{
"jwt_token":"***jwt-token***",
"contact_ids" : ["60g33"]
}
{
"message": "",
"status": "success"
}
- cd into contact-book-server
- Run
python3 test.py