create account

Exploring Splinterlands API with a card search Discord bot by jazzhero

View this thread on: hive.blogpeakd.comecency.com
· @jazzhero ·
$13.21
Exploring Splinterlands API with a card search Discord bot
Trading Splinterland cards with a friend a week ago was a fun experience. It was much more gratifying than buying and selling cards in the marketplace. So it got me thinking if I could find more opportunities to acquire the cards that I want from my friends. I started looking for specific cards in their collection, but it was a long and tedious process that made me give up after several attempts. 

<br>
After recalling from somewhere or someone that there was a Splinterlands API ... it led to this.
<center>
![SplinterScry1.png](https://images.hive.blog/DQmbmWHezRjv2PsXyogTipjsMS4Y29gYDABfnWqWeFNqwxJ/SplinterScry1.png)</center>
<center>Of course, I am still looking for that Phantom Soldier from [my previous post](https://www.splintertalk.io/@jazzhero/my-first-splinterlands-card-trade).</center>


<br>
#### Splinter Scry Bot Command

After several minutes were wasted thinking of a name for the function, I decided on `splinterscry`. 'search' would have been more accurate but 'scry' sounded way cooler.
<br>
`!splinterscry` command first acquires your follower's list from Hive using [HiveSQL](https://hivesql.io/). I assumed if my followers aren't that bothered to see me on their feed, then it's likely they are at least tolerating me. I'll take that as an opening for a potential trade.

<br>
Once the bot has the list, it checks for the card collection of each user using this API endpoint: https://api.splinterlands.io/cards/collection/romeskie, where `romeskie` can be replaced with any Hive username. 
 
<br>
The bot lists down the quantity per level of the target players' collection. Cards that were delegated to other users or those that are being rented out are excluded from the list. It is possible to specify if you're looking for an *Alpha* or *Beta* edition. Recent cards such as in *Untamed* edition need not be specified in the bot commands, since all those beyond *Beta* are unique across all editions. It's also possible to search specifically for gold versions.
<br>
<center>![SplinterScry2.png](https://images.hive.blog/DQmXVG5qKRsrgmTP8CTT5xaBXgmZ5eNrcth9tbghfeLAQqt/SplinterScry2.png)
<sub>The results are so few. Either the card I'm searching for is very rare or I don't have many followers to search cards from. <i>It's the latter</i>.</sub>
</center> 
<br>


**Is this command available to HiveBotPH users?** Not at the moment. I'm still deciding and discovering more about the usage of this API so I'm unsure whether I should extend this beyond personal use. 

<br>
#### A fair use of the API?
Part of the reason why I posted this on my blog is to allow more experienced developers to cross-check the concept of this function. The bot function's goal feels so inconsequential so I was wary of using the API endpoints in the first place. But my desire to learn something new and the utility in searching for potential trades pushed me into exploring the API.

<br>
I purposely made the information gathering process longer to maintain what I think is the standard minimum API call rate of **60 requests per minute** (1 request/second). All the card details information was stored in code to minimize the request count -- the server keeps a permanent copy of this endpoint's data since it very rarely changes: https://api.splinterlands.io/cards/get_details 

<br>
*Any pointers or corrections with this prototype are greatly appreciated!*

<br><br>
#### Some acknowledgments

Thank you to the whole development team who gave third-party developers the tools to interact with Splinterlands. There's also this well-documented API endpoint information prepared by KioKizz found here: https://github.com/kiokizz/Splinterlands-API.  It has an organized list of all available endpoints and a better context of each endpoint's purpose. So thanks to KioKizz too!

For anyone who has questions with the bot, just drop a message in the comments section and I'll try to answer them as best as I can.

<br>
**Random trivia: There are currently 351 unique cards in Splinterlands! More to come when the Chaos Legion edition arrives! Head to [Splinterlands.com](https://splinterlands.com?ref=minnowlife) to start collecting!** 
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 68 others
properties (23)
authorjazzhero
permlinkexploring-splinterlands-api-with-a-card-search-discord-bot
categoryhive-13323
json_metadata"{"tags":["hive-13323","splintertalk","splinterlands","discordbot","hiveph"],"image":["https://images.hive.blog/DQmbmWHezRjv2PsXyogTipjsMS4Y29gYDABfnWqWeFNqwxJ/SplinterScry1.png","https://images.hive.blog/DQmXVG5qKRsrgmTP8CTT5xaBXgmZ5eNrcth9tbghfeLAQqt/SplinterScry2.png"],"links":["https://www.splintertalk.io/@jazzhero/my-first-splinterlands-card-trade"],"description":"A modest exploration of Splinterlands API with practical and humble results","format":"markdown","canonical_url":"https://www.splintertalk.io/@jazzhero/exploring-splinterlands-api-with-a-card-search-discord-bot","app":"splintertalk/1.0.0"}"
created2021-11-01 03:54:51
last_update2021-11-01 03:54:51
depth0
children4
last_payout2021-11-08 03:54:51
cashout_time1969-12-31 23:59:59
total_payout_value6.629 HBD
curator_payout_value6.582 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,150
author_reputation22,009,542,931,933
root_title"Exploring Splinterlands API with a card search Discord bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id107,425,480
net_rshares11,466,611,692,930
author_curate_reward""
vote details (132)
@adamada ·
$0.21
!discovery 20
👍  , ,
properties (23)
authoradamada
permlinkre-jazzhero-r1vncv
categoryhive-13323
json_metadata{"tags":["hive-13323"],"app":"peakd/2021.09.1"}
created2021-11-01 05:02:54
last_update2021-11-01 05:02:54
depth1
children0
last_payout2021-11-08 05:02:54
cashout_time1969-12-31 23:59:59
total_payout_value0.106 HBD
curator_payout_value0.106 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length13
author_reputation294,128,165,025,737
root_title"Exploring Splinterlands API with a card search Discord bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id107,426,603
net_rshares189,970,529,821
author_curate_reward""
vote details (3)
@discovery-it ·
<div class="pull-left">https://cdn.steemitimages.com/DQmTAn3c753LR7bHCLPo96g9UvRMaPFwaMYn8VQZa85xczC/discovery_logo_colore%20-%20Copia.png</div><br> This post was shared and voted inside the discord by the curators team of <a href="https://discord.gg/cMMp943"> discovery-it</a> <br>Join our community! <a href = "https://hive.blog/trending/hive-193212"> hive-193212</a><br>Discovery-it is also a Witness, vote for us <a href = "https://hivesigner.com/sign/account-witness-vote?witness=discovery-it&approve=true"> here</a>  <br>Delegate to us for passive income. Check our <a href = "https://hive.blog/hive-193212/@discovery-it/delegations-program-80-fee-back"> 80% fee-back Program</a> <hr>
properties (22)
authordiscovery-it
permlinkre-jazzhero-k2m8g5b89v
categoryhive-13323
json_metadata"{"app": "beem/0.24.26"}"
created2021-11-01 05:03:06
last_update2021-11-01 05:03:06
depth1
children0
last_payout2021-11-08 05:03:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length690
author_reputation67,254,602,513,346
root_title"Exploring Splinterlands API with a card search Discord bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id107,426,610
net_rshares0
@poshtoken ·
https://twitter.com/JazzHero1/status/1455507402581630976
<sub> The rewards earned on this comment will go directly to the person sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.</sub>
properties (22)
authorposhtoken
permlinkre-jazzhero-exploring-splinterlands-api-with-a-card-search-dis-8367
categoryhive-13323
json_metadata"{"app":"Poshtoken 0.0.1"}"
created2021-11-02 12:37:00
last_update2021-11-02 12:37:00
depth1
children0
last_payout2021-11-09 12:37:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length244
author_reputation5,294,099,705,734,474
root_title"Exploring Splinterlands API with a card search Discord bot"
beneficiaries
0.
accountreward.app
weight10,000
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id107,457,241
net_rshares0
@steemmonsters ·
$0.05
**Thanks for sharing! - @alokkumar121**
![](https://media.giphy.com/media/W4QD5qT1u6OJV1ENXU/giphy.gif)

👍  
properties (23)
authorsteemmonsters
permlinkre-exploring-splinterlands-api-with-a-card-search-discord-bot-20211106t082123z
categoryhive-13323
json_metadata"{"app": "beem/0.24.26"}"
created2021-11-06 08:21:24
last_update2021-11-06 08:21:24
depth1
children0
last_payout2021-11-13 08:21:24
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.025 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length105
author_reputation421,558,861,527,597
root_title"Exploring Splinterlands API with a card search Discord bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id107,544,068
net_rshares45,766,533,435
author_curate_reward""
vote details (1)