Skip to main content

Overview

This guide covers complete installation of FKApi with all features including PostgreSQL, Redis caching, and optional Celery for background tasks.
For a quick development setup, see the Quickstart Guide.

Prerequisites

Ensure you have the following installed:
  • Python 3.11+ (tested with 3.11)
  • PostgreSQL 15+ (or 12+ for development)
  • Redis 6+ (optional, for caching and Celery)
  • Git for version control
  • pip and virtualenv

Installation Steps

1

Clone Repository

Clone the FKApi repository:
2

Create Virtual Environment

Create an isolated Python environment:
Verify activation:
3

Install Dependencies

Install all required packages:
For development with testing tools:
Key Dependencies Installed:
  • Django 5.0.4 - Web framework
  • django-ninja 1.1.0 - REST API framework
  • psycopg2-binary 2.9.9 - PostgreSQL adapter
  • django-redis 5.4.0 - Redis cache backend
  • celery 5.4.0 - Async task queue (optional)
  • beautifulsoup4 4.12.3 - Web scraping
  • cloudscraper 1.2.71 - Cloudflare bypass
  • django-countries 7.6.1 - Country field support
4

Configure Environment Variables

Copy the example environment file:
Edit .env with your configuration:
.env
Production Security:
  • Set DJANGO_DEBUG=False in production
  • Generate a strong DJANGO_SECRET_KEY
  • Use a secure POSTGRES_PASSWORD
  • Configure DJANGO_ALLOWED_HOSTS with your domain
5

Set Up PostgreSQL Database

Create the database:
Verify connection:
6

Run Database Migrations

Apply all database migrations:
You should see output like:
7

Create Superuser

Create an admin account:
Enter username, email, and password when prompted.
8

Set Up Redis (Optional but Recommended)

Start Redis server:
Test Redis connection:
9

Verify Installation

Start the development server:
Test the API:
Expected response:

Optional: Celery Setup

Celery enables background task processing for scraping operations.
Celery is optional. The system automatically falls back to threading if Celery is not available.

Install Celery

Celery is included in requirements.txt, but verify:

Configure Celery

Ensure these settings in .env:

Start Celery Worker

Start Celery Beat (Scheduled Tasks)

Monitor with Flower

Flower provides a web UI for monitoring Celery:
Access at: http://localhost:5555

Production Deployment

Security Settings

For production, update .env:

Use Gunicorn

Gunicorn is included in requirements.txt:

Nginx Configuration Example

Systemd Service Example

Create /etc/systemd/system/fkapi.service:
Enable and start:

Environment Variables Reference

Django Settings

Database Settings

Cache Settings

Celery Settings

Scraper Settings

Rate Limiting

Troubleshooting

PostgreSQL Connection Issues

Redis Connection Issues

Migration Errors

Celery Not Starting

Next Steps

Quickstart Guide

Make your first API call

API Reference

Explore all endpoints

Scraping Guide

Learn ethical data collection

Admin Interface

Manage data via Django admin