Spectre.AI Hyper-API v 2.0

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 incentivize the creation of high quality capital growth products for end-users. All earnings can be tracked in the Developer Portal.

Click here to view the documentation for version 1.1 Beta (deprecated).

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]


Codesnew

Response Codes 1 to 9 represent a successful request, Codes 10 and higher represent an error, further information about the error will be provided in the "msg" field.
May contain a "notify_message" field providing more information or example input on some methods.

If further information is needed on a received error, please contact support providing the Request, Response and AppId.


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

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

action string Method Name
data
account_type int Available account types: 1 = demo; 4 = Regular
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

AppDataDeFi() new

Summary of app usage

Retrieve data regarding the total users and total traded volume.

Parameters

action string Method Name
data
account_type int Available account types: 6 = DeFi
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

Assets()

List of available Assets

Retrieve list of all available assets.

Parameters

action string Method Name
data
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

UserData()

Get user data

Retreives user data and risk management settings.

Parameters

account_type int The user's Account Type from which the data is requested. Available account types are 1 = demo; 4 = Regular; 6 = DeFi
subaccount_type string DeFi token name (optional, required on `account_type`=6)
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

UserHistory()

Get user trading history

Retrieve history of trades, up to 100 per request.

Parameters

action string Method Name
data
account_type int Available account types: 1 = demo; 4 = Regular; 6 = DeFi
start_position int
end_position int
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

LiveTrades()

Get user's live trades

Retrieve live trades, up to 100 per request.

Parameters

action string Method Name
data
account_type int Available account types: 1 = demo; 4 = Regular; 6 = DeFi
start_position int
end_position int
asset_id int (Optional) retrieve live trades for a specific Asset ID
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

TradeDetails()

Get trade details

Retrieve data of a Closed trade

Parameters

action string Method Name
data
transaction_id int The transaction ID to be queried
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

OpenTrade()

Get trade details

Retrieve data of an Open trade

Parameters

action string Method Name
data
transaction_id int The transaction ID to be queried
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

ChartSubscribe() replaced

Replaced by MarketData()

NewTrade()New Options

Place new trade

Parameters

action string Method Name
data
account_type int Available account types: 1 = Demo; 4 = Regular; 6 = DeFi
subaccount_type string DeFi token name; required on DeFi account type
direction string Call / Put
asset_id int
expiration string Use the AvailableExpiries method to retrieve available expiries for any valid Asset ID; Use "C" for custom expirations
custom_expiration string Custom expirations can only be used if 'expiration' has been set to "C". Custom expiration Format: `xxh yym zzs`. ( xxhours yyminutes zzseconds)
investment float64 Investment amount for trade
min_payout int Specify minimum payout for trade entry; will return with error if the current payout is lower.
percentage int Investment value will be used as % of user balance; 1 to use percentage, 0 or undefined to use fixed amount
min_investment float64 Overwrite investment when % of user balance is too low. (when "percentage"=1)
max_investment float64 Overwrite investment when % of user balance is too high. (when "percentage"=1)
refid string Custom reference ID
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

AvailableExpiries()

List of available expiries

Request the available expiries for Asset ID

Parameters

action string Method Name
data
asset_id int
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

MaxInvestment()

Get max investment

Request the maximum investment for an Asset ID and expiration.

Parameters

action string Method Name
data
asset_id int
expiration string
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

GetPayout()

Get payout

Request the payout for an Asset ID, investment and expiration.

Parameters

action string Method Name
data
asset_id int
expiration string
investment float64
custom_expiration string Required on expiration "C"
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

ChartHistory()

Get chart historic candles

Request the historic candles for an Asset ID, output may differ based on the set period.

Parameters

action string Method Name
data
asset_id int
period string Available periodicities: 1, 5, 15, 60, 30, 24, "second"
  start int Start time as unix timestamp
  end int End time as unix timestamp
OR
  startpoint int Start candle count offset
  endpoint int End candle count offset; example starting from current position to 200 candles in the past:` "startpoint":0, "endpoint":200 `
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

ApplicationReport()

Retrieve Application Trading History

The response is within the boundaries of the set dates. When no start/end date parameters are present in the request, the response contains the trades for the current day.
Results are cached for 5 minutes; making another request, even with different start/end dates, will respond with the previously cached successful response.

Parameters

action string Method Name
data
start string Start Date Year-Month-Day
end string End Date Year-Month-Day
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

DisableRiskmanagement()

Change risk management status

Parameters

action string Method Name
data
disable int Available values: 1 to disable; 2 to enable.
token string Access Token
id int Request ID, response will return the ID value

Returns

array

TradeSetup()

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

Parameters

action string Method Name
data
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

PrepareTrade()New Options

Create a trade template valid for 30minutes

Parameters

action string Method Name
data
account_type int User's account type for which the trade to be placed. 1 = Demo; 4 = Regular ;6 = DeFi
subaccount_type string DeFi token name; required on DeFi account type
direction string Call / Put
asset_id int
expiration string See the API call below on how to pull the available expiration for given asset_id
min_payout int Specify minimum payout for trade entry; will return with error is the current payout is lower.
percentage int Investment value will be used as % of user balance; 1 to use percentage, 0 or undefined to use fixed amount
min_investment float64 Overwrite investment when % of user balance is too low. (when "percentage"=1)
max_investment float64 Overwrite investment when % of user balance is too high. (when "percentage"=1)
refid string Custom reference ID
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

PurchaseTrade()

Use trade template to place trades for multiple users simultaneously

Parameters

action string Method Name
data
id string id given by PrepareTrade
investment float64 Investment amount for current batch, applies to all trades unless a per-user amount is received
token(s) string Access Token of the user(s), comma separated values; A different investment per user can be set using "USER_TOKEN_1-INVESTMENT,USER_TOKEN_2-INVESTMENT2,.."
id int Request ID, response will return the ID value

Returns

Object

TradeSubscribe()

Receive notifications on trade status change

Parameters

action string Method Name
data
subscribe int 1 to enable, 2 to disable
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

BalanceSubscribe()New

Receive notifications on account balance changes

Parameters

action string Method Name
data
subscribe int 1 to enable, 2 to disable
token string Access Token
id int Request ID, response will return the ID value

Returns

Object

MarketDataSubscribe()New

Receive notifications on OHLC updates

Live MarketData feed

Parameters

action string Method Name
data
subscribe int 1 to enable, 2 to disable
asset_id int
period int Candle periodicity in seconds:
  • 1 # 1s
  • 3 # 3s
  • 5 # 5s
  • 10 # 10s
  • 30 # 30s
  • 60 # 1m
  • 300 # 5m
  • 900 # 15m
  • 1800 # 30m
  • 3600 # 1h
  • 14400 # 4h
  • 28800 # 8h
  • 86400 # 1d
token string Access Token
id int Request ID, response will return the ID value

Returns

Object