This document provides a comprehensive reference to the UptimeRobot API and how this .NET client library maps to it.
Official API Docs: https://uptimerobot.com/api/
The UptimeRobot API is a RESTful API that uses HTTP POST requests with form-urlencoded data. All responses are in JSON format.
https://api.uptimerobot.com/v2/
UptimeRobot uses API keys for authentication. You can obtain your API key from your account settings.
- Main API Key: Full access to all account features
- Monitor-Specific API Keys: Limited access to specific monitors
var client = UptimeRobotClientFactory.Create("your-api-key-here");UptimeRobot enforces rate limits on API requests:
- Free accounts: Lower limits
- Paid accounts: Higher limits
When rate limited, the API returns HTTP 429. Consider implementing retry logic with exponential backoff.
Monitor endpoints allow you to create, read, update, and delete monitors.
Endpoint: POST /v2/getMonitors
Library Method: GetMonitorsAsync() or GetAllMonitorsAsync()
Parameters:
monitors(optional): Comma-separated monitor IDstypes(optional): Filter by monitor typesstatuses(optional): Filter by monitor statusescustom_uptime_ratios(optional): Custom uptime ratio periodscustom_uptime_ranges(optional): Custom date ranges for uptimeall_time_uptime_ratio(optional): Include all-time uptime ratiologs(optional): Include logs (1 = yes)logs_start_date(optional): Start date for logslogs_end_date(optional): End date for logslogs_limit(optional): Number of logs to returnresponse_times(optional): Include response timesresponse_times_limit(optional): Number of response timesresponse_times_average(optional): Average interval for response timesresponse_times_start_date(optional): Start date for response timesresponse_times_end_date(optional): End date for response timesalert_contacts(optional): Include alert contacts (1 = yes)mwindows(optional): Include maintenance windowscustom_http_headers(optional): Include custom HTTP headerscustom_http_statuses(optional): Include custom HTTP statusesssl(optional): Include SSL certificate infotimezone(optional): Timezone for datesoffset(optional): Pagination offset (default: 0)limit(optional): Results per page (max: 50, default: 50)search(optional): Search term
Example:
// Get all monitors with automatic pagination
await foreach (var monitor in client.GetAllMonitorsAsync())
{
Console.WriteLine($"{monitor.FriendlyName}: {monitor.Status}");
}
// Manual pagination
var response = await client.GetMonitorsAsync(new MonitorSearchParameters
{
Limit = 50,
Offset = 0,
Search = "example.com"
});Endpoint: POST /v2/newMonitor
Library Method: CreateMonitorAsync()
Required Parameters:
friendly_name: Display name for the monitorurl: URL or IP to monitortype: Monitor type (1-7)
Optional Parameters:
sub_type: Sub-type for port monitoringport: Port number for port monitoringkeyword_type: Keyword search type (1 = exists, 2 = not exists)keyword_case_type: Case sensitivity (1 = case sensitive, 2 = case insensitive)keyword_value: Keyword to search forinterval: Check interval in seconds (60, 300, 600, 900, 1800, 3600)timeout: Request timeout in seconds (30-120)http_username: HTTP authentication usernamehttp_password: HTTP authentication passwordhttp_auth_type: HTTP auth type (1 = Basic, 2 = Digest)http_method: HTTP method (1 = HEAD, 2 = GET, 3 = POST, 4 = PUT, 5 = PATCH, 6 = DELETE, 7 = OPTIONS)post_type: POST data typepost_value: POST datapost_content_type: Content-Type header for POSTalert_contacts: Alert contact IDsmwindows: Maintenance window IDscustom_http_headers: JSON string of custom headerscustom_http_statuses: Comma-separated status codesignore_ssl_errors: Ignore SSL errors (1 = yes)
Example:
var parameters = new MonitorCreateParameters
{
FriendlyName = "My Website",
Url = "https://example.com",
Type = MonitorType.HTTP,
Interval = 300,
CustomHttpHeaders = new Dictionary<string, string>
{
{ "User-Agent", "MyMonitor/1.0" }
}
};
var result = await client.CreateMonitorAsync(parameters);
Console.WriteLine($"Created monitor with ID: {result.Monitor.Id}");Endpoint: POST /v2/editMonitor
Library Method: UpdateMonitorAsync()
Required Parameters:
id: Monitor ID
Optional Parameters: Same as Create Monitor (all optional)
Example:
var parameters = new MonitorUpdateParameters
{
Id = 12345678,
Interval = 600,
Status = MonitorStatus.Paused
};
await client.UpdateMonitorAsync(parameters);Endpoint: POST /v2/deleteMonitor
Library Method: DeleteMonitorAsync()
Required Parameters:
id: Monitor ID
Example:
var parameters = new MonitorDeleteParameters { Id = 12345678 };
await client.DeleteMonitorAsync(parameters);Endpoint: POST /v2/resetMonitor
Library Method: ResetMonitorAsync()
Required Parameters:
id: Monitor ID
Example:
var parameters = new MonitorResetParameters { Id = 12345678 };
await client.ResetMonitorAsync(parameters);Alert contacts are the notification endpoints (email, SMS, webhook, etc.) that receive alerts.
Endpoint: POST /v2/getAlertContacts
Library Method: GetAlertContactsAsync() or GetAllAlertContactsAsync()
Parameters:
alert_contacts(optional): Comma-separated alert contact IDsoffset(optional): Pagination offsetlimit(optional): Results per page (max: 50)
Example:
await foreach (var contact in client.GetAllAlertContactsAsync())
{
Console.WriteLine($"{contact.FriendlyName} ({contact.Type}): {contact.Value}");
}Endpoint: POST /v2/newAlertContact
Library Method: CreateAlertContactAsync()
Required Parameters:
type: Alert contact type (1-13)value: Contact value (email, phone, URL, etc.)friendly_name: Display name
Example:
var parameters = new AlertContactCreateParameters
{
Type = AlertContactType.Email,
FriendlyName = "Admin Email",
Value = "admin@example.com"
};
await client.CreateAlertContactAsync(parameters);Endpoint: POST /v2/editAlertContact
Library Method: UpdateAlertContactAsync()
Endpoint: POST /v2/deleteAlertContact
Library Method: DeleteAlertContactAsync()
Maintenance windows allow you to pause monitoring during scheduled maintenance.
Endpoint: POST /v2/getMWindows
Library Method: GetMaintenanceWindowsAsync() or GetAllMaintenanceWindowsAsync()
Example:
await foreach (var window in client.GetAllMaintenanceWindowsAsync())
{
Console.WriteLine($"{window.FriendlyName}: {window.Type}");
}Endpoint: POST /v2/newMWindow
Library Method: CreateMaintenanceWindowAsync()
Required Parameters:
friendly_name: Display nametype: Window type (1 = once, 2 = daily, 3 = weekly, 4 = monthly)start_time: Unix timestamp of start timeduration: Duration in seconds
Example:
var parameters = new MaintenanceWindowCreateParameters
{
FriendlyName = "Weekly Maintenance",
Type = MaintenanceWindowType.Weekly,
StartTime = DateTimeOffset.Now.AddDays(1).ToUnixTimeSeconds(),
Duration = 3600 // 1 hour
};
await client.CreateMaintenanceWindowAsync(parameters);Endpoint: POST /v2/editMWindow
Library Method: UpdateMaintenanceWindowAsync()
Endpoint: POST /v2/deleteMWindow
Library Method: DeleteMaintenanceWindowAsync()
Public status pages display the status of your monitors publicly.
Endpoint: POST /v2/getPSPs
Library Method: GetStatusPagesAsync() or GetAllStatusPagesAsync()
Example:
await foreach (var page in client.GetAllStatusPagesAsync())
{
Console.WriteLine($"{page.FriendlyName}: {page.StandardUrl}");
}Endpoint: POST /v2/newPSP
Library Method: CreateStatusPageAsync()
Required Parameters:
friendly_name: Display namemonitors: Comma-separated monitor IDs
Example:
var parameters = new StatusPageCreateParameters
{
FriendlyName = "Public Status",
Monitors = "123456-789012",
CustomMessage = "Service status",
Sort = StatusPageSort.FriendlyNameAZ
};
await client.CreateStatusPageAsync(parameters);Endpoint: POST /v2/editPSP
Library Method: UpdateStatusPageAsync()
Endpoint: POST /v2/deletePSP
Library Method: DeleteStatusPageAsync()
| Type | Value | Description |
|---|---|---|
| HTTP(s) | 1 | Monitor HTTP/HTTPS endpoints |
| Keyword | 2 | Check for presence/absence of keyword |
| Ping | 3 | ICMP ping monitoring |
| Port | 4 | TCP port monitoring |
| Heartbeat | 5 | Heartbeat/push monitoring |
| Status | Value | Description |
|---|---|---|
| Paused | 0 | Monitoring is paused |
| Not Checked Yet | 1 | New monitor, not yet checked |
| Up | 2 | Monitor is up and responding |
| Seems Down | 8 | Monitor appears down (temporary) |
| Down | 9 | Monitor is confirmed down |
| Type | Value | Description |
|---|---|---|
| SMS | 1 | SMS notification |
| 2 | Email notification | |
| Twitter DM | 3 | Twitter direct message |
| Boxcar | 4 | Boxcar notification |
| Webhook | 5 | Custom webhook |
| Pushbullet | 6 | Pushbullet notification |
| Zapier | 7 | Zapier webhook |
| Pushover | 9 | Pushover notification |
| HipChat | 10 | HipChat notification |
| Slack | 11 | Slack webhook |
| Telegram | 13 | Telegram notification |
All API responses follow this structure:
{
"stat": "ok" | "fail",
"pagination": {
"offset": 0,
"limit": 50,
"total": 100
},
"monitors": [...],
"error": {
"type": "error_type",
"message": "error message"
}
}{
"stat": "ok",
"pagination": {
"offset": 0,
"limit": 50,
"total": 3
},
"monitors": [
{
"id": 777749809,
"friendly_name": "Google",
"url": "https://www.google.com",
"type": 1,
"sub_type": "",
"keyword_type": "",
"keyword_value": "",
"http_username": "",
"http_password": "",
"port": "",
"interval": 300,
"status": 2,
"create_datetime": 1468410324
}
]
}{
"stat": "fail",
"error": {
"type": "invalid_parameter",
"parameter_name": "id",
"passed_value": "abc",
"message": "The id parameter is required and must be an integer."
}
}The library provides custom exception types for different error scenarios:
try
{
await client.CreateMonitorAsync(parameters);
}
catch (UptimeRobotValidationException ex)
{
// Client-side validation failed
Console.WriteLine($"Validation error: {ex.Message}");
foreach (var result in ex.ValidationResults)
{
Console.WriteLine($"- {result.ErrorMessage}");
}
}
catch (UptimeRobotApiException ex)
{
// API returned an error
Console.WriteLine($"API error: {ex.Message}");
Console.WriteLine($"Error type: {ex.ErrorResponse?.Error?.Type}");
}
catch (UptimeRobotException ex)
{
// Other client errors (HTTP, network, etc.)
Console.WriteLine($"Request failed: {ex.Message}");
}The UptimeRobot API limits results to 50 items per request. This library provides two ways to handle pagination:
// Automatically fetches all results
await foreach (var monitor in client.GetAllMonitorsAsync())
{
// Process each monitor
}var offset = 0;
var limit = 50;
var total = 0;
do
{
var response = await client.GetMonitorsAsync(new MonitorSearchParameters
{
Offset = offset,
Limit = limit
});
foreach (var monitor in response.Monitors)
{
// Process monitor
}
total = response.Pagination.Total;
offset += limit;
}
while (offset < total);- Use Automatic Pagination: Leverage
GetAllXxxAsync()methods for simplicity - Handle Cancellation: Pass
CancellationTokento all async methods - Implement Retry Logic: Handle rate limiting with exponential backoff
- Cache API Keys: Don't hardcode API keys; use configuration or environment variables
- Log API Calls: Enable logging for debugging and monitoring
- Validate Parameters: Use strongly-typed enums and validation attributes
- Monitor Rate Limits: Track API usage to avoid hitting limits