Bondy Connect
Skip to content

Loading an API Gateway Specification ​

Learn how to load an API Gateway Specification using the HTTP Admin API.

Loading an API you have defined using the API Gateway Specification is very easy you just need to know the location of your file and use the HTTP Admin API.

Assumptions ​

The following instructions assume the following:

  • Your API Specification file is called my_api.json
  • Your API Specification id property has the value com.example.my_api
  • Bondy is running at localhost on port 18081

Host and Port

Port 18081 is where the reserved admin listener serves the Admin API by default — no configuration is needed. If your bondy.conf declares its own listeners.admin.* block, use the port it states; see the Network Listeners Reference.

Loading the API Specification ​

The following command will load the API Specification, validate it and if successful it will be compiled and activate it.

bash
curl -X "POST" "http://localhost:18081/services/load_api_spec" \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Accept: application/json; charset=utf-8' \
--data-binary "@my_api.json"

Cluster deployments

If this node is part of a Bondy cluster, the API will be automatically replicated and activated in all nodes.

Verifying the API Specification has been loaded ​

If the previous command didn't fail the API has been loaded and activated. However, to be entirely sure you can use the following command which should retrieve the API Specification.

bash
curl -X "GET" "http://localhost:18081/api_specs/com.example.my_api"

A stored specification is not always served. To check that a node serves it, call the WAMP procedure bondy.http_gateway.api.status on that node:

bash
wick --url ws://localhost:18080/ws \
--realm com.leapsight.bondy \
call bondy.http_gateway.api.status

Find the element whose id is your specification's id. The status active means that the node serves the specification.

If the status is pending_realm, the specification's realm does not exist on the node. Create the realm. The node installs the specification's routes at its next rebuild after the realm appears.

If the status is rejected, the specification failed to parse, and reason describes the failure. Correct the specification and load it again.