OpenAPI for Excel

This page documents the functionality of all worksheet functions provided by the OpenAPI for Excel add-in.

Generic Functions

This category includes all functions that perform basic, low-level HTTP interactions with Saxo's OpenAPI.

OpenAPIGet()

DescriptionGeneric function for sending a GET request to the OpenAPI.
UseWorksheet cells, VBA.
ArgumentsTypeDescriptionExample

Request

String

Path to the OpenAPI endpoint including query string parameters.

"/openapi/ref/v1/instruments/details/?AssetTypes=FxSpot&Uics=21"
FieldsStringList of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup.
"Description,Exchange.CountryCode,Format.OrderDecimals"

OpenAPIPost()

DescriptionGeneric function for sending a POST request to the OpenAPI.
UseWorksheet cells, VBA.
ArgumentsTypeDescriptionExample

Request

String

Path to the OpenAPI endpoint including query string parameters.

"/openapi/trade/v1/orders"

Body

String

JSON-structured string where double quotes are replaced by single quotes.

"{'AccountKey':'ABCDE12345',
'Amount':100000,
'AssetType':'FxSpot',
'BuySell':'Buy',
'OrderDuration':{'DurationType':'DayOrder'},
'OrderRelation':'Oco',
'OrderType':'Market',
'Uic':21}"

OpenAPIPut()

DescriptionGeneric function for sending a PUT request to the OpenAPI.
UseWorksheet cells, VBA.
ArgumentsTypeDescriptionExample

Request

String

Path to the OpenAPI endpoint including query string parameters.

"/openapi/trade/v1/positions/exercise"

Body

String

JSON-structured string where double quotes are replaced by single quotes.

"{'AccountKey':'ABCDE12345',
'Amount':100,
'AssetType':'StockOption',
'Uic':5455848}"

OpenAPIPatch()

DescriptionGeneric function for sending a PATCH request to the OpenAPI.
UseWorksheet cells, VBA.
ArgumentsTypeDescriptionExample

Request

String

Path to the OpenAPI endpoint including query string parameters.

"/openapi/trade/v1/orders/"

Body

String

JSON-structured string where double quotes are replaced by single quotes.

"{'AccountKey':'ABCDE12345',
'Amount':200.0,
'OrderDuration':{'DurationType':'GoodTillCancel'},
'OrderPrice':1264.0,
'OrderType':'Limit'}"

OpenAPIDelete()

DescriptionGeneric function for sending a DELETE request to the OpenAPI.
UseWorksheet cells, VBA.
ArgumentsTypeDescriptionExample

Request

String

Path to the OpenAPI endpoint including query string parameters.

"/openapi/trade/v1/orders/75646392/?AccountKey=ABCDE12345"

OpenAPIGetAsync()

DescriptionGeneric function for sending an asynchronous GET request to the OpenAPI.
UseWorksheet cells only.
ArgumentsTypeDescriptionExample

Request

String

Path to the OpenAPI endpoint including query string parameters.

"/openapi/ref/v1/instruments/details/?AssetTypes=FxSpot&Uics=21"

Fields

String

List of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup.

"Description,Exchange.CountryCode,Format.OrderDecimals"

OpenAPISubscribe()

DescriptionGeneric function for subscribing to the an OpenAPI endpoint.
UseWorksheet cells only.
ArgumentsTypeDescriptionExample

Uri

String

Path to the OpenAPI endpoint without query string parameters.

"/openapi/trade/v1/infoprices/subscriptions"

Arguments

String

List of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup.

"AssetType:FxSpot,Uics:21,22,23"

FieldGroups

String

List of comma-separated, case-sensitive FieldGroups to be retrieved from the OpenAPI.

"Quote,Exchange,Format"

Fields

String

List of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup.

"Description,Exchange.CountryCode,Format.OrderDecimals"

Utility Functions

This category includes all functions that service as shortcuts for standard API calls such as getting account keys and refreshing formulas.

OpenAPIGetAccountKey()

DescriptionShortcut function to simply obtaining a account key for a given AccountId. Defaults to the user's primary account.
UseWorksheet cells, VBA.
ArgumentsTypeDescriptionExample

AccountId

String

Optional: AccountId for the requested account.

"101234_USD"

OpenAPIGetAccountList()

DescriptionShortcut function to simply obtaining a list of accounts for a given ClientKey. Defaults to the ClientKey of the logged-in user.
UseWorksheet cells only.
ArgumentsTypeDescriptionExample

ClientKey

String

Optional: ClientKey for the requested client.

"X1JAJJAsjsdTMK3mBxzd-D2UA=="

OpenAPIGetAutoResize()

DescriptionGET function that resizes the output array in a worksheet automatically depending on the returned size.
UseWorksheet cells only.
ArgumentsTypeDescriptionExample

Request

String

Path to the OpenAPI endpoint including query string parameters.

"/openapi/ref/v1/instruments/details/?AssetTypes=FxSpot&Uics=21"
FieldsStringList of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup.
"Description,Exchange.CountryCode,Format.OrderDecimals"
HeadersBoolIndicator to instruct the resize formula to include a header row containing the field names of the requested fields.
TRUE

OpenAPIGetClientKey()

DescriptionShortcut function to simplify obtaining the ClientKey of the current logged-in user.
UseWorksheet cells, VBA.

OpenAPIGetContextId()

DescriptionShortcut function to simplify obtaining the ConextId of the current session (used internally for subscription functionality).
UseWorksheet cells, VBA.

OpenAPIRefreshCurrentSheetFormula()

DescriptionFunction that refreshes all OpenAPI and Excel formulas on the current sheet. Similar to how the Refresh button in the OpenAPI ribbon refreshes all cells.
UseWorksheet cells, VBA.

OpenAPIRefreshFormula()

DescriptionFunction that refreshes all OpenAPI and Excel formulas across every sheet in the workbook. Similar to how the Refresh button in the OpenAPI ribbon refreshes all cells.
UseWorksheet cells, VBA.