---
title: API Quick Start
description: Interact with InfluxDB using a rich API for writing and querying data and more.
url: https://docs.influxdata.com/influxdb/v2/api-guide/api_intro/
estimated_tokens: 1170
product: InfluxDB OSS v2
version: v2
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb/v2/api-guide/api_intro/
date: '2025-05-23T13:46:31-05:00'
lastmod: '2025-05-23T13:46:31-05:00'
---

This page documents an earlier version of InfluxDB OSS.[InfluxDB 3 Core](/influxdb3/core/) is the latest stable version.

#### API token hashing is enabled by default in InfluxDB OSS 2.9.0

Stronger token security: tokens are stored as hashes on disk, so a
copy of the database file doesn’t expose usable tokens. Existing
tokens are hashed on first startup and the original strings can’t
be recovered afterward — **capture any plaintext tokens you still
need before you upgrade**.

For more information, see [Token hashing](/influxdb/v2/admin/tokens/#token-hashing).

InfluxDB offers a rich API and [client libraries](/influxdb/v2/api-guide/client-libraries) ready to integrate with your application. Use popular tools like Curl and [Postman](/influxdb/v2/api-guide/postman) for rapidly testing API requests.

This section guides you through the most commonly used API methods.

For detailed documentation on the entire API, see the [InfluxDB v2 API Reference](/influxdb/v2/api/).

#### Use InfluxDB 1.x API clients with 2.9

If you need to use InfluxDB 2.9 with **InfluxDB 1.x** API clients and integrations, see the [1.x compatibility guide](/influxdb/v2/reference/api/influxdb-1x/).

## Bootstrap your application

With most API requests, you’ll need to provide a minimum of your InfluxDB URL and [Authorization Token (API Token)](/influxdb/v2/admin/tokens/).

[Install InfluxDB OSS v2.x](/influxdb/v2/install/) or upgrade to
an [InfluxDB Cloud account](/influxdb/cloud/sign-up).

### Authentication

InfluxDB uses [API tokens](/influxdb/v2/admin/tokens/) to authorize API requests.
InfluxDB filters API requests and response data based on the permissions associated with the token.

1. Before exploring the API, use the `influx` CLI or the InfluxDB UI to[create an initial API token](/influxdb/v2/admin/tokens/create-token/) for your application.

2. Include your API token in an `Authorization: Token API_TOKEN` HTTP header with each request–for example:

[curl](#curl)[Node.js](#nodejs)

```bash
# Use a token to authorize a GET request to the InfluxDB API.
# List buckets in your organization that the token can read.
curl -X GET "http://localhost:8086/api/v2/buckets" \
  --header 'Accept: application/json' \
  --header 'Authorization: Token API_TOKEN'
```

```js
/**
  * Use a token to authorize a GET request to the InfluxDB API.
  * List buckets in your organization that the token can read.
  */

const https = require('https');

function listBuckets() {

  const options = {
    host: 'localhost:8086',
    path: "/api/v2/buckets",
    headers: {
      'Authorization': 'Token API_TOKEN',
      'Content-type': 'application/json'
    },
  };

  const request = https.get(options, (response) => {
    let rawData = '';
    response.on('data', () => {
      response.on('data', (chunk) => { rawData += chunk; });
    })
    response.on('end', () => {
      console.log(rawData);
    })
  });

  request.end();
}
```

> [!Note]
> Postman is another popular tool for exploring APIs.
> See how to [send authenticated requests with Postman](/influxdb/v2/tools/postman/#send-authenticated-api-requests-with-postman).

## Buckets API

Before writing data you’ll need to create a bucket in your InfluxDB instance.
To use the API to create a bucket, send a request to the following endpoint:

```
POST /api/v2/buckets
```

```bash
curl --request POST \
  "http://localhost:8086/api/v2/buckets" \
  --header "Authorization: Token API_TOKEN" \
  --json '{
    "orgID": "'"ORG_ID"'",
    "name": "BUCKET_NAME",
    "retentionRules": [
      {
        "type": "expire",
        "everySeconds": RETENTION_PERIOD_SECONDS,
        "shardGroupDurationSeconds": 0
      }
    ]
  }'
```

Replace the following placeholders with your values:

* `API_TOKEN` - your [token](/influxdb/v2/admin/tokens/).
* `ORG_ID` - the ID of the [organization](/influxdb/v2/admin/organizations/) that owns the bucket.
* `BUCKET_NAME` - the name of the [bucket](/influxdb/v2/admin/buckets/) to create.
* Optional: `RETENTION_PERIOD_SECONDS` - the [retention period](/influxdb/v2/reference/glossary/#retention-period) (in number of seconds) to retain data in the bucket. Default is `0` (infinite retention).
  * For example, `31536000` (1 year) or `604800` (7 days).

For more information, see [Create a bucket](/influxdb/v2/admin/buckets/create-bucket/#create-a-bucket-using-the-influxdb-api).

## Write API

[Write data to InfluxDB](/influxdb/v2/write-data/developer-tools/api/) using an HTTP request to the InfluxDB API `/api/v2/write` endpoint.

## Query API

[Query from InfluxDB](/influxdb/v2/query-data/execute-queries/influx-api/) using an HTTP request to the `/api/v2/query` endpoint.
