> ## Documentation Index
> Fetch the complete documentation index at: https://stars-components.js.org/llms.txt
> Use this file to discover all available pages before exploring further.

# @wolfstar/influx-utilities

> Work with a single InfluxDB organization through a small client.

<CodeGroup>
  ```bash npm theme={"system"}
  npm install @wolfstar/influx-utilities
  ```

  ```bash pnpm theme={"system"}
  pnpm add @wolfstar/influx-utilities
  ```

  ```bash yarn theme={"system"}
  yarn add @wolfstar/influx-utilities
  ```

  ```bash bun theme={"system"}
  bun add @wolfstar/influx-utilities
  ```
</CodeGroup>

<CardGroup cols={2}>
  <Card title="npm" icon="npm" horizontal href="https://npmx.dev/package/@wolfstar/influx-utilities" />

  <Card title="Source" icon="github" horizontal href="https://github.com/wolfstar-project/stars-components/tree/main/packages/influx-utilities" />
</CardGroup>

## Description

A tiny opinionated abstraction layer for InfluxDB for interacting with a single organization, based on [Wolfstar](https://wolfstar.rocks)'s internal tools.

## Usage

You can provide the configuration for the Influx client in several ways.

* `INFLUX_URL`: `ConnectionOptions.url`, the base URL to be used.
* `INFLUX_TOKEN`: `ConnectionOptions.token`, the authentication token.
* `INFLUX_ORG`: `ConnectionOptions.org`, the organization to use for the query and write APIs.
* `INFLUX_BUCKET`: `ConnectionOptions.writeBucket`, the bucket to write to in the write API.

### Environment Variables

```typescript theme={"system"}
// index.ts
process.env.INFLUX_URL = 'https://influxdb.wolfstar.rocks';
process.env.INFLUX_TOKEN = 'my-secret-token';
process.env.INFLUX_ORG = 'Wolfstar-Project';
process.env.INFLUX_BUCKET = 'analytics';

import { Client } from '@wolfstar/influx-utilities';

const client = new Client();
```

### `setInfluxVariables`

```typescript theme={"system"}
// index.ts
import { Client, setInfluxVariables } from '@wolfstar/influx-utilities';

setInfluxVariables({
	influxUrl: 'https://influxdb.wolfstar.rocks',
	influxToken: 'my-secret-token',
	influxOrg: 'Wolfstar-Project',
	influxBucket: 'analytics'
});

const client = new Client();
```

### Directly through `Client.Options`

```typescript theme={"system"}
import { Client } from '@wolfstar/influx-utilities';

const client = new Client({
	url: 'https://influxdb.wolfstar.rocks',
	token: 'my-secret-token',
	org: 'Wolfstar-Project',
	writeBucket: 'analytics'
});
```
