Skip to content


APIs specify the functionality available on the bus. To do this you define API classes within your file. You can also define your API elsewhere and import it into your file.

For further discussion of APIs see the concepts section.

An example API

# An example API. You can define this in your,
# or import into your file from elsewhere

class SupportCaseApi(Api):
    # An event,
    # available at
    case_created = Event(parameters=('id', 'sender', 'subject', 'body'))

    # Options for this API
    class Meta:
        # API name on the bus
        name = ''

    # Will be available as a remote procedure call at
    def get(self, id):
        return get_case_from_db(pk=id)

A service can define zero or more APIs, and each API can contain zero or more events and zero or more procedures.

The Meta class specifies options regarding the API, with name being the only required option. The name specifies how the API will be accessed on the bus.

You could call an RPC on the above API as follows:

bus = lightbus.create()

# Call the get_case() RPC.
case =

You can also fire an event on this API:

bus = lightbus.create()

# Fire the case_created event
    subject='I need support please!',


name (str)

Specifies the name of the API. This will determine how the API is addressed on the bus. See naming, below.

name is a required option.

Naming your APIs

As you can from the option in the example above, API names can contain periods which allow you to structure your bus in a suitable form for your situation. Some example API naming schemes may look like:

# Example API naming schemes for use within
Format:  <service>
Example: support.get_case()

Format:  <service>.<object>

Format:  <deparment>.<service>.<object>

Organising many APIs

  • Will lightbus recognise a bus package as well as a bus module? (i.e.bus/ TODO
    • It does now