UpdownDotnet 2.2.1

dotnet add package UpdownDotnet --version 2.2.1
                    
NuGet\Install-Package UpdownDotnet -Version 2.2.1
                    
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="UpdownDotnet" Version="2.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UpdownDotnet" Version="2.2.1" />
                    
Directory.Packages.props
<PackageReference Include="UpdownDotnet" />
                    
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 UpdownDotnet --version 2.2.1
                    
#r "nuget: UpdownDotnet, 2.2.1"
                    
#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 UpdownDotnet@2.2.1
                    
#: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=UpdownDotnet&version=2.2.1
                    
Install as a Cake Addin
#tool nuget:?package=UpdownDotnet&version=2.2.1
                    
Install as a Cake Tool

CI

updown-dotnet

A simple, modern Updown.io .NET Client

https://www.nuget.org/packages/UpdownDotnet

Don't currently utilize Updown.IO? Join here --> https://updown.io/r/WioVu

Features

  • Full API Coverage: Checks, Recipients, Status Pages, Pulse Monitoring, Downtimes, Metrics, and Nodes
  • Modern Async/Await: All methods support async patterns with CancellationToken
  • Custom Exceptions: Specific exception types for better error handling
  • Nullable Reference Types: Full nullability annotations for safer code
  • Multi-Targeting: Supports .NET 10, .NET 9, .NET 8, and .NET Standard 2.0
  • Comprehensive Testing: 49+ unit tests with 100% pass rate
  • XML Documentation: Full IntelliSense support

Installation

dotnet add package UpdownDotnet

Quick Start

using UpdownDotnet;
using UpdownDotnet.Models;

// Create client using builder (recommended)
var client = new UpdownClientBuilder()
    .WithApiKey("your-api-key")
    .Build();

// Get all checks
var checks = await client.ChecksAsync();

// Create a new check
var checkParams = new CheckParameters
{
    Url = "https://example.com",
    Alias = "My Website",
    Period = 60 // Check every 60 seconds
};
var check = await client.CheckCreateAsync(checkParams);

API Implementation Status

Entity Status
Checks ✅ Complete
Downtimes ✅ Complete
Metrics ✅ Complete
Nodes ✅ Complete
Recipients ✅ Complete
Status Pages ✅ Complete
Pulse Monitoring ✅ Complete

Usage Examples

Checks

// Get all checks
var checks = await client.ChecksAsync();

// Get specific check
var check = await client.CheckAsync("check-token");

// Create a check
var parameters = new CheckParameters
{
    Url = "https://example.com",
    Alias = "Example Site",
    Period = 300,
    Enabled = true
};
var newCheck = await client.CheckCreateAsync(parameters);

// Update a check
var updateParams = new CheckParameters { Period = 600 };
var updated = await client.CheckUpdateAsync("check-token", updateParams);

// Delete a check
await client.CheckDeleteAsync("check-token");

Downtimes

// Get downtimes for a check
var downtimes = await client.DowntimesAsync("check-token");

// With pagination
var page2 = await client.DowntimesAsync("check-token", page: 2);

Metrics

// Get metrics for a check
var metrics = await client.MetricsAsync("check-token");

// Get metrics for a date range
var metrics = await client.MetricsAsync(
    "check-token",
    from: "2024-01-01",
    to: "2024-01-31"
);

// Group by time or location
var metrics = await client.MetricsAsync(
    "check-token",
    group: "time"
);

Nodes

// Get all monitoring nodes
var nodes = await client.NodesAsync();

// Get IPv4 addresses
var ipv4 = await client.NodesIpv4Async();

// Get IPv6 addresses
var ipv6 = await client.NodesIpv6Async();

Pulse Monitoring (Cron/Background Jobs)

Pulse monitoring is used to monitor cron jobs, background tasks, and scheduled processes. Your application sends heartbeat signals to Updown.io on schedule.

// Send a pulse heartbeat
await client.SendPulseAsync("https://pulse.updown.io/YOUR-TOKEN/YOUR-KEY");

// In a scheduled job
public async Task RunScheduledTask()
{
    try
    {
        // Your work here
        await DoImportantWork();
        
        // Send success pulse
        await client.SendPulseAsync(pulseUrl);
    }
    catch (Exception ex)
    {
        // Don't send pulse on failure - Updown.io will alert you
        _logger.LogError(ex, "Task failed");
    }
}

Error Handling

The client provides specific exception types for different error scenarios:

using UpdownDotnet.Exceptions;

try
{
    var check = await client.CheckAsync("token");
}
catch (UpdownNotFoundException ex)
{
    // 404 - Check not found
    Console.WriteLine("Check doesn't exist");
}
catch (UpdownUnauthorizedException ex)
{
    // 401 - Invalid API key
    Console.WriteLine("Authentication failed");
}
catch (UpdownBadRequestException ex)
{
    // 400 - Invalid request parameters
    Console.WriteLine($"Bad request: {ex.ResponseContent}");
}
catch (UpdownRateLimitException ex)
{
    // 429 - Rate limit exceeded
    Console.WriteLine($"Rate limited. Retry after {ex.RetryAfterSeconds}s");
    
    if (ex.RetryAfterSeconds.HasValue)
    {
        await Task.Delay(TimeSpan.FromSeconds(ex.RetryAfterSeconds.Value));
        // Retry...
    }
}
catch (UpdownApiException ex)
{
    // Other API errors (500+)
    Console.WriteLine($"API error: {ex.StatusCode} - {ex.Message}");
}

ASP.NET Core Integration

Dependency Injection Setup

Program.cs:

// Register with dependency injection
builder.Services.AddHttpClient<IUpdownService, UpdownService>((sp, client) =>
{
    client.BaseAddress = new Uri("https://updown.io");
    var apiKey = builder.Configuration["Updown:ApiKey"];
    client.DefaultRequestHeaders.Add("X-API-KEY", apiKey);
});

Service Implementation:

public class UpdownService : IUpdownService
{
    private readonly UpdownClient _client;

    public UpdownService(HttpClient httpClient)
    {
        _client = new UpdownClient(httpClient);
    }

    public async Task<List<Check>> GetAllChecksAsync(CancellationToken ct = default)
    {
        return await _client.ChecksAsync(ct);
    }
}

Advanced Configuration

Using the Builder Pattern

var client = new UpdownClientBuilder()
    .WithApiKey("your-api-key")
    .WithTimeout(TimeSpan.FromSeconds(30))
    .WithUserAgent("MyApp/1.0")
    .Build();

Custom HttpClient

var handler = new SocketsHttpHandler
{
    PooledConnectionLifetime = TimeSpan.FromMinutes(5),
    AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
};

var client = new UpdownClientBuilder()
    .WithApiKey("your-api-key")
    .WithHttpMessageHandler(handler)
    .Build();

Cancellation Token Support

// Pass cancellation token for long-running operations
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));

try
{
    var checks = await client.ChecksAsync(cts.Token);
}
catch (OperationCanceledException)
{
    Console.WriteLine("Request cancelled");
}

Migration from 1.x to 2.0

Version 2.0 introduces several improvements while maintaining backward compatibility:

Old (still works, but deprecated):

var client = UpdownClientFactory.Create("api-key");
var checks = await client.Checks();  // No Async suffix
var check = await client.Check("token");

New (recommended):

var client = new UpdownClientBuilder()
    .WithApiKey("api-key")
    .Build();
var checks = await client.ChecksAsync();  // Async suffix
var check = await client.CheckAsync("token");

For full migration details, see the CHANGELOG.

Best Practices

  1. Use the Builder Pattern: More flexible and thread-safe than the factory

    var client = new UpdownClientBuilder().WithApiKey("key").Build();
    
  2. Pass CancellationTokens: Especially in web applications

    await client.ChecksAsync(cancellationToken);
    
  3. Handle Specific Exceptions: Use custom exception types for better error handling

    catch (UpdownRateLimitException ex) { /* Handle rate limit */ }
    
  4. Use Async Methods: Always use methods with Async suffix

    await client.ChecksAsync();  // ✅ Good
    await client.Checks();       // ⚠️ Deprecated
    
  5. Dispose HttpClient Properly: When using custom HttpClient instances

    using var httpClient = new HttpClient();
    var client = new UpdownClient(httpClient);
    

Troubleshooting

"Unauthorized" Exception

  • Verify your API key is correct
  • Check that the API key is active in your Updown.io dashboard

Rate Limiting

  • Updown.io has rate limits on API calls
  • Catch UpdownRateLimitException and respect RetryAfterSeconds
  • Consider caching responses when appropriate

Connection Timeouts

  • Default timeout is 100 seconds
  • Configure custom timeout using UpdownClientBuilder.WithTimeout()

Contributing

Contributions are welcome! Please see our Contributing Guide for details.

git clone https://github.com/strvmarv/updown-dotnet.git
cd updown-dotnet
dotnet restore
dotnet build

Run Tests

dotnet test

Documentation

License

MIT License - see LICENSE file for details

Support


Made with ❤️ for the .NET community

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.1 96 2/20/2026
2.2.0 88 2/20/2026
2.0.1 92 2/20/2026
2.0.0 697 12/1/2025
2.0.0-rc.2 177 11/5/2025
2.0.0-rc.1 162 10/21/2025
1.1.0 163 7/29/2025
1.0.9 369 6/10/2025
1.0.8 200 1/22/2025
1.0.7 183 12/17/2024
1.0.6 191 11/18/2024
1.0.5 187 11/15/2024
1.0.4 189 11/8/2024
1.0.3 192 11/7/2024
1.0.1 177 11/7/2024
1.0.0 177 11/6/2024