-
Notifications
You must be signed in to change notification settings - Fork 2
API
See also: Build-in Queries
Once the server is setup and running you can query the Server for information. The Client already implemented the connection setup and all Build-in Queries, but if you wish to build your own client (as opposed to your own UI, which can be build around the client) you can do so.
Assuming the RESTPORT has been enabled and API has the {APIVERSION: requesthandler} key you can query the server at the endpoint: http://serverhost.com:RESTPORT/any/extension/that/you/want/APIVERSION
(or https if you have TLS enabled). Both GET and POST requests are supported. The following response codes can be expected, aside from custom status codes of specific queries:
- 200: successful request (with data)
- 400: Missing api version/request method, invalid request format
- 405: invalid request method
- 413: payload of post request too large
- 500: successful request, but could not fulfill the request (with data)
- 501: api version not supported
GET request format:
- Option 1: Endpoint/{request type}?{request data as json}
- Option 2: Endpoint/{request type}?a=b&c=d (Same as if requesting with json {"a":"b","c":"d"}.)
- Option 3: Endpoint/{request type}?abc (Same as if requesting with json "abc".)
- Example for option 1:
https://coinversable.com/api/v1/transaction?%221234567890abcdef1234567890abcdef%22
(quotes from json string escaped as %22) - Example for option 3:
https://coinversable.com/api/v1/transaction?1234567890abcdef1234567890abcdef
POST request format:
- URL: Endpoint/{request type}
- Body: {request data as json}
- Example URL:
https://coinversable.com/api/v1/transaction
- Example body: "1234567890abcdef1234567890abcdef"
Response format if successful:
- code: 200
- Content-Type: application/json
- content: {json with the response data}
Reponse format if unsuccesful:
- code: 500
- context: A string with a description of the error.
Assuming the WSPORT has been enabled and API has the {APIVERSION: requesthandler} key you can query the server at the endpoint: ws://serverhost.com:WSPORT/any/extension/that/you/want/APIVERSION
(or wss if you have TLS enabled). The following close codes can be expected:
- 1001: Server shutting down or restarting
- 4100: Version of api not supported
Request format:
{
"type": "{request type}",
"id": "{any string that will be returned with the response}",
"data": {any data needed for the request type}
}
Example:
{
"type": "transaction",
"id": "abc123",
"data": "1234567890abcdef1234567890abcdef"
}
Response format if successful:
{
"id": "{the id that you send with the request}",
"data": {response data}
}
Response format if unsuccessful:
{
"id": "{the id that you send with the request}",
"error": "{A string with a description of the error}"
}
Push format (if a push is done):
{
"pushType": "{type}",
"data": {push data}
}