Best Flask open-source libraries and packages

Truecaller api clone

A clone of Truecaller API, built using Flask Framework. It has the functionality to Create Account, Add contact, Mark number as spam, Search contact by name as well as phone number.
Updated 2 months ago

TRUECALLER API CLONE

A clone of Truecaller API, built using Flask Framework.
To see the instructions on how to run this API, click here

API functionalities

Note: Authorization header required for all operations

  • Register/Create Account
  • Login
  • Add contact
  • Mark number as spam
  • Search contact by name
  • Search contact by phone number

HOME PAGE

Asks the user to register/login if not logged in, i.e., no valid Authorization Token was passed by the user while sending this request.
Notice the empty Key-Value pair in the Headers section.

Screenshot 2022-08-24 at 8 08 47 PM

REGISTER

  • Takes details of the new user
  • Creates new user
  • Asks them to go to /login

User 1

Screenshot 2022-08-24 at 8 11 50 PM

User 2

Screenshot 2022-08-24 at 8 12 36 PM

LOGIN

Takes username and password to check for a valid user.
If valid, asks user to go to the endpoint to add contacts.

Also generates a unique Authorization Token which is shown to the user as it would be needed to be entered for further requests by the user to validate whether he is logged in or not(refer instructions.txt to see how to pass this auth_token).

User 1

Screenshot 2022-08-24 at 8 14 23 PM

User 2

Screenshot 2022-08-24 at 8 15 05 PM

Notice that both the users have different Authorization Tokens. Whichever Authorization Token is passed along with the request, the request would be by that specific user.

ADD CONTACTS

User 1

We have provided the Authorization Token for User 1 in the Headers section.
Screenshot 2022-08-24 at 8 22 18 PM

Our Body has the contacts of User 1 that are to be added
Screenshot 2022-08-24 at 8 22 56 PM

User 2

We have provided the Authorization Token for User 2 in the Headers section.
Screenshot 2022-08-24 at 8 24 48 PM

Our Body has the contacts of User 2 that are to be added
Screenshot 2022-08-24 at 8 31 30 PM

User 1 has 3 contacts and User 2 has 4 contacts
User 2 has same 3 phone numbers as User 1 but with different names and he also has the phone number of User 1

Current State of Database

User table

Screenshot 2022-08-24 at 8 33 59 PM

Contact Table

Screenshot 2022-08-24 at 8 33 42 PM

SEARCH BY NAME

A user can search for a person by name in the global database. Search results display the name, phone number and spam likelihood for each result matching that name.

We have provided the Authorization Token for User 1. See the Key-Value pair inside Headers

Search 1

Screenshot 2022-08-24 at 8 38 38 PM

Search 2

Screenshot 2022-08-24 at 8 39 59 PM

SEARCH BY NUMBER

A user can search for a person by phone number in the global database. If there is a registered user with that phone number, show only that result. Otherwise, show all results matching that phone number completely - note that there can be multiple names for a particular phone number in the global database, since contact books of multiple registered users may have different names for the same phone number.

We have provided the Authorization Token for User 2. See the Key-Value pair inside Headers.

Not a registered User

Screenshot 2022-08-24 at 8 43 07 PM

Registered User

Screenshot 2022-08-24 at 8 46 21 PM

CHANGING SPAM STATUS

A user should be able to mark a number as spam so that other users can identify spammers via the global database. Any registered user can change the spam status for any number in the global database.
Note : It isn't necessary that the number should belong to any registered user or contact - it could be any random number in our contact table.

We have provided the Authorization Token for User 2. See the Key-Value pair inside Headers

Screenshot 2022-08-24 at 8 57 21 PM

Notice that the number was saved by both our registered users, but with different names and even though User 2 changed the spam status, it has changed for both the registered users.

Searching for the same number now shows the changed status for that number

Screenshot 2022-08-24 at 9 02 22 PM

Database after changing spam status

Contact Table

Screenshot 2022-08-24 at 9 03 54 PM

LOGOUT

User 2 is logging out.
We have provided the Authorization Token for User 2. See the Key-Value pair inside Headers.

Screenshot 2022-08-24 at 9 25 29 PM

As soon as User 2 logged out, notice that the database column having the Authorization Token for User 2 is set to null, which indicates he is not in session anymore.

Screenshot 2022-08-24 at 9 26 49 PM

Now, even if we pass the earlier Authorization Token for our requests, it would ask to sign in first. Would do the same if we don’t pass any Authorization Token.