This is a backend API that takes in a list of emails as input and returns an integer denoting the total unique emails in the list.
An email consists of two parts: username and domain name, divided by the @ sign.
If the email is [email protected], username is vivekwap4 and domain is email.com
If the username contains a '.', it's ignored. For example vivek.wap4 becomes vivekwap4.
If the username contains a'+', everything from that position is ignored. For example vivek+wap4 becomes vivek.
The API follows these rules and returns total unique emails
Input: ["[email protected]","[email protected]", "[email protected]"] Output: 2. Because [email protected] becomes [email protected], [email protected] becomes [email protected], and [email protected] again becomes [email protected]. Therefore, we have two distinct email addresses.
The API is written using Java (JAX-RS). Please use POST method when using it.
-
To run it locally, clone it to your system. Please make sure that you have Java, Eclipse, and Tomcat installed. Open Eclipse -> File -> Import Maven Project and import the project. Right click on the project -> Run As -> 1 Run on Server. The app would open a browser window with the path to the app root. The endpoint we want to target is localhost:8080/unique-emails/rest/emails/unique using a POST method. The API can be tested through Postman.
-
The API is also deployed on heroku and can be hit at: https://unique-emails.herokuapp.com/rest/emails/unique