Home Projects Services Blog Contact
Back to Blog

What is a REST API? A plain explanation

Almost every app you use talks to a backend through an API. This is how REST APIs work, with a working Django example.

TL;DR

An API is the interface a program exposes so that other programs can use it. REST is the most common style for web APIs: each resource has a URL, you act on it with HTTP methods, and data usually travels as JSON.

What is an API?

API stands for Application Programming Interface. It's a contract between two pieces of software: which requests you can send, what they must contain, and what you get back. When your mobile app asks the server for a user's orders, it does it through an API.

The client never touches the database or the server's internals directly. It sends a request in an agreed format, the server validates it, does the work and returns a response. That separation lets you change the backend without breaking the apps that use it, as long as the contract stays the same.

What makes an API REST?

REST (Representational State Transfer) is an architectural style for APIs built on HTTP. Every resource has a URL, and the HTTP method says what you want to do with it: GET to read, POST to create, PUT or PATCH to update, DELETE to remove. Requests are stateless, so each one carries everything the server needs, including authentication.

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 way to build APIs in Django. The example below gives you a full CRUD API for one model in a few dozen lines: a model, a serializer, a viewset and a router.

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 is mature and well documented, and it's used by organizations such as Mozilla, Red Hat and Heroku. In Tunisia it's one of the most common choices for Python backends.

What a response looks like

API Response: JSON
{
  "id": 42,
  "title": "Hesabi: ERP & Invoicing SaaS",
  "description": "Multi-tenant ERP for Tunisian businesses",
  "created_at": "2026-01-15T10:30:00Z",
  "tech_stack": ["Next.js", "PostgreSQL", "Prisma", "Docker"]
}

Key takeaways

Instagram, Uber and your banking app all sit on top of APIs. Designing and building a clean one is a core backend skill, and Django with DRF is a quick way to learn it properly.

Tous les articles Article suivant