ME.Api.Sdk
2.8.1
See the version list below for details.
dotnet add package ME.Api.Sdk --version 2.8.1
NuGet\Install-Package ME.Api.Sdk -Version 2.8.1
<PackageReference Include="ME.Api.Sdk" Version="2.8.1" />
paket add ME.Api.Sdk --version 2.8.1
#r "nuget: ME.Api.Sdk, 2.8.1"
// Install ME.Api.Sdk as a Cake Addin #addin nuget:?package=ME.Api.Sdk&version=2.8.1 // Install ME.Api.Sdk as a Cake Tool #tool nuget:?package=ME.Api.Sdk&version=2.8.1
ME.Api.Sdk
ME.Api.Sdk is a C# SDK that simplifies integration with Mercado Eletrônico APIs and Webhooks. It provides built-in authentication, retry handling, and rate-limit management, enabling a smoother and more efficient integration experience.
APIs Reference:: Mercado Eletrônico APIs
Requirements
.NET 6.0 or higher
Installation
To install the ME.Api.Sdk, use NuGet Package Manager with the following command:
dotnet add package ME.Api.Sdk
Alternatively, you can search for ME.Api.Sdk in the NuGet Package Manager in Visual Studio.
Getting Started
Dependency Injection Setup
To integrate the SDK into your application, you need to configure it through Dependency Injection (DI). Add the following code in your application's DI setup (typically in Program.cs or Startup.cs):
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMEApiClient(builder.Configuration);
// Retrieve the IMEApiClient from the service provider
var apiClient = serviceProvider.GetService<IMEApiClient>();
Configuration
Ensure that your appsettings.json
file contains the required API settings:
{
"MEApiSettings": {
"BaseAddress": "https://api.mercadoe.com",
"ClientId": "ClientId",
"ClientSecret": "ClientSecret"
}
}
This configuration allows the SDK to authenticate requests automatically.
Direct Instantiation (Optional)
If you prefer not to use Dependency Injection, you can instantiate the client directly:
var settings = new MEApiSettings
{
BaseAddress = "https://trunk.api.mercadoe.com",
ClientId = "ClientId",
ClientSecret = "ClientSecret"
};
var apiClient = new MEApiClient(settings);
Usage
To interact with the APIs, inject the IMEApiClient
and enjoy!
app.MapGet("/", async (IMEApiClient api, CancellationToken ctx) =>
{
var preOrder = await api.PreOrderClient.GetPreOrderAsync(
new GetPreOrderRequest { PreOrderId = "your_preorder_id" }
, cancellationToken);
return Ok(preOrder);
});
Features
- Integrated Authentication: Easily manage OAuth 2.0 authentication flows.
- Retry Policies: Automatic retries on transient failures.
- Rate-Limit Control: Manage API request limits effectively. For more details on the available API endpoints and usage examples, refer to the Mercado Eletrônico API documentation
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 was computed. 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. |
-
net6.0
- Microsoft.Extensions.Configuration (>= 6.0.0)
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 6.0.0)
- Polly (>= 7.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.