> ## 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.

# Quick Start

> Practical examples to get up and running with the Law4Devs TypeScript SDK.

## Setup

```typescript theme={null}
import { Law4DevsClient } from 'law4devs';

const client = new Law4DevsClient();
```

***

## 1. List all frameworks

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

console.log(`${page.meta.total} frameworks available`);

for (const fw of page.data) {
  const label = fw.status === 'active' ? fw.shortName : `${fw.shortName} (${fw.status})`;
  console.log(`${label}: ${fw.name}`);
}
```

***

## 2. Iterate all CRA articles

Use `for await` to walk through every article without managing pagination manually.

```typescript theme={null}
let count = 0;

for await (const article of client.articles.iter('cra')) {
  console.log(`Art. ${article.articleNumber}: ${article.title}`);
  count++;
}

console.log(`Iterated ${count} CRA articles`);
```

<Tip>
  `iter()` fetches pages lazily. Break out of the loop early with `break` as soon as you have what you need — subsequent pages are never fetched.
</Tip>

***

## 3. Search with a framework filter

```typescript theme={null}
const results = await client.search.query('security requirements', {
  framework: 'nis2',
  resultType: 'article',
  perPage: 10,
});

for (const result of results.data) {
  console.log(`[${result.type}] Art. ${result.articleNumber}: ${result.title}`);
  console.log(`  ...${result.matchContext}...`);
}
```

***

## 4. Get compliance deadlines with `iterDeadlines()`

```typescript theme={null}
for await (const deadline of client.compliance.iterDeadlines({ frameworkSlug: 'nis2' })) {
  const date = deadline.deadlineDate ?? 'ongoing';
  console.log(`${deadline.deadlineType} — ${date}: ${deadline.description}`);
}
```

<Note>
  The compliance resource uses `iterDeadlines()` rather than `iter()` because it operates across multiple frameworks rather than within a single one.
</Note>

***

## 5. Error handling

```typescript theme={null}
import { Law4DevsClient, NotFoundError, RateLimitError } from 'law4devs';

const client = new Law4DevsClient({ maxRetries: 3 });

try {
  const article = await client.articles.get('gdpr', 999);
  console.log(article.title);
} catch (err) {
  if (err instanceof NotFoundError) {
    console.error(`Article not found (HTTP ${err.statusCode})`);
  } else if (err instanceof RateLimitError) {
    console.error('Rate limit hit — the SDK retries automatically, but all retries were exhausted');
  } else {
    throw err; // re-throw unexpected errors
  }
}
```

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Frameworks →" href="/sdks/typescript/frameworks" icon="building-columns" color="#0EA5E9" />

  <Card title="Articles →" href="/sdks/typescript/articles" icon="file-lines" color="#8B5CF6" />

  <Card title="Pagination →" href="/sdks/typescript/pagination" icon="list" color="#22c55e" />

  <Card title="Error Handling →" href="/sdks/typescript/error-handling" icon="triangle-exclamation" color="#f59e0b" />
</CardGroup>
