2013-05-24 17:23:25 +08:00
# Elasticsearch REST API JSON specification
2015-03-25 00:03:35 +08:00
This repository contains a collection of JSON files which describe the [Elasticsearch ](http://elastic.co ) HTTP API.
2013-05-24 17:23:25 +08:00
Their purpose is to formalize and standardize the API, to facilitate development of libraries and integrations.
2015-03-25 00:03:35 +08:00
Example for the ["Create Index" ](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html ) API:
2013-05-24 17:23:25 +08:00
```json
2013-05-28 16:55:24 +08:00
{
"indices.create": {
2019-08-15 23:15:30 +08:00
"documentation":{
"url":"http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html"
},
2019-06-13 02:54:51 +08:00
"stability": "stable",
2019-08-15 23:15:30 +08:00
"url":{
"paths":[
{
"path":"/{index}",
"method":"PUT",
"parts":{
"index":{
"type":"string",
"description":"The name of the index"
}
}
2013-05-24 17:23:25 +08:00
}
2019-08-15 23:15:30 +08:00
]
},
"params": {
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
2013-05-24 17:23:25 +08:00
}
2013-05-28 16:55:24 +08:00
},
"body": {
"description" : "The configuration for the index (`settings` and `mappings` )"
2013-05-24 17:23:25 +08:00
}
2013-05-28 16:55:24 +08:00
}
}
2013-05-24 17:23:25 +08:00
```
The specification contains:
* The _name_ of the API (`indices.create`), which usually corresponds to the client calls
2019-08-15 23:15:30 +08:00
* Link to the documentation at the < http: // elastic . co > website
2019-06-13 02:54:51 +08:00
* `stability` indicating the state of the API, has to be declared explicitly or YAML tests will fail
2019-08-15 23:15:30 +08:00
* `experimental` highly likely to break in the near future (minor/path), no bwc guarantees.
2019-06-13 02:54:51 +08:00
Possibly removed in the future.
* `beta` less likely to break or be removed but still reserve the right to do so
2019-08-15 23:15:30 +08:00
* `stable` No backwards breaking changes in a minor
* Request URL: HTTP method, path and parts
* Request parameters
* Request body specification
2013-05-24 17:23:25 +08:00
2019-08-15 23:15:30 +08:00
**NOTE**
2019-06-13 02:54:51 +08:00
If an API is stable but it response should be treated as an arbitrary map of key values please notate this as followed
```json
{
"api.name": {
"stability" : "stable",
"response": {
"treat_json_as_key_value" : true
}
}
}
```
2019-12-12 20:56:16 +08:00
## Type definition
In the documentation, you will find the `type` field, which documents which type every parameter will accept.
#### Querystring parameters
| Type | Description |
|---|---|
| `list` | An array of strings *(represented as a comma separated list in the querystring)* |
| `date` | A string representing a date formatted in ISO8601 or a number representing milliseconds since the epoch *(used only in ML)* |
| `time` | A numeric or string value representing duration |
| `string` | A string value |
| `enum` | A set of named constants *(a single value should be sent in the querystring)* |
| `int` | A signed 32-bit integer with a minimum value of -2< sup > 31</ sup > and a maximum value of 2< sup > 31</ sup > -1. |
| `double` | A [double-precision 64-bit IEEE 754 ](https://en.wikipedia.org/wiki/Floating-point_arithmetic ) floating point number, restricted to finite values. |
| `long` | A signed 64-bit integer with a minimum value of -2< sup > 63</ sup > and a maximum value of 2< sup > 63</ sup > -1. *(Note: the max safe integer for JSON is 2<sup>53</sup>-1)* |
| `number` | Alias for `double` . *(deprecated, a more specific type should be used)* |
| `boolean` | Boolean fields accept JSON true and false values |
2019-08-15 23:15:30 +08:00
## Backwards compatibility
2019-06-13 02:54:51 +08:00
2019-08-15 23:15:30 +08:00
The specification follows the same backward compatibility guarantees as Elasticsearch.
2019-06-11 17:38:33 +08:00
2019-08-15 23:15:30 +08:00
- Within a Major, additions only.
- If an item has been documented wrong it should be deprecated instead as removing these might break downstream clients.
2019-06-11 17:38:33 +08:00
- Major version change, may deprecate pieces or simply remove them given enough deprecation time.
## Deprecations
2019-08-15 23:15:30 +08:00
The specification schema allows to codify API deprecations, either for an entire API, or for specific parts of the API, such as paths or parameters.
2019-06-11 17:38:33 +08:00
#### Entire API:
```json
{
"api" : {
"deprecated" : {
"version" : "7.0.0",
"description" : "Reason API is being deprecated"
},
}
}
```
2019-08-15 23:15:30 +08:00
#### Specific paths and their parts:
2019-06-11 17:38:33 +08:00
```json
{
"api": {
"url": {
2019-08-15 23:15:30 +08:00
"paths": [
2019-06-11 17:38:33 +08:00
{
2019-08-15 23:15:30 +08:00
"path":"/{index}/{type}/{id}/_create",
"method":"PUT",
"parts":{
"id":{
"type":"string",
"description":"Document ID"
},
"index":{
"type":"string",
"description":"The name of the index"
},
"type":{
"type":"string",
"description":"The type of the document",
"deprecated":true
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
2019-06-11 17:38:33 +08:00
}
]
}
}
}
```
2019-08-15 23:15:30 +08:00
#### Parameters
2019-06-11 17:38:33 +08:00
```json
{
"api": {
"url": {
"params": {
"stored_fields": {
"type": "list",
"description" : "",
"deprecated" : {
"version" : "7.0.0",
"description" : "Reason parameter is being deprecated"
}
}
}
}
}
}
```
2013-05-24 17:23:25 +08:00
## License
2014-11-08 12:57:13 +08:00
This software is licensed under the Apache License, version 2 ("ALv2").