An API, or application programming interface, is a set of rules that define how applications or devices can connect to and communicate with each other. A REST API is an API that conforms to the design principles of the REST, or representational state transfer architectural style. For this reason, REST APIs are sometimes referred to RESTful APIs.
A REST API allows developers to work with Roxy-WI: to start, stop and restart the services, to add, to edit and to delete ACLs, etc. It communicates via JSON requests and JSON responses. Request headers and parameters are also important in REST API calls because they include important identifier information such as metadata, authorizations, uniform resource identifiers (URIs), caching, cookies and more. Request headers and response headers, along with conventional HTTP status codes, are used within well-designed REST APIs.
To get the list of all available endpoints, perform the following command:
The command output will be similar to:
You need an authorization token to use the API. Make the following request to get a token:
You will get a new token:
Make the following request to stop the HAProxy service:
You should get the following response:
Make the following request to add an ACL to a section:
The if parameter may take the following values:
- host_starts
- host_ends
- path_starts
- path_ends
- path_ends
- src_ip
The then parameter may take the following values:
- use_backend
- redirect
- allow
- deny
- return
- set-header
The action parameter may take the following values:
- save
- test
- restart
- reload
Make the following request to delete an ACL from a section:
The if parameter may take the following values:
- host_starts
- host_ends
- path_starts
- path_ends
- path_ends
- src_ip
The then parameter may take the following values:
- use_backend
- redirect
- allow
- deny
- return
- set-header
The action parameter may take the following values:
- save
- test
- restart
- reload