An API, or application programming interface, is a set of rules that defines how applications or devices connect and communicate with each other. A REST API adheres to the design principles of the REST (representational state transfer) architectural style. For this reason, REST APIs are often referred to as RESTful APIs.
A REST API enables developers to interact with Roxy-WI by starting, stopping, and restarting services, as well as adding, editing, and deleting ACLs. It communicates using JSON requests and responses. Request headers and parameters are crucial in REST API calls, as they contain important identifier information such as metadata, authorizations, uniform resource identifiers (URIs), caching, cookies, and more. Both request and response headers, along with standard HTTP status codes, are utilized in well-designed REST APIs.
To get a list of all available endpoints, run the following command:
The command output will look something like this:
To use the API, you need an authorization token. Make the following request to get a token:
You will get a new token:
To stop the HAProxy service, make the following request:
You should get the following response:
To add an ACL to a section, make the following request:
The if parameter can take the following values:
- host_starts
- host_ends
- path_starts
- path_ends
- path_ends
- src_ip
The then parameter can take the following values:
- use_backend
- redirect
- allow
- deny
- return
- set-header
The action parameter can take the following values:
- save
- test
- restart
- reload
To delete an ACL from a section, make the following request:
The if parameter can take the following values:
- host_starts
- host_ends
- path_starts
- path_ends
- path_ends
- src_ip
The then parameter can take the following values:
- use_backend
- redirect
- allow
- deny
- return
- set-header
The action parameter can take the following values:
- save
- test
- restart
- reload