A client library for the eBay API targeting .NET standard 2.0.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode added starter projects and files Sep 30, 2018
ebay.tests Added unit test to check correct exception is thrown Nov 30, 2018
ebay
.editorconfig added starter projects and files Sep 30, 2018
.gitignore added starter projects and files Sep 30, 2018
.gitlab-ci.yml Added gitlab ci Nov 3, 2018
LICENSE.md Initial commit Sep 30, 2018
README.md Updated readme Dec 9, 2018

README.md

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;
}