Skip to content

API Reference

Avery-H edited this page Jun 26, 2018 · 86 revisions

The Disgo API is organized around REST. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. We support cross-origin resource sharing, allowing you to interact securely with our API from a client-side web application. JSON is returned by all API responses, including errors, although our API libraries convert responses to appropriate language-specific objects.

Errors

Disgo uses conventional HTTP response codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that failed given the information provided, and codes in the 5xx range indicate an error with Disgo's nodes (these are rare). Not all errors map cleanly onto HTTP response codes, however. When a request is valid but does not complete successfully, we return a 402 error code.

HTTP Status Code Summary

Status Code. Summary
200 - OK Everything worked as expected.
400 - Bad Request The request was unacceptable, often due to missing a required parameter.
401 - Unauthorized No valid API key provided.
402 - Request Failed The parameters were valid but the request failed.
404 - Not Found The requested resource doesn't exist.
409 - Conflict The request conflicts with another request
429 - Too Many Requests Too many requests hit the API too quickly. We recommend an exponential backoff of your requests.
500, 502, 503, 504 - Server Errors Something went wrong on Disgo's end. (These are rare.)

Types of Request

Request Description
RequestNewTransaction Send a New Transaction
RequestGetStatus Get Transaction Status
RequestGetAccount Get Account info
RequestGetTransactionsByAddress Get all transactions for an address

Transaction

This is an object representing your Disgo transfer of tokens, deployment of smart contract, and smart contract execution. These are our 3 different types of transactions, respectively 0, 1, and 2. Note that any parameter that says optional you should include, but leave as either an empty string or 0; with the exception of params which should be an if empty.

The transaction object

Attribute Type Description Optional Example
hash string SHA3 hash of the object NO "603378477301a29..."
type number The type of the transaction NO 0
from string Address of from where the tokens came from NO "7777f2b40aa..."
to string Address of where to transfer the tokens YES "c296220327589..."
value number Number of tokens to transfer YES 999
code string Smart contract deployment code YES "608060405234..."
abi string Smart contract guide YES "5b7b0a202..."
method string Name of Method being called YES "getVar5"
params JSON array Parameters for Method YES ["5555"] , or []
time string Time of the transfer formatted in ISO 1806 NO 1528923572369
Signature string Hash owner's signature NO "7b60acd9e8f972..."
hertz number Amount of bandwidth to use YES 0
fromName string From account nickname YES ""
toName string To account nickname YES ""

Create transaction object

Example request

curl -X POST -d '{"hash":"5abdb41f762ca24f1915fc217b70f59b9c164d96eaee36f2265df339b4fcceb0","from":"7777f2b40aacbef5a5127f65418dc5f951280833","to":"c296220327589dc04e6ee01bf16563f0f53895bb","value":100,"time":"2018-03-16T15:29:04.287216-07:00","signature":"38fbce7db5d744700cd3deb9162d6783e4fee32039d7bb0210d27e316fa69f3e5a965fa6a8ff1bc8d1f3dac793277e2321a0425d5deab7278bdcb61cc9f9537a00"}' 'http://localhost:1975/v1/transactions'

Example response

{
	"status": "OK",
	"transaction": {
		"hash": "603378477301a29ecb064bc5c806458b10bc4ef4b531b519fc9123ba07d02c6d",
                "type": 0,
		"from": "123f681646d4a755815f9cb19e1acc8565a0c2ac",
		"to": "553f681646d4a755815f9cb19e1acc8533a0c2ac",
		"value": 1,
		"time": "2018-02-25T11:40:23.367223-08:00"
	}
}

Checking on a transaction

Retrieve transactions objects

Example request

curl 'http://localhost:1975/v1/transactions/123f681646d4a755815f9cb19e1acc8565a0c2ac'

Example response

{
	"status": "OK",
	"transactions": [{
		"hash": "34962196b64999109c60701c5200ce4bae1f7b986fb38eb9518816584de637fe",
                "type": 0,
		"from": "123f681646d4a755815f9cb19e1acc8565a0c2ac",
		"to": "cc3f682246d4a755833f9cb19e1acc8565a0c2ba",
		"value": 2,
		"time": "2018-02-25T11:41:28.288582-08:00"
	}, {
		"hash": "f6c1270ccb2986ed582d1d46a850e68771184827814f733d4267ae514a7f0058",
                "type": 0,
		"from": "123f681646d4a755815f9cb19e1acc8565a0c2ac",
		"to": "cc3f682246d4a755833f9cb19e1acc8565a0c2ba",
		"value": 4,
		"time": "2018-02-25T11:41:28.288587-08:00"
	}]
}

Retrieve Balance

This endpoint retrieves the balance of the provided address.

Example request

curl 'http://localhost:1975/v1/balance/7777f2b40aacbef5a5127f65418dc5f951280833'

Example response

{
	"status": "OK",
	"balance": 10000
}
Clone this wiki locally