Home Projects Services Blog Contact
Back to Blog

Article

Subtitle

TL;DR

Summary

What is an API?

API = Application Programming Interface. It's a contract between two pieces of software. When your mobile app asks "give me the user's orders", it's talking to an API.

Think of a restaurant: you're the customer (client), the waiter is the API, and the kitchen is the server. You don't go into the kitchen — you order through the waiter.

What Makes an API "REST"?

REST (Representational State Transfer) is a set of rules for designing APIs using HTTP. The 4 main operations: GET (read), POST (create), PUT/PATCH (update), DELETE (delete).

REST API — The 4 Operations
GET    /api/users/       → Get all users
GET    /api/users/42/    → Get user #42
POST   /api/users/       → Create a new user
PUT    /api/users/42/    → Update user #42 entirely
PATCH  /api/users/42/    → Update user #42 partially
DELETE /api/users/42/    → Delete user #42

Building a REST API with Django

Django REST Framework (DRF) is the standard for building APIs with Python. Here's a complete example:

Django REST Framework — Quick Start
# Install
pip install django djangorestframework

# models.py
from django.db import models

class Project(models.Model):
    title = models.CharField(max_length=200)
    description = models.TextField()
    created_at = models.DateTimeField(auto_now_add=True)

# serializers.py
from rest_framework import serializers
from .models import Project

class ProjectSerializer(serializers.ModelSerializer):
    class Meta:
        model = Project
        fields = '__all__'

# views.py
from rest_framework import viewsets
from .models import Project
from .serializers import ProjectSerializer

class ProjectViewSet(viewsets.ModelViewSet):
    queryset = Project.objects.all()
    serializer_class = ProjectSerializer

# urls.py
from rest_framework.routers import DefaultRouter
from .views import ProjectViewSet

router = DefaultRouter()
router.register(r'projects', ProjectViewSet)
urlpatterns = router.urls

DRF (Django REST Framework) is used by Instagram, Pinterest, Mozilla. It's the most mature Python API framework and the industry standard in Tunisia for backend development.

What an API Response Looks Like

API Response — JSON
{
  "id": 42,
  "title": "Hesabi — Accounting Platform",
  "description": "Built with Next.js for Tunisian businesses",
  "created_at": "2026-01-15T10:30:00Z",
  "tech_stack": ["Next.js", "PostgreSQL", "Docker"]
}

Key Takeaways

Every app you use has an API: Instagram, Uber, your bank app. Learning to build one with Django is one of the most valuable skills you can have as a developer in Tunisia today.

Tous les articles Article suivant