Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
101 lines (68 sloc) 2.21 KB

API for Noisebridge

This is a very simple Python WSGI App that provides a RESTful API for fun things in the Noisebridge space.

In the Noisebridge tradition, it's not stable! It will, however try to break in as noisy a way as possible if things change.

Using the API

The API is currently only available within the space. Once we have authorisation running, this will change.

The API is RESTful, and can be called at the URL:[call]

For instance, to open the door using curl:

    curl -X POST -d open=True

GET /hello/[name]

Returns 'hello [name]'

GET /spaceapi/

Returns Noisebridge status, formatted as per

GET /gate/

Gets interesting stats about the gate. Currently:

    ringing: boolean

Where 'ringing' is true if the gate buzzer is ringing at that moment, or in the last few seconds, as users may push the button for a very short time. The amount of time that this state is cached is totally up to the Gateman daemon that runs to interact with the gate hardware.

POST /gate/

With open=True, opens the door. Returns a 300 error if unsuccessful, and the following additions to the /gate/ stats if successful:

    open : True
    message: string

POST /audio/

With say=[TEXT] will convert the TEXT into speech, and announce it to the space.

Adding to the API is a Bottle. It should be pretty self explanatory, even if you don't know much Python.

Just add a function of the form:

def myfunc()
    return { 'success' : True, 'OMG IT WORXORRED' }

Deploying your new API

You'll need sudo powers on pony. Check out the code using git:

    git clone /var/local/noise_api/

Make your changes, and test them locally using

    python --debug

When you're ready to deploy, commit the code, then pull it out to the runningversion of

    cd /var/local/noise_api/
    sudo git pull [your cloned directory goes here]
    sudo make install