Need help with thorn?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

472 Stars 58 Forks Other 226 Commits 13 Opened issues


Easy Webhooks for Python

Services available


Need anything else?

Contributors list

.. image::


Python Stream Processing

|build-status| |coverage| |license| |wheel| |pyversion| |pyimp|

:Version: 1.5.2 :Web: :Download: :Source: :Keywords: event driven, webhooks, callback, http, django

.. contents:: Table of Contents: :local:


Thorn is a webhook framework for Python, focusing on flexibility and ease of use, both when getting started and when maintaining a production system.

The goal is for webhooks to thrive on the web, by providing Python projects with an easy solution to implement them and keeping a repository of patterns evolved by the Python community.

  • Simple

    Add webhook capabilities to your database models using a single decorator, including filtering for specific changes to the model.

  • Flexible

    All Thorn components are pluggable, reusable and extendable.

  • Scalable

    Thorn can perform millions of HTTP requests every second by taking advantage of

    _ for asynchronous processing.

.. _


What are webhooks?

A webhook is a fancy name for an HTTP callback.

Users and other services can subscribe to events happening in your system by registering a URL to be called whenever the event occurs.

The canonical example would be GitHub where you can register URLs to be called whenever a new change is committed to your repository, a new bugtracker issue is created, someone publishes a comment, and so on.

Another example is communication between internal systems, traditionally dominated by complicated message consumer daemons, using webhooks is an elegant and REST friendly way to implement event driven systems, requiring only a web-server (and optimally a separate service to dispatch the HTTP callback requests).

Webhooks are also composable, so you can combine multiple HTTP callbacks to form complicated workflows, executed as events happen across multiple systems.

In use

Notable examples of webhooks in use are:

+------------+---------------------------------------------------------------+ | Site | Documentation | +------------+---------------------------------------------------------------+ | Github | | +------------+---------------------------------------------------------------+ | Stripe | | +------------+---------------------------------------------------------------+ | PayPal | | +------------+---------------------------------------------------------------+


This example adds four webhook events to the Article model of an imaginary blog engine:


from django.urls import reverse
from thorn import ModelEvent, webhook_model

@webhook_model #

Users can now subscribe to the four events individually, or all of them by subscribing to

, and will be notified every time an article is created, changed, removed or published:


$ curl -X POST                                                      \
> -H "Authorization: Bearer "                   \
> -H "Content-Type: application/json"                               \
> -d '{"event": "article.*", "url": ""}' \

The API is expressive, so may require you to learn more about the arguments to understand it fully. Luckily it's all described in the

Events Guide
_ for you to consult after reading the quick start tutorial.

What do I need?

.. sidebar:: Version Requirements :subtitle: Thorn version 1.0 runs on

- Python (2.7, 3.4, 3.5)
- PyPy (5.1.1)
- Jython (2.7).

  • Django (1.8, 1.9, 1.10) Django 1.9 adds the transaction.on_commit() feature, and Thorn takes advantage of this to send events only when the transaction is committed.

Thorn currently only supports

, and an API for subscribing to events is only provided for
Django REST Framework

Extending Thorn is simple so you can also contribute support for your favorite frameworks.

For dispatching web requests we recommend using

_, but you can get started immediately by dispatching requests locally.


_ for dispatching requests will require a message transport like
_ or

You can also write custom dispatchers if you have an idea for efficient payload delivery, or just want to reuse a technology you already deploy in production.

.. _

: .. _
: .. _
Django REST Framework
: .. _
: .. _

Quick Start

Go immediately to the

guide to get started using Thorn in your Django projects.

If you are using a different web framework, please consider contributing to the project by implementing a new environment type.


Thorn was inspired by multiple Python projects:

  • dj-webhooks
  • django-rest-hooks
  • durian

.. _

: .. _
: .. _

.. _

Events Guide

.. _installation:


Installing the stable version

You can install thorn either via the Python Package Index (PyPI) or from source.

To install using



$ pip install -U thorn

.. _installing-from-source:

Downloading and installing from source

Download the latest version of thorn from

You can install it by doing the following,:


$ tar xvfz thorn-0.0.0.tar.gz
$ cd thorn-0.0.0
$ python build
# python install

The last command must be executed as a privileged user if you are not currently using a virtualenv.

.. _installing-from-git:

Using the development version

With pip ~~~~~~~~

You can install the latest snapshot of thorn using the following pip command:


$ pip install

.. _

Events Guide

.. _getting-help:

Getting Help

.. _mailing-list:

Mailing list

For discussions about the usage, development, and future of Thorn, please join the

_ mailing list.

.. _


.. _irc-channel:


Come chat with us on IRC. The #thorn channel is located at the

_ network.

.. _


.. _bug-tracker:

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to our issue tracker at

.. _contributing-short:


Development of

happens at GitHub:

You are highly encouraged to participate in the development of

. If you don't like GitHub (for some reason) you're welcome to send regular patches.

Be sure to also read the

Contributing to Thorn
_ section in the documentation.

.. _

Contributing to Thorn

.. _license:


This software is licensed under the

New BSD License
. See the
file in the top distribution directory for the full license text.

.. # vim: syntax=rst expandtab tabstop=4 shiftwidth=4 shiftround

.. _

Events Guide

.. |build-status| image:: :alt: Build status :target:

.. |coverage| image:: :target:

.. |license| image:: :alt: BSD License :target:

.. |wheel| image:: :alt: Thorn can be installed via wheel :target:

.. |pyversion| image:: :alt: Supported Python versions. :target:

.. |pyimp| image:: :alt: Support Python implementations. :target:

.. _

Events Guide

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.