NAV
shell javascript python

Introduction

Welcome to the DSTOQ API. Securities trading is only a few lines away. We'll onboard you with everything you'll need to know to build or integrate awesome trading experience of everything out there that can be tokenized.

It doesn't matter if you are a seasoned algorithmic trader or beginner in the field. We have accumulated crystal clear and easily adaptable examples for you.

Fintech or blockchain novice? Don't sweat, we'll explain the important concepts along the way.

Ping us @dstoq whenever you get stuck!

Prerequisites

curl https://api.dstoq.com/core/

# output:
# {"success":true,"message":"Hooray, we're here to deliver awesomeness!"}
import requests

data = requests.get('https://api.dstoq.com/core/').json()
print(data)

# output:
{'success': True, 'message': "Hooray, we're here to deliver awesomeness!"}
const axios = require('axios')

axios
  .get('https://api.dstoq.com/core/')
  .then(response => console.log(response.data))
  .catch(console.log)

// output:
{"success":true,"message":"Hooray, we're here to deliver awesomeness!"}

We prepared code snippets to onboard you ASAP. So before we start learning the concepts, let's give it a go!

Copy, paste & play a code snippet from the right side to get comfortable! You'll need the axios library for JavaScript or requests for python.

However: It's a REST API, it should be straightforward to adapt this to your needs & tooling. There are Stellar Wrappers for almost any language around.

All snippets use the stellar testnet and our staging infrastructure.

Basic Concepts

Securities trading is complicated, luckily we abstract away the heavy lifting to a few API endpoints.

DSTOQ is a trading facility platform where partner banks of ours can issue tokens representing securities. Those securities are held in custody by the bank which in turn is regulated and licenced to do so.

However, the D in DSTOQ stands for decentralized. This has a few implications with the important one being that we don't hold customers tokens. They are held on-chain.

Consequently, the customer needs to know something that no one else knows - a private key to verify ownership over assets and transactions need to be signed with said private key before it can be send to the underlying chain.

We'll explain the concept in more depth below and we have an additional section for best practises that will guide you through the process.

Authentication

curl -X POST -H "Content-Type: application/json" -d '{"username": "emailaddressofuser@dstoq.com", "password": "AVerySecretPassword"}' https://api.dstoq.com/accounts/auth/jwt/create/

# output
{
   "refresh": "... some refresh token ...",
   "access": ... some access token ..."
}
const axios = require('axios')

axios
  .post('https://api.dstoq.com/accounts/auth/jwt/create/', {
    username: 'emailaddressofuser@dstoq.com',
    password: 'AVerySecretPassword'
  })
  .then(response => console.log(response.data))
  .catch(console.log)

// output
{
   "refresh": "... some refresh token ...",
   "access": "... some access token ..."
 }
import requests

data = requests.post('https://api.dstoq.com/accounts/auth/jwt/create/', json={
  'username': 'emailaddressofuser@dstoq.com'
  'password': 'AVerySecretPassword'
}).json()
print(data)

# output
{
   "refresh": "... some refresh token ...",
   "access": "... some access token ..."
 }

This section explains how you can interact with the DSTOQ API as an existing customer. We'll explain how you can bring your own customer base to the platform and use a whitelabeld-DSTOQ version!

You can obtain a JWT token to use subsequent services that require authentication.

HTTP Request

POST https://api.dstoq.com/accounts/auth/jwt/create/

JSON Body

Parameter Description
email The email of the user.
password The password of the user.

The endpoint returns, among other information, a token that can be used to authenticate against the API. Subsequent calls must then send an Authorization header using the given token:

Authorization: JWT TOKEN_GOES_HERE

curl -H "Authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ4ODU4NTI4LCJqdGkiOiI3ZjcxZTIwYzE1YjE0MDJlODkyZGRkMTdlMWViODYwZCIsInVzZXJfaWQiOjEsInNjb3BlcyI6WyJmb28iLCJiYXIiLCJiYXoiXSwiaXNfc3RhZmYiOnRydWUsImlzX3N1cGVydXNlciI6dHJ1ZSwiYWRkaXRpb25hbCI6ImRhdGEifQ.fkcrKCBlmX4oDsCHy2CUgp-CEv_z2uFOvkrgZilQowurS0fQDrQDtmJu59JJJ4eCbSgLjo3HJovG6-UJ8B3gGwIOpP3mmkijvx-IDeJ44MOIzkGVO2MvhQhHSUCc2U0AQzgQRUhlI6zD7OUn5Vm8LN9AY0E3gg-OS3XmxmFN-MWC_QC93viT5f" https://api.dstoq.com/accounts/auth/users/me/

# output
{
    "country_code": "br",
    "email": "emailaddressofuser@dstoq.com",
    "kyc_status": "pending"
}


curl -H "Authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ4ODU4NTI4LCJqdGkiOiI3ZjcxZTIwYzE1YjE0MDJlODkyZGRkMTdlMWViODYwZCIsInVzZXJfaWQiOjEsInNjb3BlcyI6WyJmb28iLCJiYXIiLCJiYXoiXSwiaXNfc3RhZmYiOnRydWUsImlzX3N1cGVydXNlciI6dHJ1ZSwiYWRkaXRpb25hbCI6ImRhdGEifQ.fkcrKCBlmX4oDsCHy2CUgp-CEv_z2uFOvkrgZilQowurS0fQDrQDtmJu59JJJ4eCbSgLjo3HJovG6-UJ8B3gGwIOpP3mmkijvx-IDeJ44MOIzkGVO2MvhQhHSUCc2U0AQzgQRUhlI6zD7OUn5Vm8LN9AY0E3gg-OS3XmxmFN-MWC_QC93viT5f" https://api.dstoq.com/core/accounts/accounts/me/

# output
{
    "account_provider": 1,
    "country_code": "br",
    "email": "emailaddressofuser@dstoq.com",
    "first_name": "Christian",
    "has_deposited": true,
    "id": 19232,
    "last_name": "Peters",
    "public_key": "GCXETER4MRRY7WNOLIXETD6OZ46P6KGUMOORXF2JCJUXIKBW2BS6GZGA",
    "referral_short_link": "https://app.dstoq.com/9vUm",
    "signer_key": "GCXETER4MRRY7WNOLIXETD6OZ46P6KGUMOORXF2JCJUXIKBW2BS6GZGA",
    "status": "kyc_passed"
}

const axios = require('axios')

axios
  .create({
    headers: {'Authorization': 'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ4ODU4NTI4LCJqdGkiOiI3ZjcxZTIwYzE1YjE0MDJlODkyZGRkMTdlMWViODYwZCIsInVzZXJfaWQiOjEsInNjb3BlcyI6WyJmb28iLCJiYXIiLCJiYXoiXSwiaXNfc3RhZmYiOnRydWUsImlzX3N1cGVydXNlciI6dHJ1ZSwiYWRkaXRpb25hbCI6ImRhdGEifQ.fkcrKCBlmX4oDsCHy2CUgp-CEv_z2uFOvkrgZilQowurS0fQDrQDtmJu59JJJ4eCbSgLjo3HJovG6-UJ8B3gGwIOpP3mmkijvx-IDeJ44MOIzkGVO2MvhQhHSUCc2U0AQzgQRUhlI6zD7OUn5Vm8LN9AY0E3gg-OS3XmxmFN-MWC_QC93viT5f'}
  })
  .get('https://api.dstoq.com/accounts/accounts/user/')
  .then(response => console.log(response.data))
  .catch(console.log)

// output
{
    "country_code": "br",
    "email": "emailaddressofuser@dstoq.com",
    "kyc_status": "pending"
}

axios
  .create({
    headers: {'Authorization': 'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ4ODU4NTI4LCJqdGkiOiI3ZjcxZTIwYzE1YjE0MDJlODkyZGRkMTdlMWViODYwZCIsInVzZXJfaWQiOjEsInNjb3BlcyI6WyJmb28iLCJiYXIiLCJiYXoiXSwiaXNfc3RhZmYiOnRydWUsImlzX3N1cGVydXNlciI6dHJ1ZSwiYWRkaXRpb25hbCI6ImRhdGEifQ.fkcrKCBlmX4oDsCHy2CUgp-CEv_z2uFOvkrgZilQowurS0fQDrQDtmJu59JJJ4eCbSgLjo3HJovG6-UJ8B3gGwIOpP3mmkijvx-IDeJ44MOIzkGVO2MvhQhHSUCc2U0AQzgQRUhlI6zD7OUn5Vm8LN9AY0E3gg-OS3XmxmFN-MWC_QC93viT5f'}
  })
  .get('https://api.dstoq.com/core/accounts/accounts/me/')
  .then(response => console.log(response.data))
  .catch(console.log)

// output
{
    "account_provider": 1,
    "country_code": "br",
    "email": "emailaddressofuser@dstoq.com",
    "first_name": "Christian",
    "has_deposited": true,
    "id": 19232,
    "last_name": "Peters",
    "public_key": "GCXETER4MRRY7WNOLIXETD6OZ46P6KGUMOORXF2JCJUXIKBW2BS6GZGA",
    "referral_short_link": "https://app.dstoq.com/9vUm",
    "signer_key": "GCXETER4MRRY7WNOLIXETD6OZ46P6KGUMOORXF2JCJUXIKBW2BS6GZGA",
    "status": "kyc_passed"
}
import requests

data = requests.get('https://api.dstoq.com/accounts/accounts/user/', headers={
  'Authorization': 'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ4ODU4NTI4LCJqdGkiOiI3ZjcxZTIwYzE1YjE0MDJlODkyZGRkMTdlMWViODYwZCIsInVzZXJfaWQiOjEsInNjb3BlcyI6WyJmb28iLCJiYXIiLCJiYXoiXSwiaXNfc3RhZmYiOnRydWUsImlzX3N1cGVydXNlciI6dHJ1ZSwiYWRkaXRpb25hbCI6ImRhdGEifQ.fkcrKCBlmX4oDsCHy2CUgp-CEv_z2uFOvkrgZilQowurS0fQDrQDtmJu59JJJ4eCbSgLjo3HJovG6-UJ8B3gGwIOpP3mmkijvx-IDeJ44MOIzkGVO2MvhQhHSUCc2U0AQzgQRUhlI6zD7OUn5Vm8LN9AY0E3gg-OS3XmxmFN-MWC_QC93viT5f'
}).json()
print(data)

# output
{
    "country_code": "br",
    "email": "emailaddressofuser@dstoq.com",
    "kyc_status": "pending"
}

data = requests.get('https://api.dstoq.com/core/accounts/accounts/me/', headers={
  'Authorization': 'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ4ODU4NTI4LCJqdGkiOiI3ZjcxZTIwYzE1YjE0MDJlODkyZGRkMTdlMWViODYwZCIsInVzZXJfaWQiOjEsInNjb3BlcyI6WyJmb28iLCJiYXIiLCJiYXoiXSwiaXNfc3RhZmYiOnRydWUsImlzX3N1cGVydXNlciI6dHJ1ZSwiYWRkaXRpb25hbCI6ImRhdGEifQ.fkcrKCBlmX4oDsCHy2CUgp-CEv_z2uFOvkrgZilQowurS0fQDrQDtmJu59JJJ4eCbSgLjo3HJovG6-UJ8B3gGwIOpP3mmkijvx-IDeJ44MOIzkGVO2MvhQhHSUCc2U0AQzgQRUhlI6zD7OUn5Vm8LN9AY0E3gg-OS3XmxmFN-MWC_QC93viT5f'
}).json()
print(data)

# output
{
    "account_provider": 1,
    "country_code": "br",
    "email": "emailaddressofuser@dstoq.com",
    "first_name": "Christian",
    "has_deposited": true,
    "id": 19232,
    "last_name": "Peters",
    "public_key": "GCXETER4MRRY7WNOLIXETD6OZ46P6KGUMOORXF2JCJUXIKBW2BS6GZGA",
    "referral_short_link": "https://app.dstoq.com/9vUm",
    "signer_key": "GCXETER4MRRY7WNOLIXETD6OZ46P6KGUMOORXF2JCJUXIKBW2BS6GZGA",
    "status": "kyc_passed"
}

Try it with the user endpoint that gives you a few basic information about the user behind the given token:

HTTP Request

Auth Information

GET https://api.dstoq.com/accounts/accounts/user/

Trading Information

GET https://api.dstoq.com/core/accounts/accounts/me/

Assets

A trading flow is pretty straightforward to implement, as you don't have to wrestle with a lot of details.

Specifically if you want ...

Fortunately that can be done with only a few calls. Let's dive in.

Available Assets

curl https://api.dstoq.com/core/assets/assets/?trading_pair=USDC&time_span=LAST_HOUR

# output:
{
  "count": 11,
  "next": null,
  "previous": null,
  "results": [
   {
    "id": 1,
    "is_trading_pair": false,
    "code": "TSLA",
    "unicode": "",
    "issuer_name": "DSQ AG",
    "issuer": "GBRDHSZL4ZKOI2PTUMM53N3NICZXC5OX3KPCD4WD4NG4XGCBC2ZA3KAG",
    "custodian_name": "Mason PrivatBank",
    "asset_type": "credit_alphanum4",
    "display_decimals": 7,
    "name": "Tesla",
    "company_name": "Tesla, Inc.",
    "desc": "Tesla, Inc., designs, develops, manufactures and sells fully electric vehicles, and energy storage systems, as well as installs, operates and maintains solar and energy storage products. The Company operates through two segments: Automotive, and Energy generation and storage.",
    "image": "https://dstoq-prod-core-storage.s3.amazonaws.com/equities.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIASP7JDUVZ75NLNLGF%2F20210626%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20210626T090745Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X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78qZKaJVM6YNEmrBY3goazzmhnFOl%2FSnz9uLytevbnZ9GBB%2BmEFC07cBr2wfSukRvufLX5MDLQrkOCf3x5ttscqHVPx&X-Amz-Signature=b21ff619e53036c35d6de80c43dae8b34c9598d52368da9501f3fca1e35aadf5",
    "isin": "US88160R1014",
    "wkn": "88160R101",
    "product_class": "STOCK",
    "issuance_currency": "USD",
    "aggregation_time_span": "LAST_MONTH",
    "aggregations": [
      {
        "asset_volume": "0.0000142",
        "trading_pair_volume": "0.0099481",
        "avg": "700.5704225",
        "high": "700.5701160",
        "low": "700.5701160",
        "open": "700.5701160",
        "close": "700.5701160",
        "trade_count": 1,
        "timestamp": "2021-06-25T10:00:00"
      },
      ...  
    ],
    "can_be_traded": true
    },
    ...
  ]
}
const axios = require('axios')

axios.get('https://api.dstoq.com/core/assets/assets/?trading_pair=USDC&time_span=LAST_HOUR')
  .then(response => console.log(response.data))
  .catch(console.log)

// output:
{
  "count": 11,
  "next": null,
  "previous": null,
  "results": [
   {
    "id": 1,
    "is_trading_pair": false,
    "code": "TSLA",
    "unicode": "",
    "issuer_name": "DSQ AG",
    "issuer": "GBRDHSZL4ZKOI2PTUMM53N3NICZXC5OX3KPCD4WD4NG4XGCBC2ZA3KAG",
    "custodian_name": "Mason PrivatBank",
    "asset_type": "credit_alphanum4",
    "display_decimals": 7,
    "name": "Tesla",
    "company_name": "Tesla, Inc.",
    "desc": "Tesla, Inc., designs, develops, manufactures and sells fully electric vehicles, and energy storage systems, as well as installs, operates and maintains solar and energy storage products. The Company operates through two segments: Automotive, and Energy generation and storage.",
    "image": "https://dstoq-prod-core-storage.s3.amazonaws.com/equities.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIASP7JDUVZ75NLNLGF%2F20210626%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20210626T090745Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEGUaCWV1LXdlc3Qt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BB%2BmEFC07cBr2wfSukRvufLX5MDLQrkOCf3x5ttscqHVPx&X-Amz-Signature=b21ff619e53036c35d6de80c43dae8b34c9598d52368da9501f3fca1e35aadf5",
    "isin": "US88160R1014",
    "wkn": "88160R101",
    "product_class": "STOCK",
    "issuance_currency": "USD",
    "aggregation_time_span": "LAST_MONTH",
    "aggregations": [
      {
        "asset_volume": "0.0000142",
        "trading_pair_volume": "0.0099481",
        "avg": "700.5704225",
        "high": "700.5701160",
        "low": "700.5701160",
        "open": "700.5701160",
        "close": "700.5701160",
        "trade_count": 1,
        "timestamp": "2021-06-25T10:00:00"
      },
      ...  
    ],
    "can_be_traded": true
    },
    ...
  ]
}
import requests

data = requests.get('https://api.dstoq.com/core/assets/assets/?trading_pair=USDC&time_span=LAST_HOUR').json()
print(data)

# output:
{
  "count": 11,
  "next": null,
  "previous": null,
  "results": [
   {
    "id": 1,
    "is_trading_pair": false,
    "code": "TSLA",
    "unicode": "",
    "issuer_name": "DSQ AG",
    "issuer": "GBRDHSZL4ZKOI2PTUMM53N3NICZXC5OX3KPCD4WD4NG4XGCBC2ZA3KAG",
    "custodian_name": "Mason PrivatBank",
    "asset_type": "credit_alphanum4",
    "display_decimals": 7,
    "name": "Tesla",
    "company_name": "Tesla, Inc.",
    "desc": "Tesla, Inc., designs, develops, manufactures and sells fully electric vehicles, and energy storage systems, as well as installs, operates and maintains solar and energy storage products. The Company operates through two segments: Automotive, and Energy generation and storage.",
    "image": "https://dstoq-prod-core-storage.s3.amazonaws.com/equities.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIASP7JDUVZ75NLNLGF%2F20210626%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20210626T090745Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEGUaCWV1LXdlc3QtMSJIMEYCIQC2wllKb4%2BGCmiQmc6aneGCFg%2Bf%2BgPkT4ASNZq4N3FVvgIhAIykJ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d6de80c43dae8b34c9598d52368da9501f3fca1e35aadf5",
    "isin": "US88160R1014",
    "wkn": "88160R101",
    "product_class": "STOCK",
    "issuance_currency": "USD",
    "aggregation_time_span": "LAST_MONTH",
    "aggregations": [
      {
        "asset_volume": "0.0000142",
        "trading_pair_volume": "0.0099481",
        "avg": "700.5704225",
        "high": "700.5701160",
        "low": "700.5701160",
        "open": "700.5701160",
        "close": "700.5701160",
        "trade_count": 1,
        "timestamp": "2021-06-25T10:00:00"
      },
      ...  
    ],
    "can_be_traded": true
    },
    ...
  ]
}

This endpoints returns a list of all available assets on the DSTOQ platform.

It's paginated and gives you back previous and next urls (or null if they don't exist) along with the count.

HTTP Request

GET https://api.dstoq.com/core/assets/assets/

URL Params

Parameter Description Default
trading_pair The code of an asset that has is_trading_pair set to true. If not set, fields that require a complete trading pair won't populate (e.g. aggregations) -
time_span The time span as string that should be reflecte in aggregations, options are LAST_MONTH, LAST_WEEK, LAST_DAY, LAST_HOUR, LAST_YEAR. -
trading_pairs_only A value of 1 will return only trading pairs 0
securities_only A value of 1 will return only securities 0

Orderbook

curl https://api.dstoq.com/core/assets/assets/TSLA/orderbook/?trading_pair=USDC

# output
{
   "bids":[
      {
         "price":"682.8967320",
         "amount":"0.0916524"
      },
      ...
   ],
   "asks":[
      {
         "price":"683.4432680",
         "amount":"0.0685818"
      },
      ...
   ]
}
const axios = require('axios')

axios.get('https://api.dstoq.com/core/assets/assets/TSLA/orderbook/?trading_pair=USDC')
  .then(response => console.log(response.data))
  .catch(console.log)

// output
{
  "bids": [
    {
    "price": "0.0030390",
    "amount": "2905.9551378"
    },
    ...
  ],
  "asks": [
    {
    "price": "0.0031372",
    "amount": "2.3022122"
    },
    ...
  ]
}
import requests

data = requests.get('https://api.dstoq.com/core/assets/assets/TSLA/orderbook/?trading_pair=USDC')

# output
{
   "bids":[
      {
         "price":"682.8967320",
         "amount":"0.0916524"
      },
      ...
   ],
   "asks":[
      {
         "price":"683.4432680",
         "amount":"0.0685818"
      },
      ...
   ]
}

An orderbook is just a list of currents bids and asks for a trading pair against a security. Hence, one of your sides (buying or selling) needs to be a trading pair. Our samples are for USDC (a trading pair) against TSLA (a security).

HTTP Request

GET https://api.dstoq.com/core/assets/assets/<asset_code>/orderbook/?trading_pair=USDC

URL Params

All required URL params can be retrieved from the /core/assets call described above.

Parameter Description Required
trading_pair Code of the base currency that completes the trading pair Yes

Wallet

Balances

curl -X GET -H "Authorization: JWT $TOKEN" https://api.dstoq.com/core/accounts/accounts/me/balances/\?trading_pair\=USDC

# output
[
  {
        "balance": "0.4409302",
        "buying_liabilities": "0.2577763",
        "code": "FB",
        "estimated_total": "150.520342374",
        "image": "https://dstoq-prod-core-storage.s3.amazonaws.com/equities_Rpa76lQ.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIASP7JDUVZ75NLNLGF%2F20210626%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20210626T092133Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEGUaCWV1LXdlc3QtMSJIMEYCIQC2wllKb4%2BGCmiQmc6aneGCFg%2Bf%2BgPkT4ASNZq4N3FVvgIhAIykJM5CEnvNfyjP8iBWvIr%2BqX8sgtvWY9uuHAGIo2kgKosECD4QARoMMTcxNzUwNjk2MzA3Igz4i3pIVLp8Z%2FCFLyQq6AMbvpJGF9FhqaRgI%2FlZ6m1vvu0o02lh4MlgDiA9nBcYyYqRaev6UtL2udMaV3KTac83B13cRBMt%2BvLoZfed80gTSm38FbKTKRV9e%2FbfSWVCUcOlAlC0zetD0pYe9pHBraDpyKwjte7GQkZrSsGWCqnzFjP21WAX3djoXTy2fuNR%2FA%2BrWRFstjA0uqQrA5Av4OzUqB3Z4RatzDxy90iNpTgDRTYYAmnx8U%2BDZm7a9DErM2KUhu9J8Q3qCnHukQI70HWLfXR0tsc%2FUDGemDPvw8M6rBYsgFfBoPH015qD27i2R%2B0eNy4KFZIKaPnYF7k%2FzgE%2BsW0Mkr3y0RYoqepTdizHn7PjhFppEZjcwXVUwEsQvo6Ss9OMAgEKUDVbIk6k%2Fgmv2qNIAqsnAL8%2FRwVoBLIEB%2BsrbU61as9B%2BSWhBaGdXJgfETAz7FOxFZ9HidRk0y%2Ba6j3NYNPo0jzfKdJk2%2BKUOdfe%2FSzNSoSEH2BIyJWpVmsakeYo6OcBe3cdh8RUk2wp4eqFreadJTFG%2Bcn5a4nXdsrg7VVmTGjB9Jw2ZAzTH5Tl6NPOb7de%2BNfmbRK1yuSng6apjqYq6oR2jHFc9xzoBJfCEQSd2Ee9leqflrM3aNa7YkF6pHzX6oPqPhIhDYJED%2Fu53XC1EDCY5NqGBjqkAX5XCGspnZrXA5mrBdlmr7i%2Fs6Fhlz3rMm7Qlune%2B0YxiMDXbZ%2FQvDy3qgJ9TWa6%2F6P9qeXuaNI7iR%2B%2Bo%2BUQ4w9pzQwT6cVZn1AWurL7%2FMvTEeGn3lKKbDESaD4r%2FE0Ui78qZKaJVM6YNEmrBY3goazzmhnFOl%2FSnz9uLytevbnZ9GBB%2BmEFC07cBr2wfSukRvufLX5MDLQrkOCf3x5ttscqHVPx&X-Amz-Signature=c908c160ac8488ac72a6c0720690ab251c4542c6faa564263e56a73450901ead",
        "is_trading_pair": false,
        "name": "Facebook",
        "selling_liabilities": "0.3968371",
        "type": "asset"
    },
    ...
]
const axios = require('axios')

axios
  .create({
    headers: {'Authorization': `JWT ${TOKEN}`}
  })
  .get('https://api.dstoq.com/core/accounts/accounts/me/balances/?trading_pair=USDC')
  .then(response => console.log(response.data))
  .catch(console.log)

  // output
  [
  {
        "balance": "0.4409302",
        "buying_liabilities": "0.2577763",
        "code": "FB",
        "estimated_total": "150.520342374",
        "image": "https://dstoq-prod-core-storage.s3.amazonaws.com/equities_Rpa76lQ.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIASP7JDUVZ75NLNLGF%2F20210626%2Feu-west-1%2Fs3%2Faws4_request&X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w9pzQwT6cVZn1AWurL7%2FMvTEeGn3lKKbDESaD4r%2FE0Ui78qZKaJVM6YNEmrBY3goazzmhnFOl%2FSnz9uLytevbnZ9GBB%2BmEFC07cBr2wfSukRvufLX5MDLQrkOCf3x5ttscqHVPx&X-Amz-Signature=c908c160ac8488ac72a6c0720690ab251c4542c6faa564263e56a73450901ead",
        "is_trading_pair": false,
        "name": "Facebook",
        "selling_liabilities": "0.3968371",
        "type": "asset"
    },
    ...
]
import requests

data = requests.get(
  'https://api.dstoq.com/core/accounts/accounts/me/balances/?trading_pair=USDC',
  headers={'Authorization': f'JWT {TOKEN}'}
).json()
print(data)

# output
[
  {
        "balance": "0.4409302",
        "buying_liabilities": "0.2577763",
        "code": "FB",
        "estimated_total": "150.520342374",
        "image": "https://dstoq-prod-core-storage.s3.amazonaws.com/equities_Rpa76lQ.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIASP7JDUVZ75NLNLGF%2F20210626%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20210626T092133Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEGUaCWV1LXdlc3QtMSJIMEYCIQC2wllKb4%2BGCmiQmc6aneGCFg%2Bf%2BgPkT4ASNZq4N3FVvgIhAIykJM5CEnvNfyjP8iBWvIr%2BqX8sgtvWY9uuHAGIo2kgKosECD4QARoMMTcxNzUwNjk2MzA3Igz4i3pIVLp8Z%2FCFLyQq6AMbvpJGF9FhqaRgI%2FlZ6m1vvu0o02lh4MlgDiA9nBcYyYqRaev6UtL2udMaV3KTac83B13cRBMt%2BvLoZfed80gTSm38FbKTKRV9e%2FbfSWVCUcOlAlC0zetD0pYe9pHBraDpyKwjte7GQkZrSsGWCqnzFjP21WAX3djoXTy2fuNR%2FA%2BrWRFstjA0uqQrA5Av4OzUqB3Z4RatzDxy90iNpTgDRTYYAmnx8U%2BDZm7a9DErM2KUhu9J8Q3qCnHukQI70HWLfXR0tsc%2FUDGemDPvw8M6rBYsgFfBoPH015qD27i2R%2B0eNy4KFZIKaPnYF7k%2FzgE%2BsW0Mkr3y0RYoqepTdizHn7PjhFppEZjcwXVUwEsQvo6Ss9OMAgEKUDVbIk6k%2Fgmv2qNIAqsnAL8%2FRwVoBLIEB%2BsrbU61as9B%2BSWhBaGdXJgfETAz7FOxFZ9HidRk0y%2Ba6j3NYNPo0jzfKdJk2%2BKUOdfe%2FSzNSoSEH2BIyJWpVmsakeYo6OcBe3cdh8RUk2wp4eqFreadJTFG%2Bcn5a4nXdsrg7VVmTGjB9Jw2ZAzTH5Tl6NPOb7de%2BNfmbRK1yuSng6apjqYq6oR2jHFc9xzoBJfCEQSd2Ee9leqflrM3aNa7YkF6pHzX6oPqPhIhDYJED%2Fu53XC1EDCY5NqGBjqkAX5XCGspnZrXA5mrBdlmr7i%2Fs6Fhlz3rMm7Qlune%2B0YxiMDXbZ%2FQvDy3qgJ9TWa6%2F6P9qeXuaNI7iR%2B%2Bo%2BUQ4w9pzQwT6cVZn1AWurL7%2FMvTEeGn3lKKbDESaD4r%2FE0Ui78qZKaJVM6YNEmrBY3goazzmhnFOl%2FSnz9uLytevbnZ9GBB%2BmEFC07cBr2wfSukRvufLX5MDLQrkOCf3x5ttscqHVPx&X-Amz-Signature=c908c160ac8488ac72a6c0720690ab251c4542c6faa564263e56a73450901ead",
        "is_trading_pair": false,
        "name": "Facebook",
        "selling_liabilities": "0.3968371",
        "type": "asset"
    },
    ...
]

You can find out about the current balances that the user has in his or her wallet by querying this endpoint.

Useful information such as liabillities (part of the balance that is in pending offers) images and so on are included.

URL Params

Parameter Description Default
trading_pair If added, the estimated_total will give you the balance in the given base currecny. -

HTTP Request

GET https://api.dstoq.com/core/accounts/me/balances/

Offers

curl -X GET -H "Authorization: JWT $TOKEN" https://api.dstoq.com/core/accounts/accounts/me/offers/

# output
{
    "next_cursor": "663182819",
    "offers": [
        {
            "amount": "1.6147102",
            "asset": "D5BK",
            "asset_name": "EU Property  Fund",
            "offer_id": "663182843",
            "offer_type": "buy",
            "price": "36.9304857",
            "timestamp": "2021-06-26T09:26:49Z",
            "trading_pair": "USDC"
        },
        ...
    }
}
const axios = require('axios')

axios.get('https://api.dstoq.com/core/accounts/accounts/me/offers/')
  .then(response => console.log(response.data))
  .catch(console.log)

// output
{
    "next_cursor": "663182819",
    "offers": [
        {
            "amount": "1.6147102",
            "asset": "D5BK",
            "asset_name": "EU Property  Fund",
            "offer_id": "663182843",
            "offer_type": "buy",
            "price": "36.9304857",
            "timestamp": "2021-06-26T09:26:49Z",
            "trading_pair": "USDC"
        },
        ...
    }
}
import requests

data = requests.get('https://api.dstoq.com/core/accounts/accounts/me/offers/').json()
print(data)

# output
{
    "next_cursor": "663182819",
    "offers": [
        {
            "amount": "1.6147102",
            "asset": "D5BK",
            "asset_name": "EU Property  Fund",
            "offer_id": "663182843",
            "offer_type": "buy",
            "price": "36.9304857",
            "timestamp": "2021-06-26T09:26:49Z",
            "trading_pair": "USDC"
        },
        ...
    }
}

You can use this endpoint to retrieve the outstanding offers for this account.

URL Params

Parameter Description Default
cursor The api gives a next_cursor and/or a prev_cursur to retrieve the next page of results. -

HTTP Request

GET https://api.dstoq.com/core/accounts/me/offers/

Trades

curl -X GET -H "Authorization: JWT $TOKEN" https://api.dstoq.com/core/accounts/accounts/me/trades/

# output
{
    "next_cursor": "154950797858623518-0",
    "prev_cursor": "154959340548751390-0",
    "trades": [
        {
            "amount": "0.0000467",
            "asset": "GME",
            "asset_name": "GameStop",
            "offer_type": "sell",
            "price": "213.0151720",
            "timestamp": "2021-06-26T08:47:28Z",
            "trading_pair": "USDC"
        },
        ...
    ]
}  
const axios = require('axios')

axios.get('https://api.dstoq.com/core/accounts/accounts/me/trades/')
  .then(response => console.log(response.data))
  .catch(console.log)

// output
{
    "next_cursor": "154950797858623518-0",
    "prev_cursor": "154959340548751390-0",
    "trades": [
        {
            "amount": "0.0000467",
            "asset": "GME",
            "asset_name": "GameStop",
            "offer_type": "sell",
            "price": "213.0151720",
            "timestamp": "2021-06-26T08:47:28Z",
            "trading_pair": "USDC"
        },
        ...
    ]
}  
import requests

data = requests.get('https://api.dstoq.com/core/accounts/accounts/me/trades/').json()
print(data)

# output
{
    "next_cursor": "154950797858623518-0",
    "prev_cursor": "154959340548751390-0",
    "trades": [
        {
            "amount": "0.0000467",
            "asset": "GME",
            "asset_name": "GameStop",
            "offer_type": "sell",
            "price": "213.0151720",
            "timestamp": "2021-06-26T08:47:28Z",
            "trading_pair": "USDC"
        },
        ...
    ]
}

You can use this endpoint to retrieve the past trades for this account.

URL Params

Parameter Description Default
cursor The api gives a next_cursor to retrieve the next page of results. -

HTTP Request

GET https://api.dstoq.com/core/accounts/me/trades/

Trading

Submitting an order

curl -H "Authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ4ODU4NTI4LCJqdGkiOiI3ZjcxZTIwYzE1YjE0MDJlODkyZGRkMTdlMWViODYwZCIsInVzZXJfaWQiOjEsInNjb3BlcyI6WyJmb28iLCJiYXIiLCJiYXoiXSwiaXNfc3RhZmYiOnRydWUsImlzX3N1cGVydXNlciI6dHJ1ZSwiYWRkaXRpb25hbCI6ImRhdGEifQ.fkcrKCBlmX4oDsCHy2CUgp-CEv_z2uFOvkrgZilQowurS0fQDrQDtmJu59JJJ4eCbSgLjo3HJovG6-UJ8B3gGwIOpP3mmkijvx-IDeJ44MOIzkGVO2MvhQhHSUCc2U0AQzgQRUhlI6zD7OUn5Vm8LN9AY0E3gg-OS3XmxmFN-MWC_QC93viT5f" -X POST -H "Content-Type: application/json" -d '{"offer_type": "buy", "asset": "TSLA", "trading_pair": "USDC", "price": "412.12", "amount": "0.1"}' https://api.dstoq.com/core/sign/offer/

# Take the result an head to https://accountviewer.stellar.org/ to broadcast it to the stellar network.
const StellarSdk = require('stellar-sdk')
const server = new StellarSdk.Server('https://horizon-testnet.stellar.org')

const response = await axios
  .create({
    headers: {'Authorization': 'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ4ODU4NTI4LCJqdGkiOiI3ZjcxZTIwYzE1YjE0MDJlODkyZGRkMTdlMWViODYwZCIsInVzZXJfaWQiOjEsInNjb3BlcyI6WyJmb28iLCJiYXIiLCJiYXoiXSwiaXNfc3RhZmYiOnRydWUsImlzX3N1cGVydXNlciI6dHJ1ZSwiYWRkaXRpb25hbCI6ImRhdGEifQ.fkcrKCBlmX4oDsCHy2CUgp-CEv_z2uFOvkrgZilQowurS0fQDrQDtmJu59JJJ4eCbSgLjo3HJovG6-UJ8B3gGwIOpP3mmkijvx-IDeJ44MOIzkGVO2MvhQhHSUCc2U0AQzgQRUhlI6zD7OUn5Vm8LN9AY0E3gg-OS3XmxmFN-MWC_QC93viT5f'}
  })
  .post('https://api.dstoq.com/core/sign/offer/', {
    // can be 'buy' or 'sell'
    offer_type: 'buy',
    // Any asset, can as well be one that can be used as trading pair (e.g. USD as asset against EUR is a valid trading pair)
    asset: 'TSLA',
    // complete the trading pair
    trading_pair: 'USDC',
    // The price is ALWAYS determined in terms of the trading pair (base currency / asset) -
    // for 1 TSLA we are bidding 745.1321252 USD
    price: '745.1321252',
    // how much tsla do we want to buy
    amount: 0.1
  })

tx = StellarSdk.xdr.TransactionEnvelope.fromXDR(response.data.xdr, 'base64')
tx.sign(StellarSdk.Keypair.fromSecret(SECRET_PHRASE_OF_THE_USER))
await server.submitTransaction(tx)

import requests
from stellar_sdk import Keypair, TransactionEnvelope, Network, Server

keypair = Keypair.from_secret(SECRET_PHRASE_OF_THE_USER)
server = Server(horizon_url='https://horizon.stellar.org/')

payload = requests.post('https://api.dstoq.com/core/sign/offer/', json={
    # can be 'buy' or 'sell'
    'offer_type': 'buy',
    # Any asset, can as well be one that can be used as trading pair (e.g. USD as asset against EUR is a valid trading pair)
    'asset': 'TSLA',
    # complete the trading pair
    'trading_pair': 'USDC',
    # The price is ALWAYS determined in terms of the trading pair (base currency / asset) -
    # for 1 TSLA we are bidding 745.1321252 EUR
    'price': '745.1321252',
    # how much tsla do we want to buy
    'amount': 0.1
}, headers=headers).json()

# the payload contains an xdr - the format of the stellar network and is presigned by our service.
tx = TransactionEnvelope.from_xdr(payload['xdr'], network_passphrase=Network.PUBLIC_NETWORK_PASSPHRASE)

# now we must give consent for ourself by signing the transaction
tx.sign(keypair)

server = Server(horizon_url='https://horizon.stellar.org/')
server.submit_transaction(tx)

If you want to place a trade as a user you can simply submit to our offer endpoint. It'll give you a transaction back that you can sign using your private key and broadcast to the stellar network.

HTTP Request

POST https://api.dstoq.com/core/sign/offer

JSON Body

Parameter Description
offer_type either buy or sell - from the perspective of the asset
asset the asset code that you want to sell
trading_pair the base currency to complete the trading pair
price the price in terms of the trading pair (base currency / asset), e.g. for 1 TSLA we are bidding 1000 USD - the price is then 1000
amount the amount of the asset you want to buy - hence the total money spend of the base currency is price times amount

SEP-8

DSTOQ is as well fully compliant to the Stellar SEP-8 Standard. The SEP-8 Standard is well documented and implemented in wallets such as [LOBSTR(https://lobstr.co/) and Stellarport.

The SEP-8 endpoint does support a convenient way to onboard new customers via DSTOQs Customer Identification process.

If your app is as home in the Stellar Universe, head over to the SEP-8 documentation as a good starting point to implement trading.

Bring Your Own Customers

This guide will walk you from zero to hero into a full-featured whitboard trading solution with securities such as APPL, TSLA, S&P 500 and more.

If you run into problems, don't hesitate to contact support@dstoq.com. We're here to help!

API Setup

> ssh-keygen -t rsa -b 2048 -m PEM -f jwtRS256.key
> openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub

token = jwt.encode({
    'iss': ISSUER,
    'sub': ISSUER,
    'aud': 'DSTOQ',
    'iat': now(),
    'exp': now() + timedelta(days=30),
  }, SECRET_KEY_GOES_HERE, algorithm='RS256'
).decode()

In order to start integrating with DSTOQ you have to be a registered authentication provider. We need to have a small mutual contract in place and have to add you to our partner program. Our partner program has only one pricing plan: PREMIUM and it's 0$ including VAT. That's right: None, null, zero, zip, nil, nothing, void.

You can apply via a simple mail to tech@dstoq.com outlining your project and we'll come back to you shortly

The next thing is to provide us with an RSA-256 Public Key, that you will use to sign JSON-Web-Tokens to authenticate with our API:

Send jwtRS256.key.pub to us and use jwtRS256.key to authenticate against our API. We will then give you your ISSUER name.

Consequently, add an Authorization header to each request you make to our API: JWT YOUR_TOKEN_HERE.

That's all to get started.

Registering new users

endpoint = 'https://api.dstoq.com/core/accounts/providers/accounts/'
requests.post(endpoint, json={
    'email': 'awesome@dstoq.rocks',
    'public_key': SOME_PUBLIC_KEY
}, headers={'Authorization': f'JWT YOUR_TOKEN_HERE'))

The first step in registering a user is telling us her e-mail and the stellar public key.

Exchanging KYC information

endpoint = 'https://api.dstoq.com/core/accounts/providers/kyc-documents/`


# assume you have front_image, back_image and pdf_file as file-like object available
front_b64 = b64encode(front_image.read()).decode()
back_b64 = b64encode(back_image.read()).decode()
pdf_b64 = b64encode(pdf_file.read()).decode()

requests.post(endpoint, json={
    # the email is required to match the kyc to the user
    'email': 'awesome@dstoq.rocks,
    'first_name': 'John',
    'last_name': 'Doe',
    'kyc_provider': 'ONFIDO',
    'country_code': 'ng',
    'passport_front': f'data:image/jpeg;base64,{front_b64}',
    'passport_back': f'data:image/jpeg;base64,{back_b64}',
    'kyc_provider_report': f'data:application/pdf;base64,{pdf_b64}'
}, headers={'Authorization': f'JWT YOUR_TOKEN_HERE'))

The user is now in a pending state in our system and we are awaiting KYC information.

We require the email, first_name, last_name, and country_code of the user, the name of the kyc_provider you are using (supported ones are PASSBASE and ONFIDO, but we are willing to add more if you have the requirement for that) and a front and back image of the id document. Finally we need the report of KYC Provider as PDF. All binary documents need to be B64 encoded.

Awesome. We are now reviewing the KYC document as fast as possible - and that's very fast.

Webhook Integration

You can provide us with a Webhook URL where we can send you updates about the account, giving you the option to enhance the experience for the user.

We'll POST updates to this URL like this: YOUR_WEBHOOK_URL/{email_of_the_user}/{event_name}/, sometimes with additional (optional) information about the event as the POST body. If you want to secure this endpoint, you may as well give us an API-Key that we send alongside with the Authorization Header.

The following events are currently available:

Trading

import requests
from stellar_sdk import Server, TransactionBuilder, Network, TransactionEnvelope


APPROVAL_SERVER = 'https://dsq.technology/sep-8/tx-approve/'

server = Server(horizon_url='https://horizon.stellar.org')
builder = TransactionBuilder(server.load_account(PUBLIC_KEY_OF_THE_USER), Network.PUBLIC_NETWORK_PASSPHRASE)

tx_xdr = builder.append_manage_buy_offer_op(
    selling_code='USD',
    selling_issuer='GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX',
    buying_code='TSLA',
    buying_issuer='GBRDHSZL4ZKOI2PTUMM53N3NICZXC5OX3KPCD4WD4NG4XGCBC2ZA3KAG',
    amount='1.00',
    price='402.9721521'
).build().to_xdr()

xdr = requests.post(APPROVAL_SERVER, data={'tx': tx_xdr}).json()['tx']

envelope = TransactionEnvelope.from_xdr(xdr, Network.PUBLIC_NETWORK_PASSPHRASE)
envelope.sign(PRIVATE_KEY)
server.submit_transaction(envelope)

Trading can done via the SEP-0008-Protocol. It essentially means that you create a transaction, send it to the DSQ SEP-8 Endpoint, get it back and broadcast it to the stellar network.

A list of all available assets can be found in our API or in our Stellar TOML definitions.

Trading pairs need to have at least one base currency, defined as having the is_trading_pair flag set to true (and can_be_traded set to true).

Currently trading of all assets happens against USD-Dollars issued by Anchor USD.

Note, however, that you can as well use all the other endpoints (including the ones for trading) mentioned in this documentation.