Nexus Dev
Search…
βš™
Tritium++ Overview
Tritium++ API Overview

Nexus API Overview

Nexus provides several APIs to allow users and developers to easily interact with the functionality of the Nexus software stack. Each API is a logically grouped collection of methods that either interact with a specific part of the stack (e.g. ledger, registers), by functional area (accounts, assets, tokens), or by industry specific use case (supply, music).

Protocol

The API server uses the HTTP protocol and supports both GET and POST request methods.
The API's use JSON (JavaScript Object Notation) as their primary data transport mechanism for both input and output. However the API server also supports URL encoded requests (application/x-www-form-urlencoded).

Port

By default the API server runs on port 8080. This can be changed by setting apiport=xxxx in your nexus.conf or starting your daemon with the -apiport=xxxx parameter.

Security

The Nexus API uses the HTTP Basic authentication scheme. This requires the caller to set an Authorization HTTP header with the value Basic <credentials> with the <credendtials> portion set to apiuser:apipassword and base64 encoded. On the API server side the authentication is configured by adding apiuser=<username> and apipassword=<password> to the nexus.conf. NOTE: If you wish to disable authentication entirely, you can do so by setting apiauth=0 in your nexus.conf
The authentication mechanism is complemented by the implementation of SSL encryption (HTTPS). By default the API server is started with SSL disabled. To enable it, please add apissl=1 to your nexus.conf

Multi-user Sessions

The Nexus API can be configured to run in multiuser mode, allowing multiple signature chains to be logged in and use the API simultaneously. This feature can be enabled by setting multiuser=1 in your nexus.conf (default off). When multiuser is enabled, the initial login response will include a session ID value. This session ID must be then be included in all subsequent API calls to endpoints that require a user to be logged in.

Endpoint

Each API endpoint can be invoked through the following semantics:
<api>/<verb>/<noun>
e.g.
1
http://127.0.0.1:8080/ledger/get/block
Copied!
NOTE: URI's are always in lowercase.
​
​

Error Handling

In the event that an API call results in an error, a JSON object will be returned with the following format:
1
{
2
"error" :
3
{
4
"code" : -123,
5
"message" : "An error has occurred"
6
}
7
}
Copied!
DSL Error Codes
Code
Message
1
Query Syntax Error: duplicate wildcard not allowed
2
Query Syntax Error: only '=' and '!=' operator allowed for type [typename]
3
Query Syntax Error: malformed where clause at [clause]
4
Query Syntax Error: must use = with no extra characters.
5
Query Syntax Error: must use '(' and ')' to mix AND/OR statements
6
Query Syntax Error: missing logical operator for group
7
Query Syntax Error: empty where clause at [clause]
8
​
9
​
API Error Codes
Code
Message
-1
Method not available: [message]
-2
Method not found: [message]
-3
Method was deprecated at version [version]: [message]
-4
API not found (API name)
-5
Object not available: [message]
-6
content-type [content type] not supported
-7
Unsupported type [type] for parameters.
-8
Unable to Extract Input Address
-9
Session (session) doesn't exist
-10
Invalid session ID
-11
User not logged in
-12
Malformed or missing object encoding for [type]
-13
Object not found
-14
Malformed request URL
-15
Object is not an account or token
-16
Account has not been unlocked for transactions
-17
Failed to create transaction
-18
Invalid format for standard [name]
-19
Field [name] doesn't exist in object
-20
Field [name] is read-only and can't be updated