Moonship API (1.3.0)

Download OpenAPI specification:Download

Moonship API Specification

Authentication

Authentication and session management

Login

Logs into the API. If successful, a session token will be returned in the response body and as a cookie. This must be returned to the API either in the Authorization request header as a bearer token or as a cookie to authorize future requests.

Request Body schema: application/json
required

The user credentials

user
string
password
string

Responses

Request samples

Content type
application/json
{
  • "user": "admin",
  • "password": "hello"
}

Response samples

Content type
application/json
{
  • "session_token": "52895534080d4460a45dc5e37fb0f8d5"
}

Logout

Logs out of the API.

header Parameters
Authorization
string
Example: Bearer: 52895534080d4460a45dc5e37fb0f8d5

The session bearer token. Required if the session token cookie is not sent.

Cookie
string
Example: __Host-session_token=52895534080d4460a45dc5e37fb0f8d5

The session token cookie. Required if the Authorization bearer token is not sent.

Responses

Response samples

Content type
application/json
{
  • "error": "Access denied",
  • "status": 401
}

Strategies

Trading strategy management

Get strategies list

Gets a list of trading strategy information. Query parameters can be used to filter the returned list based on certain criteria, e.g. "/strategies?engine=main&active=true". Query parameter names must match strategy information field names returned in the response.

header Parameters
Authorization
string
Example: Bearer: 52895534080d4460a45dc5e37fb0f8d5

The session bearer token. Required if the session token cookie is not sent.

Cookie
string
Example: __Host-session_token=52895534080d4460a45dc5e37fb0f8d5

The session token cookie. Required if the Authorization bearer token is not sent.

Responses

Response samples

Content type
application/json
{
  • "strategies": [
    ]
}

Get strategy

Gets information about the specified trading strategy.

path Parameters
Engine
string
Example: main

The trading engine name

Strategy
string
Example: BuyHighSellLow

The strategy name

header Parameters
Authorization
string
Example: Bearer: 52895534080d4460a45dc5e37fb0f8d5

The session bearer token. Required if the session token cookie is not sent.

Cookie
string
Example: __Host-session_token=52895534080d4460a45dc5e37fb0f8d5

The session token cookie. Required if the Authorization bearer token is not sent.

Responses

Response samples

Content type
application/json
{
  • "name": "BuyHighSellLow",
  • "engine": "main",
  • "active": true,
  • "start_time": "2024-03-10T11:53:35.593848+00:00",
  • "update_time": "2024-03-10T11:59:12.328174+00:00",
  • "last_trade_profit": -19.67,
  • "total_profit": -38.4,
  • "config": {
    }
}

Add strategy

Adds a new trading strategy. The request body must contain the strategy configuration properties specified in the same manner as they would be configured in the Moonship application configuration file.

path Parameters
Engine
string
Example: main

The trading engine name

Strategy
string
Example: BuyHighSellLow

The strategy name

header Parameters
Authorization
string
Example: Bearer: 52895534080d4460a45dc5e37fb0f8d5

The session bearer token. Required if the session token cookie is not sent.

Cookie
string
Example: __Host-session_token=52895534080d4460a45dc5e37fb0f8d5

The session token cookie. Required if the Authorization bearer token is not sent.

Request Body schema: application/json
required

The strategy configuration properties specified in the same manner as they would be configured in the Moonship application configuration file

required
object (StrategyConfigInfo)

The trading strategy configuration

Responses

Request samples

Content type
application/json
{
  • "config": {
    }
}

Response samples

Content type
application/json
{
  • "error": "Missing or bad strategy field",
  • "status": 400
}

Update strategy

Updates the specified trading strategy. If the strategy is currently active, the trading engine will attempt to stop it gracefully first before applying the update, and then restart it afterwards. The request body must contain one or more strategy configuration properties specified in the same manner as they would be configured in the Moonship application configuration file.

path Parameters
Engine
string
Example: main

The trading engine name

Strategy
string
Example: BuyHighSellLow

The strategy name

header Parameters
Authorization
string
Example: Bearer: 52895534080d4460a45dc5e37fb0f8d5

The session bearer token. Required if the session token cookie is not sent.

Cookie
string
Example: __Host-session_token=52895534080d4460a45dc5e37fb0f8d5

The session token cookie. Required if the Authorization bearer token is not sent.

Request Body schema: application/json
required

One or more strategy configuration properties specified in the same manner as they would be configured in the Moonship application configuration file

required
object (StrategyConfigInfo)

The trading strategy configuration

Responses

Request samples

Content type
application/json
{
  • "config": {
    }
}

Response samples

Content type
application/json
{
  • "error": "Missing or bad strategy field",
  • "status": 400
}

Remove strategy

Removes the specified trading strategy. If the strategy is currently active, the trading engine will attempt to stop it gracefully first.

path Parameters
Engine
string
Example: main

The trading engine name

Strategy
string
Example: BuyHighSellLow

The strategy name

header Parameters
Authorization
string
Example: Bearer: 52895534080d4460a45dc5e37fb0f8d5

The session bearer token. Required if the session token cookie is not sent.

Cookie
string
Example: __Host-session_token=52895534080d4460a45dc5e37fb0f8d5

The session token cookie. Required if the Authorization bearer token is not sent.

Responses

Response samples

Content type
application/json
{
  • "error": "Missing or bad strategy field",
  • "status": 400
}

Start strategy

Starts the specified trading strategy if it is not currently active.

path Parameters
Engine
string
Example: main

The trading engine name

Strategy
string
Example: BuyHighSellLow

The strategy name

header Parameters
Authorization
string
Example: Bearer: 52895534080d4460a45dc5e37fb0f8d5

The session bearer token. Required if the session token cookie is not sent.

Cookie
string
Example: __Host-session_token=52895534080d4460a45dc5e37fb0f8d5

The session token cookie. Required if the Authorization bearer token is not sent.

Responses

Response samples

Content type
application/json
{
  • "error": "Missing or bad strategy field",
  • "status": 400
}

Stop strategy

Stops the specified trading strategy if it is currently active.

path Parameters
Engine
string
Example: main

The trading engine name

Strategy
string
Example: BuyHighSellLow

The strategy name

header Parameters
Authorization
string
Example: Bearer: 52895534080d4460a45dc5e37fb0f8d5

The session bearer token. Required if the session token cookie is not sent.

Cookie
string
Example: __Host-session_token=52895534080d4460a45dc5e37fb0f8d5

The session token cookie. Required if the Authorization bearer token is not sent.

Responses

Response samples

Content type
application/json
{
  • "error": "Missing or bad strategy field",
  • "status": 400
}