> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebuly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Client

> HTTP client for interacting with the Nebuly reports API

## ReportsClient

The main client class for interacting with the Nebuly reports API.

### Constructor

<ParamField path="publicKey" type="string" required>
  Your Nebuly public API key. Must not be a secret key (starting with `sk-`).
</ParamField>

<ParamField path="retries" type="number" default="0">
  Number of retry attempts for failed requests.
</ParamField>

<ParamField path="retryDelay" type="number" default="1000">
  Delay in milliseconds between retry attempts.
</ParamField>

<ParamField path="baseUrl" type="string" default="https://backend.nebuly.com/api/external">
  Base URL for the Nebuly API.
</ParamField>

<ParamField path="suppressKeyError" type="boolean" default="false">
  Whether to suppress errors when a secret key is used instead of a public key.
</ParamField>

<ParamField path="supperssKeyErrorLog" type="boolean" default="false">
  Whether to suppress console error logs when a secret key is used.
</ParamField>

### Methods

#### listReports()

Retrieves a list of all available reports.

<ResponseField name="reports" type="Report[]">
  Array of report objects containing basic report information.
</ResponseField>

#### getReport(params)

Retrieves detailed data for a specific report.

<ParamField path="reportId" type="string" required>
  The unique identifier of the report to retrieve.
</ParamField>

<ParamField path="timeRange" type="TimeRange">
  Optional time range filter for the report data.
</ParamField>

<ParamField path="tags" type="Record<string, string | string[]>">
  Optional tags to filter the report data. Values can be strings or arrays of strings.
</ParamField>

<ResponseField name="reportData" type="ReportData">
  The report data containing charts and metadata.
</ResponseField>

## Types

### Report

<ParamField path="id" type="string">
  Unique identifier for the report.
</ParamField>

<ParamField path="name" type="string">
  Display name of the report.
</ParamField>

<ParamField path="description" type="string">
  Description of the report.
</ParamField>

### ReportData

<ParamField path="id" type="string">
  Unique identifier for the report.
</ParamField>

<ParamField path="name" type="string">
  Display name of the report.
</ParamField>

<ParamField path="charts" type="ChartData[]">
  Array of chart data objects within the report.
</ParamField>

### ChartData

<ParamField path="id" type="string">
  Unique identifier for the chart (prefixed with "chart-").
</ParamField>

<ParamField path="name" type="string">
  Display name of the chart.
</ParamField>

<ParamField path="type" type="string">
  Type of the chart.
</ParamField>

<ParamField path="variables" type="string[]">
  Array of variable names used in the chart.
</ParamField>

<ParamField path="visualizationType" type="string">
  Type of visualization for the chart.
</ParamField>

<ParamField path="displayType" type="string">
  Display type for the chart.
</ParamField>

<ParamField path="breakdown" type="string">
  Breakdown dimension for the chart data.
</ParamField>

<ParamField path="timeRange" type="TimeRange">
  Time range for the chart data.
</ParamField>

<ParamField path="granularity" type="string">
  Time granularity for the chart data.
</ParamField>

<ParamField path="xLabelValues" type="string[]">
  Array of x-axis label values.
</ParamField>

<ParamField path="data" type="DatasetDatapoint[]">
  Array of data points for the chart.
</ParamField>

### TimeRange

<ParamField path="kind" type="TimeRangeKind">
  The type of time range (e.g., "custom", "today", "7\_days", etc.).
</ParamField>

<ParamField path="start" type="string">
  Start date/time for the range (ISO format).
</ParamField>

<ParamField path="end" type="string">
  End date/time for the range (ISO format).
</ParamField>

### TimeRangeKind

Available time range kinds:

* `"custom"` - Custom date range
* `"date_to_now"` - From a specific date to now
* `"today"` - Today only
* `"yesterday"` - Yesterday only
* `"7_days"` - Last 7 days
* `"30_days"` - Last 30 days
* `"this_month"` - Current month
* `"this_quarter"` - Current quarter
* `"this_year"` - Current year
* `"last_month"` - Previous month
* `"last_quarter"` - Previous quarter
* `"3_months"` - Last 3 months
* `"6_months"` - Last 6 months
* `"12_months"` - Last 12 months
* `"3_months_full"` - Last 3 full months
* `"6_months_full"` - Last 6 full months
* `"12_months_full"` - Last 12 full months
* `"q1"` - Q1
* `"q2"` - Q2
* `"q3"` - Q3
* `"q4"` - Q4
* `"ytd"` - Year to date

### DatasetDatapoint

<ParamField path="label" type="string">
  Label for the data point.
</ParamField>

<ParamField path="data" type="Array<{x: number, y: number, user?: string}>">
  Array of coordinate data points with optional user information.
</ParamField>

## Error Handling

The client throws `InvalidUrlError` when an invalid base URL is provided during initialization.

## Example Usage

```typescript theme={null}
import NebulyReports from '@nebuly-ai/reports';

const client = new NebulyReports.Client({
  publicKey: 'your-public-key-here',
  retries: 3,
  retryDelay: 1000
});

// List all reports
const reports = await client.listReports();

// Get specific report data
const reportData = await client.getReport({
  reportId: 'report-123',
  timeRange: {
    kind: '7_days',
    start: '2024-01-01T00:00:00Z',
    end: '2024-01-08T00:00:00Z'
  },
  tags: {
    environment: 'production',
    team: ['frontend', 'backend']
  }
});
```
