{% extends "zephyr/portico.html" %} {# API information page #} {% block portico_content %}

We hear you like APIs...

We have a well-documented API that allows you to build custom integrations, in addition to our existing integrations. For ease-of-use, we've created a Python module that you can drop in to a project to start interacting with our API.


Download Python bindings and examples Version 0.1.8

 

Installation instructions

This package uses distutils, so you can just run python setup.py install after downloading.

You can find your API key and allocate new API keys for bots/integrations that you run on your settings page. Create ~/.humbugrc and add the following text to it:

[api]
key=API_KEY
email=EMAIL_ADDRESS

Don't want to make it yourself? Humbug already integrates with lots of services.

 

Usage examples

No download required!

{% comment %} These code snippets are generated using our very own Humbug tool, by sending them to myself in a code block, and then using the inspector to pull out the resulting HTML :) {% endcomment %}

Stream message

curl https://humbughq.com/api/v1/messages \
    -u YOUR_EMAIL:YOUR_API_KEY \
    -d "type=stream" \
    -d "to=Denmark" \
    -d "subject=Castle" \
    -d "content=Something is rotten in the state of Denmark."

Private message

curl https://humbughq.com/api/v1/messages \
    -u YOUR_EMAIL:YOUR_API_KEY \
    -d "type=private" \
    -d "to=wdaher@humbughq.com" \
    -d "content=I come not, friends, to steal away your hearts."
#!/usr/bin/env python

import humbug
client = humbug.Client()

stream_message = {
    "type": "stream",
    "to": "Denmark",
    "subject": "Castle",
    "content": "Something is rotten in the state of Denmark."
}

private_message = {
    "type": "private",
    "to": "wdaher@humbughq.com",
    "content": "I come not, friends, to steal away your hearts."
}

print client.send_message(stream_message)
print client.send_message(private_message)

# Print each message the user receives
client.call_on_each_message(lambda msg: sys.stdout.write(str(msg) + "\n"))

You can use humbug-send (found in bin/ in the tarball) to easily send Humbugs from the command-line, providing the message to be sent on STDIN.

Stream message

humbug-send --stream Denmark --subject Castle

Private message

humbug-send wdaher@humbughq.com

Passing in the message on the command-line

If you'd like, you can also provide the message on the command-line with the -m flag, as follows:

humbug-send --stream Denmark --subject Castle -m "Something is rotten in the state of Denmark."

See also the full API endpoint documentation.

{% endblock %}