Skip to content
Snippets Groups Projects
api-reference.md 21.16 KiB
title: GoShimmer API
language_tabs:
  - go: Go
  - shell: Shell
  - javascript--nodejs: Node.JS
  - python: Python
toc_footers: []
includes: []
search: true
highlight_theme: darkula
headingLevel: 2

GoShimmer API v0.1.0

The GoShimmer API provides a simple and consistent way to get transactions from the Tangle, get a node's neighbors, or send new transactions.
This API accepts HTTP requests and responds with JSON data.

Base URLs

All requests to this API should be prefixed with the following URL:

<a href="http://localhost:8080">http://localhost:8080</a>

POST /broadcastData

Creates a zero-value transaction and attaches it to the Tangle.

Creates a zero-value transaction that includes the given data in the signatureMessageFragment field and the given address in the address field.
This endpoint also does tip selection and proof of work before attaching the transaction to the Tangle.

Body parameters

{
  "address": "string",
  "data": "string"
}

Body parameters

Name Type Required Description
body object true Request object
» address string true Address to add to the transaction's address field.
» data string false Data to add to the transaction's signatureMessageFragment field.
The data must be no larger than 2187 bytes, and the address must contain only trytes and be either 81 trytes long or 90 trytes long, including a checksum.

Examples


Go

package main

import (
       "bytes"
       "net/http"
)

func main() {

    headers := map[string][]string{
        "Content-Type": []string{"application/json"},
        "Accept": []string{"application/json"},
        
    }

    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("POST", "http://localhost:8080/broadcastData", data)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}

cURL

# You can also use wget
curl -X POST http://localhost:8080/broadcastData \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json'

Node.js

const fetch = require('node-fetch');
const inputBody = '{
  "address": "string",
  "data": "string"
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json'

};

fetch('http://localhost:8080/broadcastData',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

Python

import requests
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

r = requests.post('http://localhost:8080/broadcastData', params={

}, headers = headers)

print r.json()

Response examples

200 Response

{
  "hash": "99IJMBGYVUAYAFAZFGAIVCFWMXP9WTDPX9JDFJLFKNUBLGRRHBERVTTJUZPRRTKKKNMMVX9PYGBKA9999"
}

Response examples

Status Meaning Description Schema
200 OK Successful response Inline
400 Bad Request Error response Inline

Response examples

Status Code 200

Field Type Description
» hash string The transaction's hash on the Tangle.

Status Code 400

Field Type Description
» message string The error message.

POST /findTransactionHashes

Gets any transaction hashes that were sent to the given addresses.

Searches the Tangle for transactions that contain the given addresses and returns an array of the transactions hashes that were found. The transaction hashes are returned in the same order as the given addresses. For example, if the node doesn't have any transaction hashes for a given address, the value at that index in the returned array is empty.

Body parameters

{
  "addresses": [
    "string"
  ]
}

Body parameters

Name Type Required Description
body object true Request object
» addresses [string] true Addresses to search for in transactions.
Addresses must contain only trytes and be either 81 trytes long or 90 trytes long, including a checksum.

Examples


Go

package main

import (
       "bytes"
       "net/http"
)

func main() {

    headers := map[string][]string{
        "Content-Type": []string{"application/json"},
        "Accept": []string{"application/json"},
        
    }

    data := bytes.NewBuffer([]byte{jsonReq})
    req, err := http.NewRequest("POST", "http://localhost:8080/findTransactionHashes", data)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}