Access the API from the Command Lineedit

The simplest way to interact with the full RESTful API for ECE is from the command line through the curl command. In order to interact with the API, you first need to acquire a bearer token. You do this by sending your credentials to the login endpoint.

Endpoint URLs look like this example:

curl -k -X POST -H 'Content-Type: application/json' https://COORDINATOR_HOST:12443/api/v1/users/auth/_login --data-binary '
  "username": "USER",
  "password": "PASSWORD"

Using HTTPS requires that you have a TLS certificate already installed. For testing purposes only, you can specify the -k option to turn off certificate verification, as shown in our examples, or use HTTP over port 12400 until you get your TLS certificate sorted out.

If your credentials are valid, the response from the login API will contain a JSON Web Token (JWT):

{ "token": "eyJ0eXa...<very long string>...MgBmsw4s" }" }

You then need to include this token in an HTTP "Authentication" header when making API requests:

curl -k -X GET -H "Authorization: Bearer TOKEN" https://COORDINATOR_HOST:12443/api/v1/clusters/elasticsearch
A token for a user with sufficient privileges, such as the admin user as returned in the response above.

Tokens have a short life span, so you should not save them for the long term, and should expect to handle HTTP responses that indicate that you need to reauthenticate e.g. 401.

If this is your first time exploring the API, you can take a look at our API examples to learn more.