Skip to content

SocialHubAPI Documentation

Welcome to the SocialHubAPI documentation. This project provides a complete social API with CRUD operations for posts and social interactions including likes, comments, and shares.

Quick Start

Get up and running with SocialHubAPI:

# activate virtual environment
source venv/bin/activate
# install dependencies
pip install -r requirements.txt
# run migrations
python manage.py migrate
# start server
python manage.py runserver 0.0.0.0:8000

Documentation Overview

API Reference

Authentication

Configuration

JWT Authentication

The API uses JWT tokens for secure authentication. Configure your secret key:

JWT_SECRET_KEY=your-jwt-secret-key-here

Base URLs

  • Posts API: http://localhost:8000/careers/
  • Users API: http://localhost:8000/users/
  • API Docs: http://localhost:8000/api/docs/

Authentication

Use JWT tokens in all requests:

-H "Authorization: Bearer <jwt_token>"

Examples

Register and Use the API

# 1. Register user
curl -X POST "http://localhost:8000/users/register/" \
  -H "Content-Type: application/json" \
  -d '{"username": "alice", "email": "alice@example.com", "password": "password123", "password_confirm": "password123"}'
# 2. Login and save token
TOKEN=$(curl -X POST "http://localhost:8000/users/login/" \
  -H "Content-Type: application/json" \
  -d '{"username": "alice", "password": "password123"}' | jq -r '.access')
# 3. Use token for API calls
curl -X POST "http://localhost:8000/careers/create/" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "Hello", "content": "World!"}'