Soenneker.Loops.OpenApiClient
3.0.14
Prefix Reserved
dotnet add package Soenneker.Loops.OpenApiClient --version 3.0.14
NuGet\Install-Package Soenneker.Loops.OpenApiClient -Version 3.0.14
<PackageReference Include="Soenneker.Loops.OpenApiClient" Version="3.0.14" />
<PackageVersion Include="Soenneker.Loops.OpenApiClient" Version="3.0.14" />
<PackageReference Include="Soenneker.Loops.OpenApiClient" />
paket add Soenneker.Loops.OpenApiClient --version 3.0.14
#r "nuget: Soenneker.Loops.OpenApiClient, 3.0.14"
#addin nuget:?package=Soenneker.Loops.OpenApiClient&version=3.0.14
#tool nuget:?package=Soenneker.Loops.OpenApiClient&version=3.0.14
Soenneker.Loops.OpenApiClient
A Loops (loops.so) .NET client generated from their OpenAPI schema, updated daily
Installation
dotnet add package Soenneker.Loops.OpenApiClient
Authentication
To use the Loops API, you'll need an API key. You can generate one in the Loops dashboard under Settings → API. The API key should never be exposed client-side or to end users.
using Microsoft.Kiota.Http.HttpClientLibrary;
using Soenneker.Loops.OpenApiClient;
// Create an HTTP client with the API key
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer YOUR_API_KEY");
// Create the request adapter
var requestAdapter = new HttpClientRequestAdapter(httpClient);
// Instantiate the main client
var client = new LoopsOpenApiClient(requestAdapter);
Rate Limiting
The Loops API has a baseline rate limit of 10 requests per second per team. The API provides rate limit information in response headers:
x-ratelimit-limit
: Maximum requests per secondx-ratelimit-remaining
: Remaining requests in the current window
If you exceed the rate limit, you'll receive a 429 Too Many Requests response. Implement retry logic with exponential backoff to handle these cases.
Usage Examples
Managing Contacts
// Create a new contact
var contactRequest = new ContactRequest
{
Email = "user@example.com",
FirstName = "John",
LastName = "Doe",
UserProperties = new Dictionary<string, string>
{
{ "company", "Acme Inc" }
}
};
var contact = await client.Contacts.PostAsync(contactRequest);
// Find a contact
var contact = await client.Contacts.GetAsync(requestConfiguration =>
{
requestConfiguration.QueryParameters.Email = "user@example.com";
});
// Delete a contact
await client.Contacts.DeleteAsync(new ContactDeleteRequest
{
Email = "user@example.com"
});
Sending Events
// Send an event to trigger emails in loops
var eventRequest = new EventRequest
{
Email = "user@example.com",
EventName = "purchase_completed",
EventProperties = new Dictionary<string, string>
{
{ "product_id", "123" },
{ "amount", "99.99" }
}
};
var response = await client.Events.PostAsync(eventRequest);
Transactional Emails
// Send a transactional email
var transactionalRequest = new TransactionalRequest
{
TransactionalId = "your-transactional-id",
Email = "user@example.com",
DataVariables = new Dictionary<string, string>
{
{ "name", "John Doe" },
{ "order_id", "12345" }
}
};
var response = await client.Transactional.PostAsync(transactionalRequest);
// List published transactional emails
var transactionalEmails = await client.Transactional.GetAsync();
Managing Mailing Lists
// List all mailing lists
var mailingLists = await client.Lists.GetAsync();
Error Handling
The client throws appropriate exceptions for different error scenarios:
401 Unauthorized
: Invalid or missing API key429 Too Many Requests
: Rate limit exceeded400 Bad Request
: Invalid request parameters404 Not Found
: Resource not found
Example error handling:
try
{
var response = await client.Contacts.PostAsync(contactRequest);
}
catch (ApiException ex) when (ex.StatusCode == 429)
{
// Handle rate limiting
await Task.Delay(1000); // Implement exponential backoff
// Retry the request
}
catch (ApiException ex) when (ex.StatusCode == 401)
{
// Handle invalid API key
Console.WriteLine("Please check your API key");
}
Additional Resources
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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. |
-
net9.0
- Microsoft.Kiota.Http.HttpClientLibrary (>= 1.17.4)
- Microsoft.Kiota.Serialization.Form (>= 1.17.4)
- Microsoft.Kiota.Serialization.Json (>= 1.17.4)
- Microsoft.Kiota.Serialization.Multipart (>= 1.17.4)
- Microsoft.Kiota.Serialization.Text (>= 1.17.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Loops.OpenApiClient:
Package | Downloads |
---|---|
Soenneker.Loops.ClientUtil
An async thread-safe singleton for Loops OpenApiClient |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.14 | 53 | 2 days ago |
3.0.13 | 32 | 2 days ago |
3.0.12 | 30 | 2 days ago |
3.0.11 | 54 | 2 days ago |
3.0.10 | 33 | 2 days ago |
3.0.9 | 258 | 9 days ago |
3.0.8 | 218 | 13 days ago |
3.0.7 | 127 | 13 days ago |
3.0.6 | 186 | 14 days ago |
3.0.5 | 218 | 20 days ago |
3.0.4 | 259 | 23 days ago |
3.0.3 | 193 | a month ago |
3.0.2 | 129 | a month ago |
3.0.1 | 122 | a month ago |