Practicing with the nextcolony api

in #nextcolony2 years ago

Captain's Log

Hello settlers, Today I've been practicing a bit about doing nextcolony api queries, this happened after seeing for a while the Jarunik's NC-client code in GitHub, I didn't really understand much, I don't know anything about Vuejs and I don't get along well with JS in general. But then I was reviewing the NextColony documentation and I found something I'm just learning, the api.

I want to clarify that I am not a programmer, but I am interested in learning, I do not have much free time or the best resources, but I am passionate about this and I will get it, I would like to learn what is necessary to collaborate in the development of steemapps and apparently nextcolony is one of those that allow this practice thanks to the work and documentation shared by developers like @jarunik.

Let's make some requests

The examples in the NextColony documentation are quite simple and explicit, for that we use the curl tool, if we do not have it installed in our system we can install it with the following command if you are using a system based on debian / ubuntu.

~$ sudo apt install curl

For other distributions, you must use the corresponding package manager.

Now with curl installed let's make the first example of the documentation but let's change the ID of the planet for the number 1, which is the ID of the planet earth.

~$ curl

And then the terminal will show us an object that contains the planet's information.

Let's do the same thing, but with python

Ok, but to be able to work with the information of the apis we have to treat them with some programming language, this way we can create variables and execute some action when some data takes a specific value, or to send the info to a database, etc. for this example we will use the language python.

First of all, to make a request with python we need the request module which we must install with pip, or pip3 as in my case because I will be working with python 3.

~$ pip3 install request

Once we have our module installed we create a text file named and write the following code.

import requests
request = request.get('')
print (request.json())

What does the code do? the first line imports our request module, in the second line we create a variable called request and assign the value that returns the API, and in the third line, we print the result in a .json object.

Now let's go to the terminal and run the script we just created.

~$ python3

As I explained earlier, having 2 types of python installed on my computer I must specify with which version of python I want to run the code, for this I have used python3.

the result is not very different from the one obtained in the exercise with curl, however this time we obtain a .json object which can be easily manipulated by a good amount of languages.

Just an experience

I know that maybe for many this is very simple, I just wanted to share a little of the things I have been practicing or learning by myself, it is not my intention to create a tutorial, but if like me you are a neophyte in programming and have learned something from this post I would be very happy.

I want to thank @jarunik infinitely for developing the client and for sharing the documentation of their work and the people of @nextcolony for developing the game and allowing the use of the API, I hope in the coming days to be learning a little more how to interact with them and the STEEM Blockchain in general.

All the images used in this post belong to the game NextColony, a spatial simulation game integrated to the STEEM Blockchain.

Thank you for reading and don't hesitate to leave your comment.


Hi, @darthgexe!

You just got a 1.62% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.