Skip to content

SDK

Configuration and setup of the SDK in C#.


We provide our SDK that simplifies integration with Mercado Eletrônico APIs and Webhooks, offering built-in authentication, retry handling, and rate limit control.

How to Install

powershell
dotnet add package ME.Api.Sdk

Dependency Injection

To use our SDK in your application, you can configure it in your dependency injection directly through IMEApiClient:

csharp
services.AddSingleton<IMEApiClient>(_ => new MEApiClient(new MEApiSettings {
  ClientId = "your_client",
  ClientSecret = "your_secret"
}));

Or using the AddMEApiClient method along with the MEApiSettings configuration section in you appsettings.json:

csharp
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMEApiClient(builder.Configuration);
json
{
  "MEApiSettings": {
    "BaseAddress": "https://api.mercadoe.com",
    "ClientId": "ClientId",
    "ClientSecret": "ClientSecret"
  }
}

Usage

To interact with our APIs, simply inject IMEApiClient and enjoy!

csharp
app.MapGet("/", async (IMEApiClient api, CancellationToken ctx) =>
{
   var preOrder = await api.PreOrderClient.GetPreOrderAsync(
     new GetPreOrderRequest { PreOrderId = "your_preorder_id" }
     , cancellationToken);
  return Ok(preOrder);
});