Access the API from the command lineedit

You can interact with the full RESTful API for Elasticsearch Service directly from the command line through the curl command. To authenticate, you just need to include your API key in the request header.

For convenience, you can export your API key into your shell environment:

export EC_API_KEY="YOUR_GENERATED_API_KEY"

This example curl command retrieves a list of your Elasticsearch Service deployments:

curl -H "Authorization: ApiKey $EC_API_KEY" https://api.elastic-cloud.com/api/v1/deployments

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