PawSharp.API 0.5.0-alpha9

This is a prerelease version of PawSharp.API.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package PawSharp.API --version 0.5.0-alpha9
                    
NuGet\Install-Package PawSharp.API -Version 0.5.0-alpha9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PawSharp.API" Version="0.5.0-alpha9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PawSharp.API" Version="0.5.0-alpha9" />
                    
Directory.Packages.props
<PackageReference Include="PawSharp.API" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PawSharp.API --version 0.5.0-alpha9
                    
#r "nuget: PawSharp.API, 0.5.0-alpha9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PawSharp.API@0.5.0-alpha9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PawSharp.API&version=0.5.0-alpha9&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PawSharp.API&version=0.5.0-alpha9&prerelease
                    
Install as a Cake Tool

PawSharp.API

REST API client for Discord with automatic rate limiting and error handling.

PawSharp.API provides a complete, production-ready REST client for Discord's API v10. Built on .NET 8.0 with modern async patterns, comprehensive error handling, and intelligent rate limiting that just works.

Features

  • Complete API coverage for Discord API v10
  • Automatic bucket management with zero-config setup
  • Configurable timeouts with cancellation support
  • Automatic X-Audit-Log-Reason headers
  • Automatic retries with exponential backoff
  • Smart caching prevents duplicate requests
  • Built-in performance tracking
  • First-class DI container support

📦 Installation

dotnet add package PawSharp.API --version 0.5.0-alpha9

🚀 Quick Start

using PawSharp.API.Clients;
using PawSharp.Core.Entities;

// Create the REST client
var options = new PawSharpOptions
{
    Token = "your-bot-token-here"
};

var restClient = new DiscordRestClient(options);

// Get current user
User user = await restClient.GetCurrentUserAsync();
Console.WriteLine($"Logged in as: {user.Username}");

// Send a message
var message = await restClient.CreateMessageAsync(channelId, "Hello, Discord!");

📋 API Coverage

Core Endpoints

  • Users - Get, modify current user
  • Guilds - Create, get, modify, delete guilds
  • Channels - All channel operations (text, voice, DM)
  • Messages - Send, edit, delete, bulk operations
  • Members - Guild member management
  • Roles - Role creation and management
  • Emojis - Custom emoji handling
  • Webhooks - Webhook CRUD operations

Advanced Features

  • Application Commands - Slash commands and permissions
  • Interactions - Interaction responses and followups
  • Audit Logs - Guild audit log retrieval
  • Invites - Invite management
  • Voice - Voice region and state management

🔧 Configuration

var options = new PawSharpOptions
{
    Token = "your-bot-token",
    UserAgent = "MyBot/1.0.0",
    Timeout = TimeSpan.FromSeconds(30),
    MaxRetries = 3,
    EnableCompression = true
};

var restClient = new DiscordRestClient(options);

📖 Usage Examples

Rate Limiting (Automatic)

// Rate limiting happens automatically - no code changes needed!
for (int i = 0; i < 100; i++)
{
    await restClient.CreateMessageAsync(channelId, $"Message {i}");
    // PawSharp handles rate limits transparently
}

Error Handling

try
{
    var message = await restClient.CreateMessageAsync(channelId, "Hello!");
}
catch (DiscordRateLimitException ex)
{
    Console.WriteLine($"Rate limited! Retry after: {ex.RetryAfter}");
}
catch (DiscordForbiddenException ex)
{
    Console.WriteLine("Missing permissions!");
}
catch (DiscordNotFoundException ex)
{
    Console.WriteLine("Channel not found!");
}

Audit Logs

// Automatic audit log reason support
await restClient.ModifyGuildAsync(guildId, new GuildUpdateModel
{
    Name = "New Guild Name"
}, reason: "Server rebranding");

Application Commands

// Create a slash command
var command = await restClient.CreateGuildApplicationCommandAsync(guildId, new ApplicationCommand
{
    Name = "ping",
    Description = "Responds with pong!",
    Type = ApplicationCommandType.ChatInput
});

// Get permissions
var permissions = await restClient.GetGuildApplicationCommandPermissionsAsync(guildId, command.Id);

🔄 Dependency Injection

// Register with DI container
services.AddPawSharp(options => {
    options.Token = configuration["Discord:Token"];
});

// Inject into your services
public class MyService
{
    private readonly IDiscordRestClient _restClient;

    public MyService(IDiscordRestClient restClient)
    {
        _restClient = restClient;
    }
}

📊 Monitoring & Metrics

// Get performance metrics
var metrics = restClient.GetMetrics();
Console.WriteLine($"Requests: {metrics.TotalRequests}");
Console.WriteLine($"Rate Limits Hit: {metrics.RateLimitsHit}");
Console.WriteLine($"Average Response Time: {metrics.AverageResponseTime}ms");

🤝 Dependencies

  • PawSharp.Core - Entity models and types
  • .NET 8.0 - Runtime requirements
  • Microsoft.Extensions.Http - HTTP client factory
  • Microsoft.Extensions.Logging - Structured logging

🐛 Error Handling

PawSharp.API provides comprehensive error handling:

// All exceptions inherit from DiscordException
catch (DiscordException ex)
{
    switch (ex.ErrorCode)
    {
        case 10003: // Unknown Channel
            // Handle missing channel
            break;
        case 50013: // Missing Permissions
            // Handle permission issues
            break;
    }
}

📄 License

MIT License - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on PawSharp.API:

Package Downloads
PawSharp.Cache

Caching providers for PawSharp with in-memory and pluggable cache implementations.

PawSharp.Gateway

WebSocket gateway client for PawSharp with sharding, reconnection, and event handling.

PawSharp.Client

Main Discord client for PawSharp with unified API, gateway, and caching.

PawSharp.Interactions

Interaction handlers for PawSharp including slash commands and component interactions.

PawSharp.Voice

Full-featured voice support for PawSharp — Opus encode/decode via Concentus, RFC 3550 RTP framing, and Discord DAVE end-to-end encryption (RFC 9420 MLS) built entirely on .NET 8 BCL cryptography.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.11.0-alpha.1 33 3/10/2026
0.10.0-alpha.3 40 3/8/2026
0.7.0-alpha.1 43 3/6/2026
0.6.1-alpha1 43 3/4/2026
0.6.0-alpha1 46 2/25/2026
0.5.0-alpha9 66 1/15/2026
0.5.0-alpha8 91 1/14/2026
0.5.0-alpha7 135 1/10/2026
0.5.0-alpha6 165 1/9/2026
0.5.0-alpha13 53 2/22/2026
0.5.0-alpha12 52 2/22/2026
0.5.0-alpha11 69 2/20/2026
0.5.0-alpha10 53 1/21/2026
0.1.0-alpha4 118 1/7/2026