Skip to main content

Lesson 10. JSON-RPC support

Example 10.1. JSON-RPC 2.0 example

URL /rpc-api
Protocol json-rpc-2.0

Method newCat // Create a cat.
Params
@cat
Result
123 // Cat’s id.

Method getCat // Get a cat.
Params
123 // Cat’s id.
Result
@cat

This example shows how easy it is to describe an API using the JSON-RPC 2.0 protocol. To do this, add a Protocol json-rpc-2.0 child directive to the URL directive (line 2). Then, you may define any number of JSON-RPC methods for this URL directive using the Method, Params, and Result directives. When describing input and output parameters, you may use JSight Notation Schema, just like you would when describing a regular REST API.

info

For more information about this topic, see: