API reference

API

The service exposes the following AFB API:

helloworld

It provides three verbs: hello, sum and info.

For AFB API and request handling concepts, see the AFB documentation.

hello

Returns a greeting.

Request hello

The first argument is optional. When present, the Python service converts it to a readable textual representation and uses it in the reply. Strings are used directly, structured JSON values are serialized compactly, and other scalar values use their normal Python string representation.

Without an argument:

afb-client -H localhost:1234/api helloworld hello

With an argument:

afb-client -H localhost:1234/api helloworld hello Python

Reply hello

Without an argument:

Hello world!

With Python as the first argument:

Hello Python!

The Python implementation returns the complete greeting and does not impose a fixed byte limit on the reply.

Event hello

Each call publishes helloworld/verb_called with hello as payload.

sum

Computes the sum of a JSON array of signed 64-bit integers.

Request sum

Exactly one argument is expected. It must be a JSON array containing only integers.

Example:

afb-client -H localhost:1234/api helloworld sum '[1,2,3,4]'

Reply sum

The reply is a signed 64-bit integer containing the sum of all array elements. The accumulation uses signed 64-bit wrapping semantics as part of the shared sum API contract.

For the previous example, the result is:

10

An empty array returns 0.

Error sum

Invalid requests fail with a message matching the validation error. The service distinguishes between a wrong number of arguments, a non-array argument, non-integer array values, and integers outside the signed 64-bit range.

Event sum

The call publishes helloworld/verb_called with sum as payload before validating the request arguments.

info

afb-libpython provides a default implementation of the info verb from the API and verb metadata.

Request info

No argument is required:

afb-client -H localhost:1234/api helloworld info

Reply info

The reply contains the generated API metadata and the descriptions of the registered hello and sum verbs.

The Python implementation does not need to register an explicit info callback because afb-libpython already provides a default implementation. The default can still be overridden when custom behavior is required.

Event reference

helloworld/verb_called

Property Value
Event name helloworld/verb_called
Payload type string
Payload name of the called verb
Emitted by hello, sum
Subscription automatic for the caller