﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>---
title: Introduction
description: "Use the Clics TypeScript SDK to manage projects, goals, funnels, sessions, AI crawlers, and privacy-friendly analytics data."
sidebar:
  label: Introduction
seo:
  title: Clics TypeScript SDK for analytics API access
---

The `@clicsdev/sdk` package is a type-safe TypeScript client for the [Clics REST API](/reference). Use it on a trusted server, in a backend job, or in CI to manage Clics configuration and read the same analytics data available in Dashboard.

Before making a call, open the [Dashboard](https://platform.clics.dev), create a paid-plan API key in **Settings → API keys**, and keep that key on the server only.

## Install

```bash
npm add @clicsdev/sdk
```

Also available via pnpm, yarn, and bun. See [Installation](/sdk/installation).

## Quick example

```typescript
import { Clics } from "@clicsdev/sdk";

const clics = new Clics({
  apiKey: process.env.CLICS_API_KEY,
});

const stats = await clics.stats.queryStats({
  projectId: "your_project_id",
  metrics: ["visitors", "pageviews"],
  dateRange: "last30days",
});

console.log(stats.results[0]?.metricValues.visitors);
```

## Client

```typescript
import { Clics } from "@clicsdev/sdk";

const clics = new Clics({
  apiKey: process.env.CLICS_API_KEY,
});
```

| Namespace | Methods |
| --- | --- |
| `clics.projects` | `listProjects`, `createProject`, `getProject`, `updateProject`, `deleteProject` |
| `clics.goals` | `listGoals`, `createGoal`, `getGoal`, `getGoalStats`, `updateGoal`, `deleteGoal` |
| `clics.funnels` | `listFunnels`, `createFunnel`, `getFunnel`, `getFunnelStats`, `updateFunnel`, `deleteFunnel` |
| `clics.sessions` | `listSessions`, `listSessionFilterValues`, `getSession`, `listSessionEvents` |
| `clics.aiCrawlers` | `getAiCrawlerAnalytics` |
| `clics.stats` | `queryStats` |

Class methods resolve to the typed response on success and throw a typed error for SDK validation, HTTP, or transport failures. Every method accepts an optional second argument (`RequestOptions`) for timeouts, retries, and request overrides. See [Errors](/sdk/errors).

The SDK uses camelCase (`projectId`, `dateRange`, `allowLocalhost`) and maps it to the REST API automatically.

## Standalone functions

For smaller bundles, import tree-shakeable functions from `@clicsdev/sdk/funcs/*` with `ClicsCore`:

```typescript
import { ClicsCore } from "@clicsdev/sdk/core.js";
import { goalsListGoals } from "@clicsdev/sdk/funcs/goals-list-goals.js";

const clics = new ClicsCore({ apiKey: process.env.CLICS_API_KEY });

const res = await goalsListGoals(clics, { projectId: "proj_xxx" });
if (res.ok) {
  console.log(res.value);
}
```

Standalone functions return a `Result` (`ok` / `error`) instead of throwing.

## Reference

- [Projects](/sdk/projects): `clics.projects.*`
- [Goals](/sdk/goals): `clics.goals.*`
- [Funnels](/sdk/funnels): `clics.funnels.*`
- [Sessions](/sdk/sessions): `clics.sessions.*`
- [AI Crawlers](/sdk/ai-crawlers): `clics.aiCrawlers.*`
- [Stats](/sdk/stats): `clics.stats.