Kuroco allows the creation of custom endpoints.
In this tutorial, we will find out what endpoints are and how to create them.
What is an endpoint
An endpoint is a URL that exposes a feature within Kuroco publicly.
For example, to display a list of news on a website, the website needs to get the news list from Kuroco.
To achieve that, Kuroco must prepare a URL that says, "If this URL is accessed, the list of articles will be returned as a result." That URL is an endpoint.
Difference between API and endpoint
Endpoints are often referred to as API.
API is an acronym for "Application Programming Interface" and refers to an interface that provides functions externally.
Kuroco defines the word "API" as a concept that represents the grouping of related endpoints.
How to group APIs
In Kuroco, each API will have its own security settings and CORS settings.
Therefore, it is recommended to group APIs according to the following criteria.
- Called by the same external system
- Called by multiple external systems with similar authentication methods
How to create an endpoint
Now let's actually create an endpoint.
Assuming that the news topic group has already been created, set the endpoint to get the news list.
- Group ID: 1
- Group name: Notice
2. Specify the Path - URI
Set the path as "news". Set to "Enabled".
In Kuroco, the path is always prefixed with /rcms-api/X/.
X is an integer that refers to the API ID. Fill in the rest of the path text after the prefix.
3. Specify the content and operation to be processed
Next, specify the content. Under Model, select:
- Category: Content
- Model: news, v1
- Operation: list
4. Setting up the Parameters
There are many settings for an endpoint. In this exercise, the following 2 parameters will be set.
The "news_group_id" parameter refers to the topic group ID. Enter "1" here, which is the topic group ID of "news".
The "cnt" parameter determines the number of articles displayed per page. Enter "10" here to display up to 10 articles per page.
Checking the configured endpoint
This concludes the endpoint configuration.