Rest Api HowTo
From Koha Wiki
REST API Developers How-To
This page is intended to help guide would be api develops on how to create an api endpoint.
Bug 15165 is a good template for how to add an api endpoint Koha.
Step 1: Find or create your Koha::Object(s) for the tables you will be using.
If Koha already has an OO class set for the table or tables you will be working with, great! Otherwise you can find the Koha::Object(s) guide here.
Step 2: Create your REST API module
Each endpoint has a Perl module that is connected to it. These modules live in Koha/REST/V1
Step 3: Create your object definition
Each table row needs a definition for the api, so it understands what it is. These definition files are written in JSON. The definition files live in api/v1/swagger/definitions. For example, for holds there are two definition files, one representing a single hold, and a second one representing a list of holds.
Step 4: Add your object definition to the the definitions file
Add your new definition file to the list of definitions in the file api/v1/swagger/definitions.json
Step 5: Create your path file
This file describes the various paths related to this endpoint. For example, you may have /object for listing all "objects" and /object/<id> for getting the data for the object with the id "<id>".
Step 6: Add your path file to the paths file
You will need to add your new path file to the paths file in a manner similar to how you needed to add your definition file to the definitions file. The path file is found at api/v1/swagger/paths.json