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

# Installation

> Install the Law4Devs Rust SDK and make your first API call.

## Requirements

* Rust 1.85+
* Tokio async runtime

## Install

Add to your `Cargo.toml`:

```toml theme={null}
[dependencies]
law4devs = "0.1"
tokio    = { version = "1", features = ["full"] }
futures  = "0.3"
```

Or use `cargo add`:

```bash theme={null}
cargo add law4devs
cargo add tokio --features full
cargo add futures
```

## First Call

```rust theme={null}
use law4devs::Law4DevsClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Law4DevsClient::new();
    let page = client.frameworks.list(None, None).await?;
    println!("{} frameworks", page.meta.total);
    Ok(())
}
```

## Configuration

```rust theme={null}
use std::time::Duration;
use law4devs::Law4DevsClient;

let client = Law4DevsClient::builder()
    .api_key(std::env::var("LAW4DEVS_API_KEY").unwrap_or_default())
    .base_url("https://api.law4devs.eu/v1") // default
    .timeout(Duration::from_secs(30))           // default
    .max_retries(3)                             // retries on 429/5xx
    .build();
```

| Option        | Type       | Default        | Description                                         |
| ------------- | ---------- | -------------- | --------------------------------------------------- |
| `api_key`     | `&str`     | `None`         | Your API key (required for authenticated endpoints) |
| `base_url`    | `&str`     | Production URL | Override for dev/staging environment                |
| `timeout`     | `Duration` | 30 seconds     | Per-request HTTP timeout                            |
| `max_retries` | `u32`      | `3`            | Retries on 429/5xx with exponential backoff         |

## Environment Variable

```bash theme={null}
export LAW4DEVS_API_KEY="your-key"
```

```rust theme={null}
let client = Law4DevsClient::builder()
    .api_key(std::env::var("LAW4DEVS_API_KEY").unwrap_or_default())
    .build();
```

<Warning>
  Never hardcode your API key in source code or commit it to version control.
</Warning>

## Verify the Install

```rust theme={null}
// src/main.rs
use law4devs::Law4DevsClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Law4DevsClient::builder()
        .api_key(std::env::var("LAW4DEVS_API_KEY").unwrap_or_default())
        .build();
    let page = client.frameworks.list(None, None).await?;
    println!("{} frameworks", page.meta.total);
    Ok(())
}
```

```bash theme={null}
LAW4DEVS_API_KEY=your-key cargo run
# → 19 frameworks
```
