Getting Started with BlockCypher APIs

A quick start guide

This guide will help you get started with BlockCypher! Learn how to create a BlockCypher API key, make your first request, do your first transaction on the BlockChain and get to building!


Steps to get started with BlockCypher APIs

In this short tutorial, you'll learn how to use BlockCypher APIs. Here are the steps that we are going to follow:

  1.  Get your free API token
  2.  Make a request
  3.  Create your first app
  4.  Start building

1.  Get your free API token

Getting a free API token is easy.

First create an account on our developer portal.

...
This is your developer account.

Copy-paste the token and save it somewhere. In this tutorial, we will always refer to our token as $TOKEN.

That's it, you have you free API token. Now, let's do our first request!


2.  Make a request

You can interact with the different blockchains through our BlockCypher infrastructure using a REST API. We assume here that you know how to use the terminal on your computer.

In this example, we are going to query the Bitcoin blockchain to know what is the current height and current block hash. We will do so from the terminal using curl.

Request

Response

Congrats! You did your first query on BlockCypher APIs. If you have no idea what you are you reading check out the Blockchain Object in the documentation.

Easy huh? And that's only the beginning! In our next section, we will build our first app using BlockCypher APIs.


3.  Create your first app

3.1 Setup

For this example, we are going to use BlockCypher Python SDK. We assume that you have a computer with Python3 installed.

First, let's install the library:

This should take a few seconds. After that, you're done with the installation part.

Now, let's create a Python file. We will call it start.py.

Now, open the file in your favorite text editor and write the following.

When running the code you should get something similar to the following (with a higher block height of course):

3.2 Generate a keypair

Now that we are comfortable with the SDK, let's generate a keypair. Just add the following line at the end of your file.

This query will generate a keypair containing a private key (hex and wif format), a public key and an address.

Now let's request some testnet coins.

3.2 Get testnet coins

Getting some testnet coins is easy. Just query our faucet by adding the following line to your test.py file.

This query will request 100000 bcy satoshis from the faucet. This query will generate a keypair containing a private key (hex and wif format), a public key and an address.

You can see this transaction on our BCY Explorer. Now let's do a transaction from this address.

3.3 Do a transaction

Doing a transaction using the python SDK is easy. We are going to send back 100 satoshis to the faucet. The faucet address is CFr99841LyMkyX5ZTGepY58rjXJhyNGXHf. Now let's add the following to our code:

Running all the above code should give you the following result:

Easy isn't it? You can see this transaction on our BCY Explorer.

3.4 Conclusion

Congrats! You just wrote your first blockchain app using BlockCypher APIs 🎉.

This was a short example on what you can do with the BlockCypher APIs. But here we've just scratched the surface.

Here this example was done with Python SDK but we have several SDK. Check it out!


4.  Start building

Now that you are familiar with the BlockCypher APIs, it's time to build!

Please read the official documentation for more info and if you have any questions contact us.

Want to explore more?