Django REST API for blog analytics, view counts, top charts, and period-over-period growth.
docker compose up --buildTo run the test suite inside the container:
docker compose run --rm web python manage.py test analyticsRequires Python 3.11+ and a running Postgres instance.
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt{
"object_type": "country",
"range": "month"
}object_type:country|userrange:week|month|yearx= country name or username,y= distinct blog count,z= total views
{
"top": "blog",
"range": "week"
}top:user|country|blog- For
blog:x= title,y= author username,z= views - For
user/country:x= name,y= blog count,z= views
{
"compare": "month",
"user_id": 3
}compare:day|week|month|yearuser_idis optional — leave it out for site-wide numbersx= period label + how many blogs were created that periody= views during that periodz= growth % vs previous period (0.0if previous period had no views)
Every endpoint accepts an optional filter key. Supports and, or, not, and eq.
{
"filter": {
"and": [
{ "eq": { "field": "blog__author__country__name", "value": "Egypt" } },
{ "not": { "eq": { "field": "blog__is_published", "value": false } } }
]
}
}