Spectre.AI Hyper-API v1.0 beta

Disclaimer: Spectre.ai's application programming interfaces (the “APIs”) allow developers to connect to the Spectre.ai trading platform in order to create, read and use content available inside the platform from within the developer's application or website. The beta version is still undergoing final testing before its official release. Spectre.ai does not give any warranties, whether express or implied, as to the suitability or usability of the API. Spectre.ai will not be liable for any loss, whether such loss is direct, indirect or consequential suffered by any party as a result of their use of the API. Any use of the API is done at the user's own risk and the user will be solely responsible for any issue that may arise. Should you encounter any bugs, glitches, lack of functionality or other problems, please let us know immediately at [email protected] so we can rectify these accordingly.

Compensation: Developers Earn 0.5% of all volumes and up to 30% of the payout of winning trades. This is to incentivise the creation of high quality capital growth products for end-users. All earnings can be tracked in the Developer Portal.

Authentication

Welcome to Spectre.ai API, which is now officially live! We are delighted to welcome all bot builders, auto-traders and developers. Here you will find all the information you need to get started immediately. The process is straightforward, and you should be able to extract all relevant data from the platform, including assets, users and trading history, while also being able to open trades on both demo and live accounts. If you have any questions, please email us at [email protected]


Web Application Flow

Partners looking to integrate with our API must create an account and register an application. To get the access token of the user, use the Web Flow below.
The oAuth token is served as a parameter while the Security Token is the public key of the Application.



Step 1 - Authorization

The authenticating web application should redirect users to the following URL: https://wss.hyper-api.com/authorize.php?

Parameters

app_id string Your Application ID
grant string Value is always "oauth"
response_type string Value is always "code"
client_id string You Application ID
state string An unguessable, cryptographically secure random string used to protect against cross-site request forgery attacks.

Returns

code

STEP 2 - Requesting a token

If the user accepts your request, Spectre will redirect the user back to your site with a temporary code and the previously provided state, as is.


This temporary code is valid for a duration of 5 minutes and can only be used once.
Your application is responsible for ensuring that the state matches the value previously provided, thus preventing a malicious third-party from forging this request.

You may then exchange this code for an access token using the following endpoint:
POST https://wss.hyper-api.com/token.php

Parameters

code string Code received from previous request
grant_type string Value should be "authorization_code"

Basic access authentication

When requesting a token, you must use HTTP Authentication in the request body.
user string Your Application ID
password string Your Application key

Returns

token

STEP 3 - Using the Access Token

Once you have obtained an access token you may call any protected API method on behalf of the user using the token parameter of the request.

Parameters

action string Request method, available methods are listed below
data string Request payload
token string Access token of the user/developer

Application authentication

When creating a request to the server, you must use include your public application ID in the Sec-WebSocket-Protocol.
Sec-WebSocket-Protocol string Your Application ID

Returns

Server Response

Methods

AppData()

Summary of app usage

Retrieve data regarding the total users and total traded volume.

Parameters

account_type string,int The user's Account Type from which the data is requested. Available account types are 1 = demo; 4 = Regular
token string Access Token of the developer

Returns

array

Assets()

List of available Assets

Retrieve list of all available assets.

Parameters

token string Access Token of the developer/user

Returns

multiarray

UserData()

Get user data

Retreives user data and risk management settings.

Parameters

account_type string,int The user's Account Type from which the data is requested. Available account types are 1 = demo; 4 = Regular
token string Access Token of the user

Returns

array

UserHistory()

Get user trading history

Retreives user's history of trades, up to 100 per request.

Parameters

account_type string,int The user's Account Type from which the data is requested. Available account types are 1 = demo; 4 = Regular
start_position string,int
end_position string,int
token string Access Token of the user

Returns

multiarray

LiveTrades()

Get user's live trades

Retreives user's live trades, up to 100 per request.

Parameters

account_type string,int The user's Account Type from which the data is requested. Available account types are 1 = demo; 4 = Regular
start_position string,int
end_position string,int
asset_id string,int (Optional) get live trades for only a specific Asset ID
token string Access Token of the user

Returns

multiarray

TradeDetails()

Get trade details

Retreives data of a Closed trade

Parameters

transaction_id string,int The transaction ID to be queried
token string Access Token of the user

Returns

array

OpenTrade()

Get trade details

Retreives data of a Open trade

Parameters

transaction_id string,int The transaction ID to be queried
token string Access Token of the user

Returns

array

ChartSubscribe()

Subscribe to tick data

Request tick data subscription to an asset_id or all available assets

Parameters

subscribe string,int 1/0. Use 1 to subscribe and 0 to unsubscribe
asset_id string,int (Optional) an existing asset_id in the request will subscribe only to specific asset pair, otherwise all tick data will be pushed
token string Access Token of the user/developer

Returns

multiarray

NewTrade()

Place new trade

Parameters

account_type string,int User's account type for which the trade to be placed. 1 = Demo; 4 = Regular
direction string Call / SELL
asset_id string,int
expiration string See the API call below on how to pull the available expiration for given asset_id | or use "C" for custom expirations
custom_expiration string Custom expirations can only be used if 'expiration' has been set to "C". a custom expiration must be given as `xh xm xs`. h,m,s meaning hour, minute, seconds. Each parameter can be given individually.
investment string,int Investment in current trade
refid string A reference ID for copy trading
token string Access Token of the user/developer

Returns

array

AvailableExpires()

List of available expiries

Request the available expiries of a given asset_id, those may differ from asset pair to another.

Parameters

asset_id string,int
token string Access Token of the user/developer

Returns

array

MaxInvestment()

Get max investment

Request the max investment for a asset_id/expiration combination. The output value represents the maximum investment in USD.

Parameters

asset_id string,int
expiration string
token string Access Token of the user/developer

Returns

string

GetPayout()

Get payout

Request the payout for a asset_id/expiration/investment combination. The output may differ based on asset pairs, expirations and investment values.

Parameters

asset_id string,int
expiration string
investment string,int
custom_expiry string (Optional) will be ignored if `expiration` is not set to 'C'
token string Access Token of the user/developer

Returns

string

ChartHistory()

Get chart historic candles

Request the historic candles for a given asset_id, output may differ based on the set period.

Parameters

asset_id string,int
period string,int May only be set to 0 (EPIC seconds periodicity), 1 (ALL, 1 min chart candles), 5 (ALL, 5 min chart candles), 15 (ALL, 15 min chart candles), 30 (ALL, 30 min chart candles), 60 (ALL, hourly chart candles), 24 (ALL, daily chart candles)
start string,int The timestamp of the start position, if EPIC (asset_ids 100,101,102) the timestamp is to be given in miliseconds
end string,int The timestamp of the end position, if EPIC (asset_ids 100,101,102) the timestamp is to be given in miliseconds
token string Access Token of the user/developer

Returns

multiarray

ApplicationReport()

Get report per Application ID, of the application the method is called from

Request the trades placed by an Application between two given dates, if no date given, return today's trades.

Parameters

start string Start Date Year-Month-Day
end string End Date Year-Month-Day
token string Access Token of the user/developer

Returns

multiarray

DisableRiskmanagement()

Set signal to disable the risk management of the user who belongs to the USER_TOKEN

Parameters

disable int Set Disable to 1 to disable, set Disable to 2 to enable.
token string Access Token of the user/developer

Returns

array

TradeSetup()

Will return the latest trade signals, for best performace, call this function every 5minutes

Parameters

token string Access Token of the user/developer

Returns

multiarray

PrepareTrade()

Create a trade template valid for 30minutes

Parameters

account_type string,int User's account type for which the trade to be placed. 1 = Demo; 4 = Regular
direction string Call / SELL
asset_id string,int
expiration string See the API call below on how to pull the available expiration for given asset_id
refid string Custom reference ID
token string Access Token of the user/developer

Returns

array

PurchaseTrade()

Use trade template to place trades for multiple users simultaneously

Parameters

id string id given by PrepareTrade
investment int Investment in current trade, applies for all trades
token(s) string Access Token of the user(s), comma separated values

Returns

multiarray

TradeSubscribe()

Receive transaction payload upon expiry

Parameters

subscribe string,int 1 to enable, 2 to disable
token string Access Token of the developer/user

Returns

confirmation messsage