API
API
▲▼▲▼▲▼
tags : #flutter #coding
references : Coding
▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼
▲▼▲▼▲▼### 🚀 What is an API?
🛠️Types of APIs
APIs come in different forms based on architecture and usage:
1️⃣ Request
Your app (client) sends a request to https://api.spense.com/expenses with:
{
"userId": 123,
"amount": 50,
"category": "Food"
}
2️⃣ Processing
The API backend:
Authenticates the user.
Validates the data (e.g., amount is a number).
Saves the data to the database.
3️⃣ Response
The API returns:
{
"status": "success",
"expenseId": 789
}
🛡️API Security
APIs need protection to prevent unauthorized access.
Common security methods:
🔒 API Keys – A secret key sent with requests.
🔒 OAuth2 – Secure authentication (Google/Facebook login).
🔒 JWT (JSON Web Token) – Encrypted tokens for authentication.
🎯 Final Thoughts
APIs connect your app to the world! They enable real-time updates, external data integration,
and secure storage.
Since your Spense app is 70% complete, integrating an API can help:
✅ Sync expenses across multiple devices.
✅ Store user data securely.
✅ Fetch exchange rates or financial insights.
👉 Do you want to build your own backend (Node.js, Firebase, Supabase) or just consume
external APIs? 🚀