DEV Community

hajar balirh
hajar balirh

Posted on

How I Built and Launched a KYC Selfie Verification API in One Day (Free to Try)

I've always wanted to build a product I could sell online.
Last week I did it — a full AI-powered KYC API, live in production,
listed on RapidAPI, with a registration system and usage dashboard.
Here's exactly how I built it.

What is KYC?

KYC (Know Your Customer) is the process of verifying a user's identity.
Every fintech, bank, marketplace, and crypto platform needs it.
Most solutions cost thousands of dollars per month. I built one for free.

What the API does

  • ✅ Face detection and centering check
  • ✅ Liveness detection (real person vs photo of photo)
  • ✅ Age estimation (18+/21+ flags)
  • ✅ Glasses and mask detection
  • ✅ Emotion detection
  • ✅ Background quality check
  • ✅ ID document data extraction (name, DOB, document number)
  • ✅ Selfie vs ID document face matching
  • ✅ Confidence score 0-100

The tech stack

  • FastAPI — Python REST API
  • Gemini Vision via OpenRouter — AI image analysis (free tier)
  • SQLite + SQLAlchemy — database for storing verifications
  • Railway — deployment (free tier)

The API in action

Get a free API key at:
https://kyc-selfie-api-production.up.railway.app/register

Then verify a selfie in Python:

import requests

response = requests.post(
    "https://kyc-selfie-api-production.up.railway.app/v1/verify/selfie",
    headers={"x-api-key": "your-api-key"},
    files={"selfie": open("photo.jpg", "rb")}
)

result = response.json()
print(result)
Enter fullscreen mode Exit fullscreen mode

Response:

{
  "approved": true,
  "confidence": 92,
  "face_detected": true,
  "face_centered": true,
  "eyes_open": true,
  "liveness_score": 95,
  "age_estimate": 26,
  "appears_18_plus": true,
  "glasses_detected": false,
  "mask_detected": false,
  "emotion": "neutral",
  "background_quality": "clean",
  "lighting_quality": "good",
  "issues": []
}
Enter fullscreen mode Exit fullscreen mode

Extract data from an ID document

response = requests.post(
    "https://kyc-selfie-api-production.up.railway.app/v1/verify/document",
    headers={"x-api-key": "your-api-key"},
    files={"document": open("id_card.jpg", "rb")}
)

doc = response.json()
print(f"Name: {doc['full_name']}")
print(f"DOB: {doc['date_of_birth']}")
print(f"Number: {doc['document_number']}")
Enter fullscreen mode Exit fullscreen mode

Full KYC — match selfie against ID

with open("selfie.jpg", "rb") as s, open("id.jpg", "rb") as d:
    response = requests.post(
        "https://kyc-selfie-api-production.up.railway.app/v1/verify/kyc",
        headers={"x-api-key": "your-api-key"},
        files={"selfie": s, "document": d}
    )

result = response.json()
print(f"Match approved: {result['approved']}")
print(f"Confidence: {result['confidence']}%")
Enter fullscreen mode Exit fullscreen mode

Available endpoints

Endpoint Description
POST /v1/verify/selfie Selfie analysis
POST /v1/verify/kyc Selfie + ID matching
POST /v1/verify/document Extract ID data
POST /v1/verify/age Age estimation
GET /v1/status/{id} Check past result
GET /v1/usage Usage stats

Pricing

Plan Price Calls/month
Basic Free 100
Pro $49/mo 10,000
Ultra $99/mo 50,000

What I learned

Building this in one day taught me a few things:

1. AI APIs make everything easier. Instead of training a custom face
detection model, I used Gemini Vision via a simple API call. The prompt
engineering took 10 minutes.

2. FastAPI is incredible. Auto-generated docs at /docs,
type validation, async support — everything just works.

3. Distribution is harder than building. The API took one day.
Getting people to use it is the real challenge.

What's next

  • Arabic and Moroccan CIN support (huge untapped niche)
  • Email notifications when verification completes
  • React SDK for easy frontend integration
  • Video liveness detection

Try it free

🔗 Register: https://kyc-selfie-api-production.up.railway.app/register
🔗 Live demo: https://kyc-selfie-api-production.up.railway.app
🔗 API docs: https://kyc-selfie-api-production.up.railway.app/docs
🔗 RapidAPI: https://rapidapi.com/balirh12/api/kyc-selfie-verification

Free plan — 100 verifications/month, no credit card required.


Built with ❤️ using FastAPI, Gemini Vision, and Railway.
Questions? Drop them in the comments!

Top comments (1)

Collapse
 
kiran0247y profile image
Kiran

Ohh very nice , is it optimized and take less resources to work ?? Like is it optimal to run ??