Elasticsearch provides a RESTful Web API, which allows you to perform operations including addition, deletion, modification, search, and alias configuration.

For more information about the official Elasticsearch REST API, see Elasticsearch Restful API.

Elasticsearch Reference [5.5]

Single document APIs

Multi-document APIs

Use REST clients to communicate with clusters

You can use REST clients to access Elasticsearch clusters through HTTP or TCP. We recommend that you use the Elasticsearch official Java REST Client.

Use Java APIs to communicate with clusters

Elasticsearch provides a default client for Java users. For more information, see Java API.

Transport client

A transport client forwards requests to nodes in a cluster. However, it is not a part of a cluster.

A transport client uses the Elasticsearch Transport Protocol to communicate with clusters over port 9300.

Nodes in a cluster also use port 9300 to communicate with each other. You must open port 9300 for your nodes before grouping them into a cluster.

Note Your Java clients and nodes must use the same Elasticsearch version for them to recognize each other.


All other languages can communicate with Elasticsearch over port 9200 using a RESTful API, with your favorite web client. You can use the curl command to communicate with Elasticsearch at the CLI.


Elasticsearch provides official clients for several languages, including Groovy, Javascript, .NET, PHP, Perl, Python, andRuby.

For more clients and plug-ins provided by communities, see Document.

Structure of a curl request over HTTP


  • VERB: an HTTP method: GET, POST, PUT, HEAD, and DELETE.
  • PROTOCOL: http or https. Use https only if HTTPS is enabled for Elasticsearch.
  • HOST: the hostname of any node in your Elasticsearch cluster or localhost for a local node.
  • PORT: the port that runs the Elasticsearch HTTP service. The default port number is 9200.
  • PATH: API endpoint, for example, _count returns the number of documents in a cluster. PATH may contain multiple components, such as _cluster/stats and _nodes/stats/jvm.
  • QUERY_STRING: optional query parameters. For example, the ?pretty parameter makes the JSON response much easier to read.
  • BODY: JSON-encoded request body (only if the request requires one).


Count the number of documents in an Elasticsearch cluster:
curl -XGET 'http://localhost:9200/_count?pretty' -d '
  "query": { 
    "match_all": {} 

The body of the response to the curl request:

    "count" : 0, 
    "_shards" : { 
        "total" : 5, 
        "successful" : 5, 
        "failed" : 0 

Use the curl -i command to display the HTTP header:

curl -i -XGET 'localhost:9200/'

Full request:

Curl-XGET 'localhost: 9200/_ count? pretty '-d'
    "query": { 
        "match_all": {} 

Shorthand for the request:

GET /_count
    "query": { 
        "match_all": {}