Use Livebook to open this notebook and explore new ideas.
It is easy to get started, on your machine or the cloud.
# JungleBus
```elixir
Mix.install(
[
{:bsv, "~> 2.1"},
{:httpoison, "~> 1.8"},
{:jason, "~> 1.3"},
],
config: [
bsv: [
network: :main
# network: :test
]
]
)
server_url = "https://junglebus.gorillapool.io"
```
## Consuming JungleBus Endpoints
https://junglebus.gorillapool.io/docs/
```elixir
txid = "A-TXID-GOES-HERE"
address = "AN-ADDRESS-GOES-HERE"
height = 800000
```
`GET /v1/transaction/get/:txid`
```elixir
url = "#{server_url}/v1/transaction/get/#{txid}"
```
```elixir
response = HTTPoison.get(url)
```
```elixir
{:ok, body} = response
```
```elixir
body.body |> Jason.decode!
```
## By Address
```elixir
url = "#{server_url}/v1/address/get/#{address}"
```
```elixir
response = HTTPoison.get(url)
{:ok, body} = response
body.body |> Jason.decode!
```
```elixir
url = "#{server_url}/v1/address/transactions/#{address}"
```
```elixir
response = HTTPoison.get(url)
{:ok, body} = response
body.body |> Jason.decode!
```
## Blocks
`GET /v1/block_header/get/:height`
```elixir
url = "#{server_url}/v1/block_header/get/#{height}"
```
```elixir
response = HTTPoison.get(url)
{:ok, body} = response
body.body |> Jason.decode!
```
`GET /v1/block_header/list/:height`
```elixir
url = "#{server_url}/v1/block_header/list/#{height}"
```
```elixir
response = HTTPoison.get(url)
{:ok, body} = response
body.body |> Jason.decode!
```
See source