I recently built and deployed my first API — an email validation
tool built with Python and FastAPI. Here's how I did it and what
I learned along the way.
Why Email Validation?
Every app that accepts user signups needs email validation.
Most developers either roll their own regex (which misses a lot)
or pay too much for an enterprise solution. I wanted to build
something simple, affordable, and reliable.
What It Does
The API checks email addresses for:
- Format — RFC 5322 compliance
- MX Records — confirms the domain actually receives email
- Disposable domains — flags throwaway addresses like mailinator.com
- Typos — catches mistakes like gmial.com and suggests gmail.com
Each response includes a 0-100 quality score.
The Tech Stack
- Python — FastAPI for the web framework
- dnspython — for MX record lookups
- Railway — for deployment
- RapidAPI — for distribution and billing
Quick Example
import requests
url = "https://email-validation52.p.rapidapi.com/validate"
params = {"email": "test@gmail.com"}
headers = {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "email-validation52.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=params)
print(response.json())
Example Response
{
"email": "test@gmail.com",
"is_valid": true,
"score": 95,
"checks": {
"format": true,
"mx_record": true,
"disposable": false,
"typo": false
},
"suggestion": null,
"elapsed_ms": 245
}
What I Learned
FastAPI is incredible for building APIs quickly. It generates
interactive documentation automatically at /docs which makes
testing and sharing your API effortless.
Deploying to Railway was surprisingly simple — connect your
GitHub repo and it handles everything else.
The hardest part wasn't the code. It was getting all the pieces
working together — deployment, billing, documentation. But once
it clicked it all made sense.
Try It Free
I listed it on RapidAPI with a free tier of 500 requests/month.
https://rapidapi.com/Willivan0706/api/email-validation52
Would love feedback from anyone who works with email validation
or has built APIs before!
Top comments (0)