Splinterlands API. №1 - Баланс / Splinterlands API. №1 - Balance

avatar

Часто граю у Splinterlands але про певні речі до цього часу не знав. Як ви всі знаєте гра побудована на технології блокчейн, тому всі дії з картами (оренда, продаж, купівля і т.д.) являються загальнодоступними, а отже кожен може подивитись та перевірити правдивість інформації, яка його цікавить.

А як це зробити та де хтось знає? Ця і ще кілька статей будуть присвячені додатковим можливостям, які дають змогу гравцю отримати трохи більше інформації цілком легально. Цікаво? Ну тоді почнемо.

На сьогодні правилом хорошого тону в розробці будь-яких додатків, застосунків, ігор і т.д. є можливість використовувати так зване «API» (Application Programming Interface). Частенько вона взаємодіє через «JSON» файл. Технологія використовується у різних сферах. Це необхідно для комунікації користувача з сервером з метою обміну необхідною інформацією.

Оскільки ця стаття буде перша тому пропоную вибрати щось простеньке. До прикладу отримати інформацію про баланс гравця. Як я вже писав раніше інформація є публічно доступною тому ми не порушуємо ніяких правил і не використовуємо так звані «чіти».

Для отримання балансу будемо використовувати наступний запит:

https://api2.splinterlands.com/players/balances?username=detroyt31

detroyt31 - це нік гравця

Після переходу по цій адресі ми побачимо відповідь яку нам дав сервер.

1.png

Як ми бачимо тут є інформація про нік гравця, баланс різного роду токенів та час коли була нарахована остання винагорода. Зручно, але не комфортно шукати потрібне, особливо коли у вас багато токенів. Пропоную використати Google Spreadsheets для розв'язання цієї проблеми. Це дасть можливість отримувати дані онлайн, гнучко керувати вмістом та вести подальший обрахунок.

На жаль функції для роботи з JSON файлами в Google Spreadsheets немає, але ми використаємо ось цей Script.

Отож створюємо таблицю і вибираємо пункт «Розширення» -> «Apps Script»
2.jpg

Вставляємо повністю весь код та натискаємо дискету. Вказуємо довільну назву.
3.jpg

Повертаємось до вікна нашої таблиці та пишемо в довільну клітинку наступний текст:

=ImportJSON("https://api2.splinterlands.com/players/balances?username=detroyt31")

4.jpg

Маємо ось такий результат. Якщо трохи підкоректувати таблицю можна отримати щось типу такого.
5.jpg

Це може бути корисним тим хто має кілька ігрових акаунтів.

Надіюсь ця інформація стала для когось корисна)


I often play Splinterlands but I still didn't know about certain things. As you all know, the game is built on blockchain technology, so all actions with cards (rent, sale, purchase, etc.) are publicly available, so everyone can see and verify the truth of the information that interests him.

How to do it and where does anyone know? This and several other articles will focus on additional features that allow the player to get a little more information quite legally. Interesting? Well, then let's start.

Today the rule of thumb in the development of any application, game, etc. it is possible to use the so-called "API" (Application Programming Interface). It often interacts through the "JSON" file. The technology is used in various fields. This is necessary for the user to communicate with the server in order to exchange the necessary information.

Since this article will be the first, so I suggest you choose something simple. For example, get information about the player's balance. As I wrote earlier, the information is publicly available, so we do not violate any rules and do not use so-called "cheats".

To get the balance we will use the following query:

https://api2.splinterlands.com/players/balances?username=detroyt31

detroyt31 is a player's nickname

After going to this address, we will see the answer given to us by the server.
1.png

As we can see, there is information about the player's nickname, the balance of various tokens and the time when the last prize was accrued. It is convenient, but not comfortable to look for what you need, especially when you have a lot of tokens. I suggest using Google Spreadsheets to resolve this issue. This will allow you to receive data online, flexibly manage content and conduct further calculations.

Unfortunately there is no function for working with JSON files in Google Spreadsheets, but we will use this Script.

So create a table and select "Extensions" -> "Apps Script"
2.jpg

Insert all the code and click the floppy disk. Enter any name.
3.jpg

We return to the window of our table and write the following text in any cell:

=ImportJSON("https://api2.splinterlands.com/players/balances?username=detroyt31")

4.jpg

We have this result. If you tweak the table a bit, you can get something like this.
5.jpg

This can be useful for those who have multiple gaming accounts.

I hope this information was useful to someone)



0
0
0.000
2 comments
avatar

Congratulations @detroyt31! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You distributed more than 200 upvotes.
Your next target is to reach 300 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Support the HiveBuzz project. Vote for our proposal!
0
0
0.000