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

# Quickstart

> Make your first X API v2 request with the C# / .NET XDK.

**1. Add the package**

```bash theme={null}
dotnet new console -n XdkQuickstart
cd XdkQuickstart
dotnet add package XDevPlatform.Xdk
```

**2. Export your Bearer Token**

Generate a **Bearer Token** in the [X Developer Console](https://console.x.com) and set it in your shell:

```bash theme={null}
export X_BEARER_TOKEN="your_bearer_token_here"
```

**3. Run a lookup and search**

```csharp theme={null}
using System;
using System.Collections.Generic;
using Xdk;
using Xdk.Clients;

using var client = new XClient(new XClientOptions
{
    BearerToken = Environment.GetEnvironmentVariable("X_BEARER_TOKEN"),
});

var user = await client.Users.GetByUsernameAsync("XDevelopers");
Console.WriteLine($"User: {user.Data}");

var posts = await client.Posts.SearchRecentAsync(
    "from:XDevelopers -is:retweet",
    new PostsClient.SearchRecentOptions
    {
        MaxResults = 10,
        PostFields = new List<string> { "created_at", "public_metrics" },
    });
Console.WriteLine($"Posts returned: {posts.Data?.Count ?? 0}");
```

Run it with `dotnet run`.

## Next steps

* [Authentication](https://docs.x.com/xdks/csharp/authentication.md) — Bearer Token, OAuth 2.0 PKCE, and OAuth 1.0a
* [Pagination](https://docs.x.com/xdks/csharp/pagination.md) — Iterate pages with `await foreach`
* [Streaming](https://docs.x.com/xdks/csharp/streaming.md) — Read live streams with `EventStream<T>`
* [Code samples](https://github.com/xdevplatform/samples/tree/main/csharp) — Runnable C# examples
