Endpoints are an essential part of business processes and application development in general. In this article, we define what endpoints are, why we need them and how to create them on the AppMaster.io platform.
What is an endpoint?
An endpoint is a gateway that connects the application’s server processes with an external interface. In other words, this is the address to which requests are sent.
It is important to mention how the API works to understand what endpoints are. API is an abbreviation for an application programming interface. Applications use APIs to interact with third-party services and their users.
To connect to the API, you need to send a request. For correct processing of the request, the client must provide a universal resource pointer (URL), an HTTP method, and, depending on the method, add headers, body, and request parameters. The headers provide metadata about the request, while the body contains data, such as fields for new rows in the database.
The API will process the request and send the response received from the server. The response will contain a status code, which is a part of the HTTP response message informing the client of the request result. For example, code 200 is used if the operation was completed successfully, 500 if an internal server error occurred.
Endpoints work together with API methods. These are specific URLs that the application uses to communicate with third-party services and its users. A URL is a route that can handle different request methods. Each request type is a separate endpoint. There are five main types:
- GET — gets information from the server; it doesn’t require a request body;
- POST — creates a new object in the database, requires a request body with the fields of this object;
- PUT — completely resets a specific object in the database;
- PATCH — similar to PUT, resets a specific object in the database, but it will only update the fields that are mentioned in the request body;
- DELETE — deletes the object from the database.
When creating a specific request, various parameters can be added to it. The combination of these parameters and the URL represents a URI — Uniform Resource Identifier. It indicates where and how to find the resource.
How can you configure endpoints on the AppMaster.io platform?
In the Endpoints section of the AppMaster.io platform, you can see all the automatically generated endpoints and your project’s endpoints. If the screens and pages auto-generation in your project is enabled, there will be automatically created the corresponding endpoints for any created data model. Also, endpoints can be created automatically when installing some modules, for example, Authorization (Auth), Countries and cities, and others.
AppMaster.io allows you to work with several types of endpoint APIs:
- API for accessing the backend from the client and third-party systems;
- webhooks for receiving notifications from third-party systems;
- WebSockets, for opening a two-way interactive communication session between a browser and a server without asking the server for a response.
All endpoints are grouped. Within each group, you’ll find all corresponding endpoints, their request types, URLs, and the business processes they’re connected to. All endpoints can be deleted and edited by you.
When creating or editing an endpoint, the following options are available in the configuration window:
- Request method. GET, POST, PUT, DELETE, or PATCH.
- Request URL. The first part with the path to the server is not specified since it is the same for all application endpoints. It is enough to set the end, for example, /users. The URL parameter is also specified here. Suppose the endpoint is designed to receive information about a specific user. In that case, its ID must be written after “:” (/users/:id) and passed as a parameter.
- Endpoint groups. This parameter aims to organize and structure the work with endpoints. All endpoints can be divided into groups (folders).
- Business process. One of the most critical parameters that determine what the endpoint will do. At the same time, the endpoint itself can remain unchanged. It will receive all the same requests at the old address, and if the business process is replaced, it will perform a different function. Business processes for basic database operations are created automatically. You cannot edit them, but if necessary, you can replace them with custom BPs.
Also, you can set up middleware. Middleware is intermediary software that serves as a filter when processing application requests. Middleware is used to check any conditions before executing a request. For example, if you create middleware to check user authentication, the middleware will redirect the user to the login page if the user is not logged in. If he is logged in, the middleware will not interfere with the request processing, passing it on to the client.
Creating an endpoint in AppMaster.io
Let’s consider the configuration of endpoints in practice and analyze it through the example of the Aviato project. You can find the complete process of creating this project on the AppMaster.io course.
Within the project, we created two business processes:
- Validate and create flights — the process that will be used to replace the Create flight business process;
- Register passenger — for registering a passenger for a specific flight.
Now we can use these processes to set up endpoints in the project.
Let’s start with the Validate and create flights business process. The Flight group already has a POST/flights endpoint for creating a flight. Now we need to replace the business process attached with a new one. To do this, we need to Edit the endpoint.
In the configuration window, select the desired business process. In our case, this is a Validate and create flights BP. After that, we need to select all the input variables required and save the changes.
Now we can set up the next endpoint for the Register passenger business process.
Our goal is to create a section to view a specific flight and passengers associated with it and set up a process for registering new passengers.
In the Flights endpoint group, we need to create a new endpoint: /flights/:id/register, where id refers to a specific flight that we can use as input in a business process.
By clicking on the Plus icon, we can add a new endpoint. The request method will be POST since we are creating a new object. We select the Register passenger process for our BP and save all the changes made.
That is how easy it is to create endpoints on the AppMaster.io platform. To dive deeper in endpoints, watch the full video tutorial.
Endpoints play a vital role in the operation of the API, which, in turn, is necessary for expanding projects and convenient integration of services and applications. No-code platform AppMaster.io makes it easy to work with endpoints create and configure them. You can always register on the platform and check out all the functionality.