Build a Django REST Framework-based backend system that allows authenticated devices to register, send real-time location updates, and view historical location data.
git clone https://github.com/CoderNitu/Mini-GPS-Tracking-Backened-System.git
cd Mini-GPS-Tracking-Backened-System
python -m venv env
# Windows
env\Scripts\activate
# Linux/Mac
source env/bin/activate
pip install -r requirements.txt
Create a .env file based on the .env.example:
SECRET_KEY=your-django-secret-key
DEBUG=True
ALLOWED_HOSTS=127.0.0.1,localhost
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
🔐 Used Token Authentication from DRF for device-level security.
🗺️ Device and Location models for clean tracking logic.
🧪 API tested using Postman.
🔄 Implemented throttling to limit frequent location submissions.
📦 Pagination enabled for listing devices or location history.
Method | Endpoint | Description | Auth Required |
---|---|---|---|
POST | /devices/register/ |
Register a new device | ❌ No |
POST | /locations/ |
Submit a device's location | ✅ Yes (Token) |
GET | /locations/<device_id>/ |
Get location history of a device | ✅ Yes |
GET | /devices/ |
List all registered devices | ✅ Yes |
Use Token Authentication.
Register a device → get a token in response.
Use this token in the Authorization header for other requests:
Authorization: Token <your_token>
POST /devices/register/
📬 Sample Payloads & Responses
1. Register Device (No Auth)
POST /devices/register/
Response:
{
"device_id": "DEVICE123",
"device_name": "Truck A",
"token": "abc123tokenvalue"
}
POST /locations/
"latitude": 26.9124,
"longitude": 75.7873
}
Authorization: Token abc123tokenvalue
Response:
{
"device": "DEVICE123",
"latitude": 26.9124,
"longitude": 75.7873,
"timestamp": "2025-08-02T12:00:00Z"
}
GET /locations/DEVICE123/
Authorization: Token abc123tokenvalue
Response:
[
{
"latitude": 26.9124,
"longitude": 75.7873,
"timestamp": "2025-08-02T12:00:00Z"
},
...
]
A complete Postman collection is included to demonstrate the usage of all API endpoints.
🔗 Download & Use You can import the collection into Postman using the following steps:
Open Postman.
Click on "Import" at the top left.
Select the file: gps_api_collection.json (included in the project root).
The collection will appear in your workspace.
Register Device (POST /devices/register/)
Submit Location (POST /locations/)
Get Device List (GET /devices/)
Get Location History (GET /locations/<device_id>/)
Each request includes:
Required headers (e.g., Authorization: Token ...)
Sample request bodies (JSON)
Sample responses
https://drive.google.com/file/d/1MDXjMFf3BIjlpRPcnQBCOPIh2NJ_9lQl/view?usp=sharing
Base URL: https://mini-gps-tracking-backened-system.onrender.com