Use the InfluxDB API endpoints to run queries, write data, check server status, and troubleshoot by tracking HTTP client requests, collecting server statistics, and using Go "pprof" profiles.
| [/api/v2/query](#apiv2query-http-endpoint) | Query data in InfluxDB 1.8.0+ using the InfluxDB 2.x API and [Flux](/flux/latest/) |
| [/api/v2/write](#apiv2write-http-endpoint) | Write data to InfluxDB 1.8.0+ using the InfluxDB 2.x API _(compatible with InfluxDB 2.x client libraries)_ |
Use this endpoint to query data using [Flux](/enterprise_influxdb/v1/flux/) and [InfluxDB 2.x client libraries](/influxdb/v2.x/api-guide/client-libraries/).
The `/health` endpoint accepts `Get` HTTP requests.
Use this endpoint to check the health of your InfluxDB instance.
```bash
curl -XGET "localhost:8086/health"
```
##### /health endpoint responses
| Response code | Health | Message | Status |
|:------------- |:------ |:------- | ------:|
| 200 | Healthy | `ready for queries and writes` | `pass` |
| 503 | Unhealthy | | `fail` |
---
### `/api/v2/buckets/` HTTP endpoint
The [/api/v2/buckets](/influxdb/latest/api/#tag/Buckets) endpoint accepts `GET`, `POST` and `DELETE` HTTP requests. Use this endpoint to [create](/influxdb/latest/api/#operation/PostBuckets), [delete](/influxdb/latest/api/#operation/DeleteBucketsID), [list](/influxdb/latest/api/#operation/GetBuckets), [update](/influxdb/latest/api/#operation/PatchBucketsID) and [retrieve](/influxdb/latest/api/#operation/GetBucketsID) buckets in your InfluxDB instance. Note that InfluxDB 2.x uses organizations and buckets instead of databases and retention policies.
**Include the following URL parameters:**
-`bucket`: Provide the database name and retention policy separated by a forward slash (`/`).
For example: `database/retention-policy`.
Empty retention policies map to the default retention policy.
-`org`: In InfluxDB 1.x, there is no concept of organization. The `org` parameter is ignored and can be left empty.
The [`/api/v2/delete`](/influxdb/latest/api/#tag/Delete) endpoint accepts `POST` HTTP requests. Use this endpoint to delete points from InfluxDB, including points with specific tag values, timestamps and measurements.
**Include the following URL parameters:**
-`bucket`: Provide the database name and retention policy separated by a forward slash (`/`).
For example: `database/retention-policy`.
-`precision`: Precision of timestamps in the line protocol.
Accepts `ns` (nanoseconds), `us`(microseconds), `ms` (milliseconds) and `s` (seconds).
If you use the `predicate` option in your request, review [delete predicate syntax](/influxdb/v2/reference/syntax/delete-predicate/) and note its [limitations](/influxdb/v2/reference/syntax/delete-predicate/#limitations).
| [/shard-status](#shard-status-http-endpoint) | Get information about a data node's shards |
### `/debug/pprof` HTTP endpoint
InfluxDB supports the Go [`net/http/pprof`](https://golang.org/pkg/net/http/pprof/) HTTP endpoints, which are useful for troubleshooting. The `pprof` package serves runtime profiling data in the format expected by the _pprof_ visualization tool.
#### Definition
```
curl http://localhost:8086/debug/pprof/
```
The `/debug/pprof/` endpoint generates an HTML page with a list of built-in Go profiles and hyperlinks for each.
| Profile | Description
| :---------------- | :-------------------- |
| block | Stack traces that led to blocking on synchronization primitives. |
| goroutine | Stack traces of all current goroutines. |
| heap | Sampling of stack traces for heap allocations. |
| mutex | Stack traces of holders of contended mutexes. |
| threadcreate | Stack traces that led to the creation of new OS threads. |
To access one of the `/debug/pprof/` profiles listed above, use the following cURL request, substituting `<profile>` with the name of the profile. The resulting profile is output to a file specified in `<path/to/output-file>`.
| seconds=\<integer\> | Optional | Sets the duration (in seconds) over which the client collects information. The default duration is ten seconds. |
#### Examples
##### Track requests over a ten-second interval
```bash
$ curl http://localhost:8086/debug/requests
{
"user1:123.45.678.91": {"writes":1,"queries":0},
}
```
The response shows that, over the past ten seconds, the `user1` user sent one request to the `/write` endpoint and no requests to the `/query` endpoint from the `123.45.678.91` IP address.
The response shows that, over the past minute, `user1` sent three requests to the `/write` endpoint from `123.45.678.91`, `user1` sent 16 requests to the `/query` endpoint from `000.0.0.0`, and `user2` sent four requests to the `/write` endpoint from `xx.xx.xxx.xxx`.
### `/debug/vars` HTTP endpoint
InfluxDB exposes statistics and information about its runtime through the `/debug/vars` endpoint, which can be accessed using the following cURL command:
```bash
curl http://localhost:8086/debug/vars
```
Server statistics and information are displayed in JSON format.
For information about InfluxDB HTTP server metrics, see the [`httpd` measurement](/platform/monitoring/influxdata-platform/tools/measurements-internal/#httpd).
>**Note:** The [InfluxDB input plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/influxdb) is available to collect metrics (using the `/debug/vars` endpoint) from specified Kapacitor instances. For a list of the measurements and fields, see the [InfluxDB input plugin README](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/influxdb#readme).
### `/ping` HTTP endpoint
The ping endpoint accepts both `GET` and `HEAD` HTTP requests.
Use this endpoint to check the status of your InfluxDB instance and your version
Default value is `false`. By default, the `/ping` HTTP endpoint responds with HTTP status `204` and an empty response body to let the client know that the server is running.
If set to `true` (`/ping?verbose=true`), the server responds with HTTP status `200` status and a response body that contains details.
The `verbose=true` option is required for [Google Cloud Load Balancing](https://cloud.google.com/load-balancing/docs/health-check-concepts) health checks.
#### Example
You can use the `/ping` endpoint to find the build and version of an InfluxDB instance.
The `X-Influxdb-Build` header field displays the InfluxDB build type, either `OSS` (open source) or `ENT` (Enterprise).
The `X-Influxdb-Version` header field displays the InfluxDB version.
| GET | Use for all queries that start with: <br><br> [`SELECT`](/enterprise_influxdb/v1/query_language/spec/#select)* <br><br> [`SHOW`](/enterprise_influxdb/v1/query_language/spec/#show-continuous-queries) |
| POST | Use for all queries that start with: <br><br> [`ALTER`](/enterprise_influxdb/v1/query_language/spec/#alter-retention-policy) <br><br> [`CREATE`](/enterprise_influxdb/v1/query_language/spec/#create-continuous-query) <br><br> [`DELETE`](/enterprise_influxdb/v1/query_language/spec/#delete) <br><br> [`DROP`](/enterprise_influxdb/v1/query_language/spec/#drop-continuous-query) <br><br> [`GRANT`](/enterprise_influxdb/v1/query_language/spec/#grant) <br><br> [`KILL`](/enterprise_influxdb/v1/query_language/spec/#kill-query) <br><br> [`REVOKE`](/enterprise_influxdb/v1/query_language/spec/#revoke) |
The `mymeas` [measurement](/enterprise_influxdb/v1/concepts/glossary/#measurement) has two points.
The first point has the [timestamp](/enterprise_influxdb/v1/concepts/glossary/#timestamp) `2017-03-01T00:16:18Z`, a `myfield` value of `33.1`, and no tag values for the `mytag1` and `mytag2` [tag keys](/enterprise_influxdb/v1/concepts/glossary/#tag-key).
The response shows that InfluxDB writes two points to the `newmeas` [measurement](/enterprise_influxdb/v1/concepts/glossary/#measurement).
Note that the system uses epoch 0 (`1970-01-01T00:00:00Z`) as a [null timestamp equivalent](/enterprise_influxdb/v1/troubleshooting/frequently-asked-questions/#why-does-my-query-return-epoch-0-as-the-timestamp).
| chunked=[true \| \<number_of_points>] | Optional | Returns points in streamed batches instead of in a single response. If set to `true`, InfluxDB chunks responses by series or by every 10,000 points, whichever occurs first. If set to a specific value, InfluxDB chunks responses by series or by that number of points.* |
| db=\<database_name> | Required for database-dependent queries (most [`SELECT`](/enterprise_influxdb/v1/query_language/spec/#select) queries and [`SHOW`](/enterprise_influxdb/v1/query_language/spec/#show-continuous-queries) queries require this parameter). | Sets the target [database](/enterprise_influxdb/v1/concepts/glossary/#database) for the query. |
| epoch=[ns,u,µ,ms,s,m,h] | Optional | Returns epoch timestamps with the specified precision. By default, InfluxDB returns timestamps in RFC3339 format with nanosecond precision. Both `u` and `µ` indicate microseconds. |
| p=\<password> | Optional if you haven't [enabled authentication](/enterprise_influxdb/v1/administration/authentication_and_authorization/#set-up-authentication). Required if you've enabled authentication.** | Sets the password for authentication if you've enabled authentication. Use with the query string parameter `u`. |
| pretty=true | Optional | Enables pretty-printed JSON output. While this is useful for debugging it is not recommended for production use as it consumes unnecessary network bandwidth. |
| q=\<query> | Required | InfluxQL string to execute. See also [Request Body](/enterprise_influxdb/v1/tools/api/#request-body). |
| u=\<username> | Optional if you haven't [enabled authentication](/enterprise_influxdb/v1/administration/authentication_and_authorization/#set-up-authentication). Required if you've enabled authentication.* | Sets the username for authentication if you've enabled authentication. The user must have read access to the database. Use with the query string parameter `p`. |
Use basic authentication if you've [enabled authentication](/enterprise_influxdb/v1/administration/authentication_and_authorization/#set-up-authentication)
The first point has no [tag values](/enterprise_influxdb/v1/concepts/glossary/#tag-value) for the `mytag1` and `mytag2` [tag keys](/enterprise_influxdb/v1/concepts/glossary/#tag-key).
The value `30` does not require double quotes because `myfield` stores numerical [field values](/enterprise_influxdb/v1/concepts/glossary/#field-value).
| 200 OK | Success. Response body contains data in JSON format. |
| 400 Bad Request | Unacceptable request. Can occur with a syntactically incorrect query. Response body contains an error message with additional information in JSON format. |
| consistency=[any,one,quorum,all] | Optional, available with [InfluxDB Enterprise clusters](/enterprise_influxdb/v1/) only. | Sets the write consistency for the point. InfluxDB assumes that the write consistency is `one` if you do not specify `consistency`. See the [InfluxDB Enterprise documentation](/enterprise_influxdb/v1/concepts/clustering#write-consistency) for detailed descriptions of each consistency option. |
| db=\<database> | Required | Sets the target [database](/enterprise_influxdb/v1/concepts/glossary/#database) for the write. |
| p=\<password> | Optional if you haven't [enabled authentication](/enterprise_influxdb/v1/administration/authentication_and_authorization/#set-up-authentication). Required if you've enabled authentication.* | Sets the password for authentication if you've enabled authentication. Use with the query string parameter `u`. |
| precision=[ns,u,ms,s,m,h] | Optional | Sets the precision for the supplied Unix time values. InfluxDB assumes that timestamps are in nanoseconds if you do not specify `precision`.** |
| rp=\<retention_policy_name> | Optional | Sets the target [retention policy](/enterprise_influxdb/v1/concepts/glossary/#retention-policy-rp) for the write. InfluxDB writes to the `DEFAULT` retention policy if you do not specify a retention policy. |
| u=\<username> | Optional if you haven't [enabled authentication](/enterprise_influxdb/v1/administration/authentication_and_authorization/#set-up-authentication). Required if you've enabled authentication.* | Sets the username for authentication if you've enabled authentication. The user must have write access to the database. Use with the query string parameter `p`. |
Use basic authentication if you've [enabled authentication](/enterprise_influxdb/v1/administration/authentication_and_authorization/#set-up-authentication)
| 400 Bad Request | Unacceptable request. Can occur with an InfluxDB line protocol syntax error or if a user attempts to write values to a field that previously accepted a different value type. The returned JSON offers further information. |
| 401 Unauthorized | Unacceptable request. Can occur with invalid authentication credentials. |
| 404 Not Found | Unacceptable request. Can occur if a user attempts to write to a database that does not exist. The returned JSON offers further information. |
| 413 Request Entity Too Large | Unaccetable request. It will occur if the payload of the POST request is bigger than the maximum size allowed. See [`max-body-size`](/enterprise_influxdb/v1/administration/configure/config-data-nodes/#max-body-size) parameter for more details.
| 500 Internal Server Error | The system is overloaded or significantly impaired. Can occur if a user attempts to write to a retention policy that does not exist. The returned JSON offers further information. |
#### Examples
##### A successful write
```
HTTP/1.1 204 No Content
```
##### Write a point with an incorrect timestamp
```
HTTP/1.1 400 Bad Request
[...]
{"error":"unable to parse 'mymeas,mytag=1 myfield=91 abc123': bad timestamp"}
```
##### Write an integer to a field that previously accepted a float
```
HTTP/1.1 400 Bad Request
[...]
{"error":"field type conflict: input field \"myfield\" on measurement \"mymeas\" is type int64, already exists as type float"}
```
##### Write a point with invalid authentication credentials
```
HTTP/1.1 401 Unauthorized
[...]
{"error":"authorization failed"}
```
##### Write a point to a database that doesn't exist
```
HTTP/1.1 404 Not Found
[...]
{"error":"database not found: \"mydb1\""}
```
##### Send a request body that is too large
```
HTTP/2 413 Request Entity Too Large
[...]
{"error":"Request Entity Too Large"}
```
##### Write a point to a retention policy that doesn't exist
```
HTTP/1.1 500 Internal Server Error
[...]
{"error":"retention policy not found: myrp"}
```
### `/shard-status` HTTP endpoint
The `/shard-status` endpoint accepts HTTP `GET` requests.
Use this endpoint to get information about all shards for a given data node.
#### Response
Requests to `/shard-status` return the following information in JSON format:
-`id`: the shard ID
-`size`: the size on disk of the shard in bytes
-`is_hot`: whether the time range from the shard includes `now`
{{% note %}}
An *idle* shard is fully compacted and not receiving new (potentially historical) writes.
A hot shard may or may not be idle.
{{% /note %}}
-`state`: the anti-entropy status of the shard can be one of the following: