Skip to content

benscabbia/Ebay.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ebay.net

master
pipeline status

A client library for the ebay API targeting .NET standard 2.0.

Usage Examples

var client = new EbayClient("clientId", "clientSecret");
var item = await client.BrowseAPI.Item.GetItem("itemId");
var itemSearch = await client.BrowseAPI.ItemSummary.Search("drone", 10);

Supported APIs

Currently, only the Browse API is supported. Ebay.net follows the same hierarchical structure as the official documentation.

For instance, to call 'Get Item', you would do: client.BrowseAPI.Item.GetItem(<itemId>);


Getting started

Add the package:

dotnet add package Ebay.Net

Authentication

Ebay.net supports both Production and Sandbox environments. You set the Environment enum during initialisation of the client or authenticator like shown in examples below. The default is Environment.Production.

You will require your ClientID and your ClientSecret, which you can grab from here.

You authenticate via OAuth2 in any of the following ways:

// Simplest way is to pass your clientId and secret directly
var client = new EbayClient("clientId", "clientSecret", Environment.Production);

// Format specification: https://developer.ebay.com/api-docs/static/oauth-base64-credentials.html
// You can use https://www.base64encode.org and encode: yourClientId:yourClientSecret
var client = new EbayClient("base64encoded");

// Manually create and set the authenticator:
// You can also add your own implementation by implementing IOAuth2Authenticator
var auth = new OAuth2Authenticator("base64encoded");
var client = new EbayClient(auth);

Ebay.net will handle token expiration and renew for you.

Error and Exception Handling

Any error in the library will result in a generic EbayException. You can extract the message to determine the cause of the issue.

try 
{
    var client = new EbayClient(...);
    var item = await client.BrowseAPI.Item.GetItem("Fake-Item-Will-Throw-Exception");
}
catch(EbayException ex)
{
    var message = ex.Message;
    var stackTrace = e.InnerException;
}