8000 GitHub - Sohojoe/opensea-net: .NET 6 C# SDK for the OpenSea marketplace.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

.NET 6 C# SDK for the OpenSea marketplace.

License

Notifications You must be signed in to change notification settings

Sohojoe/opensea-net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



NuGet GitHub

.NET 6 C# SDK for the OpenSea marketplace API.

The API docs can be found here: https://docs.opensea.io/reference/api-overview

install

PM> Install-Package OpenSeaClient -Version 1.0.3

snippets

DI configuration:

builder.Services.AddHttpClient<IOpenSeaClient, OpenSeaHttpClient>(config =>
{
    config.DefaultRequestHeaders.Add("X-Api-Key", "<your_api_key_here>");
});

Get assets in batches of 50 with 1s delay between API calls to avoid throttling:

var client = new OpenSeaHttpClient(apiKey: "<your_api_key_here>");

var queryParams = new GetAssetsQueryParams
{
    CollectionSlug = collectionSlug,
};
var count = 0;
var limit = 50;
var it = 0;

var assetsList = new List<Asset>();

do
{
    queryParams.Offset = limit * it;
    queryParams.Limit = limit;

    var assets = await client.GetAssetsAsync(queryParams);

    if (assets != null)
    {
        if (assets.Count > 0)
        {
            assetsList.AddRange(assets);
        }
    }
    else
    {
        break;
    }

    await Task.Delay(1000);
}
while (count == 50);

Get the price of a token's sale order:

Note that the listing price of an asset is equal to the currentPrice of the lowest valid sell order on the asset. Users can lower their listing price without invalidating previous sell orders, so all get shipped down until they're canceled, or one is fulfilled.

var client = new OpenSeaHttpClient(apiKey: "<your_api_key_here>");

var orders = await client.GetOrdersAsync(new GetOrdersQueryParams
{
   AssetContractAddress = contractAddress,
   TokenId = tokenId,
   Side = 1,
   SaleKind = 0,
});

if (orders?.Any() == true)
{
    var order = orders.Where(x => x.Cancelled == false).OrderBy(x => x.CurrentPriceEth).FirstOrDefault();

    if (order != null)
    {
        Console.WriteLine($"Token {tokenId} has a sell order of {order.CurrentPriceEth} ETH");                   
    }
}

MIT License

About

.NET 6 C# SDK for the OpenSea marketplace.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%
0