[C# Tutorial] How to use Splinterlands Market API


Hi Splinterlands Community,

beside of my art work I'm also developing software and also spent some time with the splinterlands API. Today I want to show you a way on reading marked prices of individual Splinterland cards. In my example I will use Visual Studio and C# as programming language. I will also upload the complet Visual Studio Project at the end of my post.


1. The Market API


To use the API you also need to input 3 paramters:

    1. card_detail_id 
    2. gold 
    3. edition

As an example lets use the card "PLADO EMBERSTORM" in Normal (Non-Gold):

    1. card_detail_id=110 
    2. gold=false 
    3. edition=1

We finally fet this API URL:



2. Let's programm

Goal of this tutorial is to show how you transform the API raw data in a suitable data format. To do so we will store all offers in a List of offers.

    class JSonDownloadFormat
        public List<Root> offers { get; set; }

To read out all data from the API into single variables we will create also the Root class in way to match wit the available date, this is requried to use the JSON Desirializer later on.

    public class Root
        public int fee_percent { get; set; }
        public string uid { get; set; }
        public string seller { get; set; }
        public int card_detail_id { get; set; }
        public int xp { get; set; }
        public bool gold { get; set; }
        public int edition { get; set; }
        public string buy_price { get; set; }
        public string currency { get; set; }
        public object desc { get; set; }
        public string type { get; set; }
        public string market_id { get; set; }
        public int? last_transferred_block { get; set; }
        public DateTime? last_transferred_date { get; set; }
        public int? last_used_block { get; set; }
        public DateTime? last_used_date { get; set; }
        public string last_used_player { get; set; }

We are now able to download and parse all data from the API into our customer list. To do saw we just need few lines of code:

        static void Main(string[] args)
        string MyUrl = https://api.splinterlands.io/market/for_sale_by_card?card_detail_id=110&gold=false&edition=1";   
            string API_Response = new System.Net.WebClient().DownloadString(MyUrl);
            API_Response = "{\"offers\":" + API_Response + "}";
            JSonDownloadFormat JSonDownloadList = JsonConvert.DeserializeObject<JSonDownloadFormat>(API_Response);
            foreach (Root Offer in JSonDownloadList.offers)
                Console.WriteLine(Offer.xp.ToString() + " : " + Offer.buy_price.ToString() + "$");
            int Inpiut = Console.Read();

The code above will download the current offers, transfer it to our customer list, loop over all offers and output the offer XP* and price into the console. ( *XP is typically used to caluclate the BCX)

Let's have a look on the final output:



3. Summary

Having this data available in your own tool opens you many possibilities. I currently use it to track my favority cards for special discounts, which looks like this:


4. The Example Code



Wish you a great day! Appriciate all comments, follower or other kind of support!