Tutorial: Automate your SP-API Calls using a prebuilt C# SDK
Automate your SP-API calls using a prebuilt C# SDK.
This tutorial shows you how to install and integrate a prebuilt C# SDK. It also contains an example using the Sellers API.
Prerequisites
To complete this tutorial, you need:
- Integrated development environment (IDE) software
- Dotnet 7.0 or higher.
You must register your application and have a selling partner authorize your application before you can connect to the Selling Partner API. If you have not done this, follow these tutorials:
Once you have completed these steps, you can return to this tutorial.
Step 1. Add the C# SDK dependency to your application
Get the latest SDK version from the release version or NuGet, then add the C# SDK dependency to your application library config (.csproj) file.
<ItemGroup>
<PackageReference Include="software.amzn.spapi" Version="1.1.1" />
</ItemGroup>
Step 2. Connect the C# SDK to SP-API
To connect the C# SDK to the SP-API, you must:
- Configure your Login with Amazon credentials.
- Create an instance for a specific API client.
- Call an operation.
For an example, refer to the following sample code:
using RestSharp;
using software.amzn.spapi;
using software.amzn.spapi.Client;
using software.amzn.spapi.Api;
using software.amzn.spapi.Model;
using Amazon.SellingPartnerAPIAA;
using software.amzn.spapi.Api.sellers.v1;
using software.amzn.spapi.Model.sellers.v1;
using System.Threading;
// Configure your LWA credentials
LWAAuthorizationCredentials lwaAuthorizationCredentials = new LWAAuthorizationCredentials
{
ClientId = "yourClientId",
ClientSecret = "YourClientSecret",
RefreshToken = "YourRefreshToken",
Endpoint = new Uri("https://api.amazon.com/auth/o2/token")
};
// Create an instance of the Sellers API
SellersApi sellersApi = new SellersApi.Builder()
.SetLWAAuthorizationCredentials(lwaAuthorizationCredentials)
.Build();
// Call an operation
GetMarketplaceParticipationsResponse result = sellersApi.GetMarketplaceParticipations();
Console.WriteLine(result.ToJson());
You can now use this SDK to automate your calls to SP-API.
Report issues
You can report issues on GitHub.
Updated about 13 hours ago