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

# Tags

> List, retrieve, and iterate taxonomy tags with the Law4Devs TypeScript SDK.

## Overview

Tags are the Law4Devs taxonomy — a curated set of labels applied to articles and requirements across all frameworks. Using tags you can find related content spanning multiple regulations (e.g. all articles tagged `"data-breach"` across GDPR, NIS2, and CRA).

***

## Methods

### `list()`

Returns a page of tags.

```typescript theme={null}
const page = await client.tags.list({ perPage: 50 });

console.log(`${page.meta.total} tags in the taxonomy`);

for (const tag of page.data) {
  console.log(`${tag.slug}: ${tag.name}`);
}
```

**Parameters**

| Parameter | Type     | Default | Description            |
| --------- | -------- | ------- | ---------------------- |
| `page`    | `number` | `1`     | Page number            |
| `perPage` | `number` | `20`    | Items per page (1–100) |

**Returns** `Promise<Page<Tag>>`

***

### `get()`

Fetch a single tag by its slug.

```typescript theme={null}
const tag = await client.tags.get('data-breach');

console.log(tag.name);
console.log(tag.description);
console.log('Keywords:', tag.keywords.join(', '));
```

**Parameters**

| Parameter | Type     | Description                                  |
| --------- | -------- | -------------------------------------------- |
| `slug`    | `string` | Tag slug, e.g. `"data-breach"`, `"security"` |

**Returns** `Promise<Tag>`

***

### `iter()`

Iterate over all tags.

```typescript theme={null}
for await (const tag of client.tags.iter()) {
  console.log(`#${tag.slug} — ${tag.name} (color: ${tag.color ?? 'none'})`);
}
```

**Parameters** — same options as `list()` (except `page`, which is managed internally).

**Returns** `AsyncGenerator<Tag>`

***

## Model

### `Tag`

| Field         | Type             | Description                                    |
| ------------- | ---------------- | ---------------------------------------------- |
| `id`          | `number`         | Internal numeric ID                            |
| `slug`        | `string`         | URL-safe identifier, e.g. `"data-breach"`      |
| `name`        | `string`         | Display name, e.g. `"Data Breach"`             |
| `description` | `string \| null` | Plain-text description of what this tag covers |
| `keywords`    | `string[]`       | Keywords used for auto-tagging                 |
| `color`       | `string \| null` | Hex color for UI display, e.g. `"#e53e3e"`     |
| `createdAt`   | `string`         | ISO 8601 creation timestamp                    |

***

## Example: build a tag index

```typescript theme={null}
const tagIndex = new Map<string, { name: string; keywords: string[] }>();

for await (const tag of client.tags.iter()) {
  tagIndex.set(tag.slug, {
    name: tag.name,
    keywords: tag.keywords,
  });
}

console.log(`Indexed ${tagIndex.size} tags`);
console.log(tagIndex.get('security'));
```
