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

# See your direct data rate

> Get started with Iroh Services in minutes

## What is direct data rate?

When two iroh endpoints connect, traffic either flows **directly** between them
(peer-to-peer) or gets routed through a relay server. Direct connections are
faster and cheaper. Relayed traffic adds latency and burns relay bandwidth.

**Direct data rate** is the percentage of your network's traffic flowing
directly. A **high rate** means NAT traversal is working and your users are getting
the best possible connection. A **low rate** means too much traffic is falling back
to relays, which is worth investigating.

This guide walks you through hooking up your first endpoint to Iroh Services so you can see direct data rate and other connectivity metrics for your own network. You'll need an [Iroh Services account](https://services.iroh.computer?utm_source=docs\&utm_content=quickstart) with an [API key](/iroh-services/access).

## Quickstart

### 1. Install Rust

```bash theme={null}
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

### 2. Get your API key

Create one from your project's **Settings → API Keys** tab. See [API Keys](/iroh-services/access) for the full walkthrough. Then export it as an environment variable:

```bash theme={null}
export IROH_SERVICES_API_SECRET=<your-api-key>
```

### 3. Run the example

Clone the repository and run the `quickstart` example:

```bash theme={null}
git clone https://github.com/n0-computer/iroh-services
cd iroh-services
cargo run --example quickstart
```

Open your project's **Endpoints** page in the dashboard. Your endpoint should appear online within a few seconds. Navigate to the **Metrics** tab to see real-time direct data rate and other connectivity metrics.

<img src="https://mintcdn.com/number0/kWIQgDsT7dLoTZPO/images/metrics-dashboard.png?fit=max&auto=format&n=kWIQgDsT7dLoTZPO&q=85&s=ffd83d65a1f6d40d676ef2f82d207b9c" alt="Metrics Dashboard" width="1240" height="1069" data-path="images/metrics-dashboard.png" />

The **Direct Data Rate** chart shows what percentage of your traffic flowed directly between endpoints versus through a relay over time.

<img src="https://mintcdn.com/number0/kWIQgDsT7dLoTZPO/images/metrics-direct-data-rate.png?fit=max&auto=format&n=kWIQgDsT7dLoTZPO&q=85&s=0920644c05209d375b82239bab05738d" alt="Direct data rate metric" width="970" height="397" data-path="images/metrics-direct-data-rate.png" />

## Build it into your own app

To wire Iroh Services into your own iroh application instead of running the example, follow the full setup below.

### Add the Iroh Services Client

Add the `iroh-services` crate to your `Cargo.toml`:

```
cargo add iroh-services
```

### Connect Your Endpoint

Then, in your code, create a client and connect your endpoint to Iroh Services.

```rust theme={null}
use iroh::{Endpoint, endpoint::presets};
use iroh_services::Client;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create an iroh endpoint
    let endpoint = Endpoint::bind(presets::N0).await?;

    // Wait for the endpoint to be online
    endpoint.online().await;

    // Create the Iroh Services client with your API key. Giving the endpoint
    // a name makes it easy to identify on the dashboard. Unnamed endpoints
    // are harder to distinguish from each other.
    let client = Client::builder(&endpoint)
        .api_secret_from_str("YOUR_API_KEY")?
        .name("my-endpoint")?
        .build()
        .await?;

    // Your endpoint is now reporting metrics to Iroh Services!

    Ok(())
}
```

### View Your Endpoint on the Dashboard

Go to your project's **Endpoints** page. You should see your endpoint listed as
online. Click on it to view details.

## Next steps

<Card title="Diagnose a connectivity issue" icon="stethoscope" href="/iroh-services/net-diagnostics/quickstart" horizontal>
  Run remote diagnostic reports on your users' endpoints to find out why connections fail.
</Card>

<Card title="Add a relay" icon="server" href="/add-a-relay" horizontal>
  Configure dedicated relays for your endpoints and learn why they matter for production.
</Card>

<Card title="Build a chat app" icon="comments" href="/examples/chat" horizontal>
  Build a peer-to-peer chat application from scratch using the iroh gossip protocol.
</Card>
