Skip to main content

A Django leaderboard (scoreboard) app, using redis as its backend

Project description

A Django leaderboard (scoreboard) app, using redis as its backend. This app is a wrapper for the python-leaderboard api https://github.com/agoragames/python-leaderboard

The app uses Redis KVS for its back-end and stores the scores on its ‘sorted set’ data structure, which keeps the data ordered and allows us to retrieve, update and delete scores efficiently.

With this app, you can get the leaderboard with pagination, create scores, update or delete them. Even get rankings around the given score.

Features

  • RESTful api for creating, updating, deleting and retrieving high scores or scores around the user

  • Standard view for displaying high scores with pagination

Not implemented features

  • delete method for the api

Requirements

Python leaderboards module pip install leaderboard, note that this module will install redis and hiredis modules as its dependancy djangorestframework pip install djangorestframework for providing the rest behavior.

Installation

  • Add the django_leaderboard folder to your path.

  • Add django_leaderboard to APPS list in settings.py

  • Make sure that your redis server is running.

  • Add following lines to your urls.py file.

  • Run python manage.py runserver to test it out.

    url(r’^leaderboard/’, include(‘django_leaderboard.urls’)), # auth support for rest framework url(r’^restframework’, include(‘djangorestframework.urls’, namespace=’djangorestframework’))

Usage

Thanks to djangorestframeword, you can just visit http://localhost:8000/leaderboard/api/<game-identifier>/ to create, update or get the leaderboard.

Other urls are http://localhost:8000/leaderboard/api/<game-identifier>/user/<user-id>/ for scores around the user, and http://localhost:8000/leaderboard/api/<game-identifier>/<page-id>/ for pagination. Please see urls.py to see the full list or urls.

To create new ranking using the api, send a POST request to http://localhost:8000/leaderboard/api/<game-identifier>/. Game identifier is the key to determine your game to the system. it can be anything. Parameters are user_id`and `score. To see the html table of leaderboard, go to http://localhost:8000/leaderboard/highscores/<game-identifier>/ page.

Example

There is an example project in the source to make it easy to start.

Contributions

Please feel free to contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-leaderboard-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file django-leaderboard-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django-leaderboard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1249940e6fc30febf6d49b8f58f542b68dd7f2e01d109ee3efa739833d90fed3
MD5 53a02a0b854750be0758afa5335816cd
BLAKE2b-256 b0db46004243fcefdb362f1b617631b286e7dcaac007747611c05959bdd8c169

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page