<commit_before>---
title: InfluxDB HTTP API reference
description: Use the InfluxDB HTTP 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.
aliases:
    - influxdb/v1.6/concepts/api/
menu:
  influxdb_1_6:
    name: InfluxDB HTTP API reference
    weight: 20
    parent: Tools
---

The InfluxDB HTTP API provides a simple way interact with the database.
It uses HTTP response codes, HTTP authentication, JWT Tokens, and basic authentication, and responses are returned in JSON.

The following sections assume your InfluxDB instance is running on `localhost`
port `8086` and HTTPS is not enabled.
Those settings [are configurable](/influxdb/v1.6/administration/config/#http-endpoint-settings-http).

# InfluxDB HTTP endpoints

| Endpoint    | Description |
| :---------- | :---------- |
| [/debug/pprof ](#debug-pprof-http-endpoint)   | Use `/debug/pprof` to generate profiles for troubleshooting.  |   
| [/debug/requests](#debug-requests-http-endpoint) | Use `/debug/requests/` to track HTTP client requests to the `/write` and `/query` endpoints. | [/debug/vars](#debug-vars)  | Use `/debug/vars` to collect statistics  |
| [/ping](#ping) | Use `/ping` to check the status of your InfluxDB instance and your version of InfluxDB. |
| [/query](#query) | Use `/query` to query data and manage databases, retention policies, and users. |
| [/write](#write) | Use `/write` to write data to a pre-existing database. |

### `/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 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>`.

```
curl -o <path/to/output-file>  http://localhost:8086/debug/pprof/<profile>
```

In the following example, the cURL command outputs the resulting heap profile to a file:

```
curl -o <path/to/output-file> http://localhost:/8086/debug/pprof/heap
```

You can also use the [Go `pprof` interactive tool](https://github.com/google/pprof) to access the InfluxDB `/debug/pprof/` profiles.
For example, to look at the heap profile of a InfluxDB instance using this tool, you would use a command like this:

```
go tool pprof http://localhost:8086/debug/pprof/heap
```

For more information about the Go `/net/http/pprof` package and the interactive _pprof_ analysis and visualization tool, see:

* [Package pprof (`net/http/pprof`)](https://golang.org/pkg/net/http/pprof/)
* [`pprof` analysis and visualization tool](https://github.com/google/pprof)
* [Profiling Go programs](https://blog.golang.org/profiling-go-programs)
* [Diagnostics - Profiling](https://golang.org/doc/diagnostics.html#profiling)

#### `/debug/pprof/all` HTTP endpoint

The `/debug/pprof/all` endpoint is a custom `/debug/pprof` profile intended primarily for use by InfluxData support. This endpoint generates a `profile.tar.gz` archive containing text files with the standard Go profiling information and additional debugging data. An optional CPU profile is generated when using the `cpu=true` option (default is `false`).

To create a `profile.tar.gz` archive, use the following cURL command to generate a `profile.tar.gz` file for sharing with InfluxData support.

```
curl -o profiles.tar.gz "http://localhost:8086/debug/pprof/all?cpu=true"
```

>**Note:** When the `cpu=true` option is included, a CPU profile is generated for 30+ seconds.
> If you're concerned about running a CPU profile (which only has a small, temporary impact on performance), then you can set `?cpu=false` or omit `?cpu=true` altogether.

As the following example shows, the cURL output includes "Time Spent," the time elapsed (in  seconds). After 30 seconds of data has been collected, the results are output to a file.

```
➜  ~ curl -o profiles.tar.gz "http://localhost:8086/debug/pprof/all?cpu=true"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  237k    0  237k    0     0   8025      0 --:--:--  0:00:30 --:--:-- 79588
```

## `/debug/requests` HTTP endpoint

Use this endpoint to track HTTP client requests to the `/write` and `/query` endpoints.
The `/debug/requests` endpoint returns the number of writes and queries to InfluxDB per username and IP address.

### Definition

```
curl http://localhost:8086/debug/requests
```

### Query string parameters

| Query String Parameter | Optional/Required | Definition |
| :--------------------- | :---------------- |:---------- |
| 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

```
$ 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.

##### Track requests over a one-minute interval

```
$ curl http://localhost:8086/debug/requests?seconds=60

{
"user1:123.45.678.91": {"writes":3,"queries":0},
"user1:000.0.0.0": {"writes":0,"queries":16},
"user2:xx.xx.xxx.xxx": {"writes":4,"queries":0}
}
```

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:

```<commit_msg>fixed links in influxdb http api reference, updated formatting, fixes #1798<commit_after>---
title: InfluxDB HTTP API reference
description: Use the InfluxDB HTTP 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.
aliases:
    - influxdb/v1.6/concepts/api/
menu:
  influxdb_1_6:
    name: InfluxDB HTTP API reference
    weight: 20
    parent: Tools
---

The InfluxDB HTTP API provides a simple way interact with the database.
It uses HTTP response codes, HTTP authentication, JWT Tokens, and basic authentication, and responses are returned in JSON.

The following sections assume your InfluxDB instance is running on `localhost`
port `8086` and HTTPS is not enabled.
Those settings [are configurable](/influxdb/v1.6/administration/config/#http-endpoint-settings-http).

## InfluxDB HTTP endpoints

| Endpoint    | Description |
| :---------- | :---------- |
| [/debug/pprof ](#debug-pprof-http-endpoint)   | Use `/debug/pprof` to generate profiles for troubleshooting.  |   
| [/debug/requests](#debug-requests-http-endpoint) | Use `/debug/requests/` to track HTTP client requests to the `/write` and `/query` endpoints. |
| [/debug/vars](#debug-vars-http-endpoint)  | Use `/debug/vars` to collect statistics  |
| [/ping](#ping-http-endpoint) | Use `/ping` to check the status of your InfluxDB instance and your version of InfluxDB. |
| [/query](#query-http-endpoint) | Use `/query` to query data and manage databases, retention policies, and users. |
| [/write](#write-http-endpoint) | Use `/write` to write data to a pre-existing database. |

## `/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 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>`.

```
curl -o <path/to/output-file>  http://localhost:8086/debug/pprof/<profile>
```

In the following example, the cURL command outputs the resulting heap profile to a file:

```
curl -o <path/to/output-file> http://localhost:/8086/debug/pprof/heap
```

You can also use the [Go `pprof` interactive tool](https://github.com/google/pprof) to access the InfluxDB `/debug/pprof/` profiles.
For example, to look at the heap profile of a InfluxDB instance using this tool, you would use a command like this:

```
go tool pprof http://localhost:8086/debug/pprof/heap
```

For more information about the Go `/net/http/pprof` package and the interactive _pprof_ analysis and visualization tool, see:

* [Package pprof (`net/http/pprof`)](https://golang.org/pkg/net/http/pprof/)
* [`pprof` analysis and visualization tool](https://github.com/google/pprof)
* [Profiling Go programs](https://blog.golang.org/profiling-go-programs)
* [Diagnostics - Profiling](https://golang.org/doc/diagnostics.html#profiling)

#### `/debug/pprof/all` HTTP endpoint

The `/debug/pprof/all` endpoint is a custom `/debug/pprof` profile intended primarily for use by InfluxData support. This endpoint generates a `profile.tar.gz` archive containing text files with the standard Go profiling information and additional debugging data. An optional CPU profile is generated when using the `cpu=true` option (default is `false`).

To create a `profile.tar.gz` archive, use the following cURL command to generate a `profile.tar.gz` file for sharing with InfluxData support.

```
curl -o profiles.tar.gz "http://localhost:8086/debug/pprof/all?cpu=true"
```

>**Note:** When the `cpu=true` option is included, a CPU profile is generated for 30+ seconds.
> If you're concerned about running a CPU profile (which only has a small, temporary impact on performance), then you can set `?cpu=false` or omit `?cpu=true` altogether.

As the following example shows, the cURL output includes "Time Spent," the time elapsed (in  seconds). After 30 seconds of data has been collected, the results are output to a file.

```
➜  ~ curl -o profiles.tar.gz "http://localhost:8086/debug/pprof/all?cpu=true"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  237k    0  237k    0     0   8025      0 --:--:--  0:00:30 --:--:-- 79588
```

## `/debug/requests` HTTP endpoint

Use this endpoint to track HTTP client requests to the `/write` and `/query` endpoints.
The `/debug/requests` endpoint returns the number of writes and queries to InfluxDB per username and IP address.

### Definition

```
curl http://localhost:8086/debug/requests
```

### Query string parameters

| Query String Parameter | Optional/Required | Definition |
| :--------------------- | :---------------- |:---------- |
| 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

```
$ 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.

##### Track requests over a one-minute interval

```
$ curl http://localhost:8086/debug/requests?seconds=60

{
"user1:123.45.678.91": {"writes":3,"queries":0},
"user1:000.0.0.0": {"writes":0,"queries":16},
"user2:xx.xx.xxx.xxx": {"writes":4,"queries":0}
}
```

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:

```
{'fraction_non_alphanumeric': 0.1326222876057374, 'fraction_numerical': 0.022655388010297903, 'mean_word_length': 3.753846153846154, 'pattern_counts': {'":': 24, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7467124', 'n_tokens_mistral': 4313, 'n_tokens_neox': 3955, 'n_words': 1532}