WebSocket API
Arkis provides a WebSocket API that delivers real-time maintenance updates on borrowings, including position details and the calculated risk factor. It uses the WebSocket protocol provided by the Centrifuge library. To receive real-time maintenance updates, use an official Centrifuge client. You will also need to generate an API key in the Arkis App settings and present it as a credential when connecting with the Centrifuge client. The sections below walk through each step and include development documentation.
Create a new API key
Go to "API Key Management" page.
Click on "Create API Key" button in the top right corner.
Enter a token name, select an expiration date from the predefined options or specify a custom date, and choose the desired permissions.
Click "Create API Key" to proceed.
The token is displayed only once. Make sure to copy it immediately and store it securely. Do not save the token in plain text files. If the token is lost or compromised, it must be manually revoked: Revoke an API key.
Integrate the API with the Centrifuge Client
Now that your token has been generated, you can use one of the official Centrifuge clients to subscribe to Arkis real-time maintenance updates.
Connection info
URL wss://api.arkis.xyz/e/v1/ws
Channel maintenance:wallet:{owner_wallet}
Examples
Below are examples in several popular programming languages. Replace <API TOKEN>
with your generated token. Never hardcode or commit the token to your codebase. Replace <OWNER WALLET>
with the address of wallet that was used to open the Margin Account.
import { Centrifuge } from 'centrifuge';
let centrifuge = new Centrifuge('wss://api.arkis.xyz/e/v1/ws', {
timeout: 5000, // Timeout for operations in milliseconds
debug: true, // Debug mode for observability while development is ongoing
token: '<API TOKEN>',
})
// Add event handlers for connection errors and disconnect
centrifuge.on('error', ctx => console.error("Connection error:", ctx))
centrifuge.on('disconnected', ctx => console.log("Disconnected: ", ctx))
// // Paste the address of the wallet used to open the Margin Account
const wallet = '<OWNER WALLET>'
// Create a new subcription for maintenance information
const subscription = centrifuge.newSubscription(`maintenance:wallet:${wallet}`)
// Assign handlers for the most important subscription events
// After the subscription is successfully established, you can access the publication history
subscription.on('subscribed', _ => {
// For demonstration purposes, the history limit is 100
// If you only need the most recent publication, set the limit to 1
subscription.history({ limit: 100 }).then(
// Print the most recent item from the history
ctx => console.log('History item:', ctx.publications.slice(-1)[0]),
err => console.error('History error: ', err)
)
})
// The 'publication' event is triggered whenever Arkis Risk Management publishes new maintenance information
subscription.on('publication', ctx => console.dir(ctx.data, { depth: null }))
// Other useful handlers
subscription.on('error', ctx => console.error(ctx))
subscription.on('unsubscribed', ctx => console.log(ctx))
subscription.on('state', ctx => console.log(ctx))
subscription.subscribe()
centrifuge.connect()
Revoke an API key
Only an Organization Admin can revoke an API key
Go to "API Key Management" page.
Locate the key by its name or tail (the last six characters of the key).
Click "Revoke".
Last updated