# ๐ก Backend API
The **Video Ads Backend API** powers the Android Ads SDK.
It provides ad delivery, configuration management, authentication, and an administration portal for managing ad content dynamically.
The API is built with **Flask**, deployed on **Vercel**, and backed by **MongoDB Atlas**.
## ๐ Deployment
- **Base URL**
https://vercel.com/talyas-projects-8ed6edb8/video-ads-sdk
- **Hosting:** Vercel
- **Database:** MongoDB Atlas
## ๐ Authentication
The API uses **JWT-based authentication**.
### Login
POST /auth/login
{
"username": "your-username",
"password": "your-password"
}
{
"token": "<jwt-token>"
}
The token must be sent in subsequent requests: Authorization: Bearer
## Registration (Developer Accounts)
POST /auth/register
{
"username": "developer-username",
"password": "developer-password",
"clientId": "developer-id"
}
Creates a developer account tied to a specific clientId (app).
The developer chooses their own id, and use it in the app when initiating the library.
## ๐ข Ads Endpoints
List Ads
GET /ads?clientId=
Create Ad
POST /ads
{
"clientId": "developer-id",
"id": "ad-id",
"title": "ad-title",
"type": "image/video",
"imageUrl": "https://...",
"clickUrl": "https://...",
"categories": \["ad-catagory"],
"enabled": true
}
Update Ad
PUT /ads/{adId}
Allows updating ad fields such as enabled, title, URLs, or categories.
Delete Ad
DELETE /ads/{adId}
Deletes an existing ad.
## ๐ฏ Ad Selection (Used by the SDK)
GET /ads/select?clientId=
response:
{
"ad": {
"id": "ad-id",
"type": "image/video",
"imageUrl": "...",
"clickUrl": "...",
"categories": \["ad-catagory"]
}
}
If no valid ad is found:
{ "ad": null }
This endpoint is public and optimized for SDK usage.
## โ๏ธ Client Configuration
Each client app can control which ads are eligible.
Get Config
GET /config/{clientId}
Update Config
PUT /config/{clientId}
{
"allowedTypes": \["image", "video"],
"allowedCategories": \["ad-catagory"]
}
Configuration directly affects /ads/select.
## ๐ ๏ธ Administration Portal
A web-based portal is included for managing ads and configurations.
๐ Portal URL
https://video-ads-sdk-git-main-talyas-projects-8ed6edb8.vercel.app/portal/login.html
### Features
- Secure login (admin \& developer roles)
- Create, edit, enable, and delete ads
- Manage client configurations
- Immediate effect on SDK behavior (no app updates required)
- End users of client apps never access the portal.
## ๐งช Health Check
GET /health
{
"status": "ok",
"db": "connected"
}
## ๐ง Environment Variables
The API requires the following environment variables:
MONGODB\_URI
ADMIN\_USERNAME
ADMIN\_PASSWORD
JWT\_SECRET
## ๐ License
This project is released under the MIT License.