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

We hear you like APIs...

Download Python bindings and examples Version 0.1.3

 

Installation instructions

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

You can find your API key on your settings page. Once you have it, create ~/.humbugrc and add the following text to it:

[api]
key=YOUR_API_KEY
email=YOUR_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/send_message \
    -d "api-key=YOUR_API_KEY" \
    -d "email=YOUR_EMAIL" \
    -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/send_message \
    -d "api-key=YOUR_API_KEY" \
    -d "email=YOUR_EMAIL" \
    -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(
    # These options are only necessary if you didn't make a .humbugrc
    # api_key=YOUR_API_KEY,
    # email=YOUR_EMAIL_ADDRESS,
    verbose=True)

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)

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."
{% endblock %}