Introduction
Welcome to the Dgtmarket API! You can use our API to access Your Dgtmarket account.
We have language bindings in Shell and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
API URL
API base URL for all endpoints is:
BASE_URL: https://dgtmarket.com/api
Use this URL as a prefix for the endpoints described in this documentation. Currently there is no sandbox instance of the API.
Available pairs
For API endpoints available pairs are: BTCPLN, LTCPLN, LTCBTC
Throttling
API has rate limits set to 60 requests per minute for public endpoints and up to 100 requests per minute for private endpoints. If rate limit is exceeded, server will response 429 Too Many Requests status code.
Public
Ticker
Example Request
curl "https://dgtmarket.com/api/public/ticker24/BTCPLN/"
Example Response
{
"ask": "2652.50000000",
"bid": "2640.00000000",
"high": "2642.59000000",
"last": "2642.59000000",
"low": "2576.44000000",
"volume": "8.50726555"
}
This endpoint retrieves ticker 24h.
HTTP Request
GET /public/ticker24/:pair/
URL Parameters
Parameter | Default | Description |
---|---|---|
pair | false | One of the available pairs. |
List Offers
Example Request
curl "https://dgtmarket.com/api/public/offers/BTCPLN"
Example Response
{
"asks": [
{
"amount": "0.28889603",
"any_price": false,
"quotation": "2640.00000000"
},
{
"amount": "0.23111682",
"any_price": false,
"quotation": "2648.00000000"
}
],
"bids": [
{
"amount": "0.41148783",
"any_price": false,
"quotation": "2590.00000000"
},
{
"amount": "0.00787401",
"any_price": false,
"quotation": "2540.00000000"
}
]
}
This endpoint retrieves aggregated offers in the orderbook. It returns maximum 30 best entries in each ‘bids’ and 'asks’ tables ordered by quotation.
HTTP Request
GET /public/offers/:pair/
URL Parameters
Parameter | Default | Description |
---|---|---|
pair | false | One of the available pairs. |
List Transactions
Example Request
curl "https://dgtmarket.com/api/public/transactions/BTCPLN/"
Example Response
[
{
"amount": "0.03311129",
"date": "1469385205",
"price": "2642.59000000",
"tid": 7557
},
{
"amount": "0.07680608",
"date": "1469384081",
"price": "2630.00000000",
"tid": 7556
},
{
"amount": "0.04765030",
"date": "1469383603",
"price": "2586.93000000",
"tid": 7555
}
]
This endpoint retrieves last 30 transactions ordered by date.
HTTP Request
GET /public/transactions/:pair/
URL Parameters
Parameter | Default | Description |
---|---|---|
pair | false | One of the available pairs. |
Private
Private API allows users to manage their accounts. Calling private API requires using authentication mechanism described in a sections below. This mechanism includes 3 main steps:
- Enabling API
- Generating API keys
- Synchronizing time with a server
- Authenticating requests
Authentication
Enabling API
This is step 0. Actually to enable private API you have to send us an e-mail (kontakt [at] dgtmarket.com or pomoc [at] dgtmarket.com) with API enabling request. After that you will have possibility to generate API keys throught the get token endpoint.
Get API keys
When your private API is enabled you can generate API keys. Calling this endpoint once again will revoke previous generated keys.
Example Request
r = requests.post('https://dgtmarket.com/api/public/token/',
data={'username': 'john', 'password': 'secret'}
)
r = r.json()
key, secret = r['key'], r['secret']
curl "https://dgtmarket.com/api/public/token/"
-X POST -d "username=john" -d "password=secret"
Example Response
{
"key": "eiPe0nouwohghaujaiy1yievei2osai7keeriedo",
"secret": "eiTahahBuaniz9peekuk7ohpi8einuiPhaeji1Oo"
}
HTTP Request
GET /public/token/
Query Parameters
Parameter | Default | Description |
---|---|---|
username | false | Username. |
password | false | Password. |
Get Time
Returns server’s time in Unix epoch format.
curl https://dgtmarket.com/api/public/time/
Example Response
{
"epoch": 1469386936
}
HTTP Request
GET /public/time/
Authenticating requests
import hmac
import hashlib
import time
import requests
from requests.auth import AuthBase
class DgtmarketApiAuth(AuthBase):
def __init__(self, key, secret):
self.key = key
self.secret = secret
def __call__(self, request):
timestamp = str(int(time.time()))
message = timestamp + request.method + request.path_url + (request.body or '')
signature = hmac.new(str(self.secret), message, hashlib.sha256).hexdigest()
request.headers.update({
'ACCESS-SIGN': signature,
'ACCESS-TIMESTAMP': timestamp,
'ACCESS-KEY': self.key,
})
return request
# create DgtmarketApiAuth callable instance
auth = DgtmarketApiAuth('you_api_key', 'your_secret_key')
# example private API request using auth. Using verify=False to simplify.
r = requests.get('https://dgtmarket.com/api/private/wallets/', auth=auth, verify=False)
All requests to the private API have to be properly signed and requests have to include headers listed below:
- ACCESS-KEY The api key as a string
- ACCESS-SIGN The user generated message signature (see below)
- ACCESS-TIMESTAMP A timestamp for your request
All request bodies should have content type application/json and be valid JSON.
The ACCESS-SIGN header is generated by creating a sha256 HMAC using the secret key on the prehash string timestamp + method + requestPath + body (where + represents string concatenation). The timestamp value is the same as the ACCESS-TIMESTAMP header.
The body is the request body string or omitted if there is no request body (typically for GET requests).
The method should be UPPER CASE.
The ACCESS-TIMESTAMP header MUST be number of seconds since Unix Epoch.
Your timestamp must be within 30 seconds of the api service time or your request will be considered expired and rejected. We recommend using the time endpoint to query for the API server time if you believe there many be time skew between your server and the API servers.
Wallets
List wallets
Example response
[
{
"outgoing_address": null,
"currency": "LTC",
"balance": "0.00000000",
"incoming_address": "LeZNStaj1q8eseLa9Gqr8nvwp4iaGiX6rU",
"blocked": "0.00000000"
},
{
"outgoing_address": null,
"currency": "BTC",
"balance": "0.33759934",
"incoming_address": "1JKhwNU45UE2j1f4CaEQLSHnPbycKqCKzG",
"blocked": "0.00000000"
},
{
"outgoing_address": null,
"currency": "PLN",
"balance": "0.01557254",
"incoming_address": "78 1010 1023 0000 2613 9520 0000",
"blocked": "0.00000000"
}
]
Get a list of user’s wallets.
HTTP Request
GET /private/wallets/
Offers
Place New Offer
data = {
'pair': 'btcpln',
'amount': 0.001,
'quotation': 2570,
'order_type': 'buy'
}
r = requests.post(server_address + '/private/offers/', auth=auth, data=data)
Example response
{
"any_price": false,
"activation_limit": "0.00000000",
"order_type": "BUY",
"amount": "0.00100000",
"pair": "BTCPLN",
"id": 17167,
"quotation": "2570.00000000"
}
HTTP Request
POST /private/offers/
Paremeters
Parameter | Description |
---|---|
pair | One of the available pairs |
order_type | BUY or SELL |
quotation | Quotation |
amount | Amount of BTC (in BTCPLN pair) to buy or sell |
activation_limit | [optional] |
any_price | [optional] true or false |
Cancel Offer
r = requests.delete(server_address + '/private/offers/17167/', auth=auth)
If successful server responses 204 No Content status code.
HTTP Request
DELETE /private/offers/:offer_id/
Get an Offer details
Example response
{
"status": "REALIZED_CLOSED",
"any_price": false,
"updated": "2016-07-29T10:13:47.086269",
"activation_limit": "0.00000000",
"order_type": "BUY",
"created": "2016-07-29T10:13:47.018452",
"transactions": [
8033
],
"filled_amount": "0.09846107",
"commission": "0.00000000",
"amount": "0.09846107",
"pair": "BTCPLN",
"blocked": "253.03214996",
"id": 17169,
"quotation": "2569.87000000"
}
HTTP Request
GET /private/offers/:offer_id/
Offer statuses
- OPENED means all actual offers not realized even partially.
- PARTLY_REALIZED returns offers which are partly, but not completely realized.
- REALIZED_CLOSED are all completely realized offers.
- PARTLY_REALIZED_CLOSED are partially realized offers, but closed by user before realized completely
- NOT_REALIZED_CLOSED means offer closed, but not realized event partially, eg. closed offer placed by mistake with improper quotation.
amount currency amount to buy or sell.
commission is in percents, eg. 0.30000000
means commission value equals 0.3%
of the offer value.
transactions returns a list of transactions’ ids connected to realized or partially realized offer.
filled_amount realized amount of the offer’s amount.
blocked blocked currency amount for realization offer purposes
List Offers
Example request with optional filtering
GET /private/offers/?offer_status=REALIZED_CLOSED&limit=3
Example response
{
"count": 1965,
"previous": null,
"results": [
{
"status": "REALIZED_CLOSED",
"any_price": false,
"updated": "2016-07-29T10:13:47.086269",
"activation_limit": "0.00000000",
"order_type": "BUY",
"created": "2016-07-29T10:13:47.018452",
"transactions": [
8033
],
"filled_amount": "0.09846107",
"commission": "0.00000000",
"amount": "0.09846107",
"pair": "BTCPLN",
"blocked": "253.03214996",
"id": 17169,
"quotation": "2569.87000000"
},
{
"status": "REALIZED_CLOSED",
"any_price": false,
"updated": "2016-07-29T09:47:28.853000",
"activation_limit": "0.00000000",
"order_type": "SELL",
"created": "2016-07-29T09:47:28.504034",
"transactions": [
8032
],
"filled_amount": "0.07800980",
"commission": "0.00000000",
"amount": "0.07800980",
"pair": "BTCPLN",
"blocked": "0.07800980",
"id": 17165,
"quotation": "2570.29000000"
},
{
"status": "REALIZED_CLOSED",
"any_price": false,
"updated": "2016-07-29T09:38:02.116077",
"activation_limit": "0.00000000",
"order_type": "BUY",
"created": "2016-07-29T09:38:02.061649",
"transactions": [
8031
],
"filled_amount": "0.05638905",
"commission": "0.00000000",
"amount": "0.05638905",
"pair": "BTCPLN",
"blocked": "145.17981202",
"id": 17164,
"quotation": "2574.61000000"
}
],
"next": "https://dgtmarket.com/api/private/offers/?limit=3&offer_status=REALIZED_CLOSED&offset=3"
}
Get list of user offers.
HTTP Request
GET /private/offers/
Available filtering
Parameter | Description |
---|---|
order_type | BUY or SELL |
offer_status | Available offer statuses |
pair | Available pairs |
date_start | Filters offers with date equal or newer than date_start |
date_end | Filters offers with date equal or older than date_end |
limit | Limit number of results |
offset | Offset |
Transactions
Get a Transaction details
r = requests.get(server_address + '/private/transactions/8033/', auth=auth)
Example response
{
"date": "2016-07-29T10:13:47.037002",
"transaction_type": "BUY",
"commission": "0.30000000",
"amount": "0.09846107",
"pair": "BTCPLN",
"id": 8033,
"quotation": "2569.87000000"
}
HTTP Request
GET /private/transactions/:transaction_id/
List Transactions
Example request with optional filtering
r = requests.get(server_address + '/private/transactions/?limit=3', auth=auth)
Example response
{
"count": 2006,
"previous": null,
"results": [
{
"date": "2016-07-29T11:05:59.447869",
"transaction_type": "BUY",
"commission": "0.30000000",
"amount": "0.06915566",
"pair": "BTCPLN",
"id": 8035,
"quotation": "2569.23000000"
},
{
"date": "2016-07-29T10:43:34.681738",
"transaction_type": "SELL",
"commission": "0.30000000",
"amount": "0.05935927",
"pair": "BTCPLN",
"id": 8034,
"quotation": "2570.71000000"
},
{
"date": "2016-07-29T10:13:47.037002",
"transaction_type": "BUY",
"commission": "0.30000000",
"amount": "0.09846107",
"pair": "BTCPLN",
"id": 8033,
"quotation": "2569.87000000"
}
],
"next": "https://dgtmarket.com/api/private/transactions/?limit=3&offset=3&pair=btcpln"
}
Get list of user transactions.
HTTP Request
GET /private/transactions/
Available filtering
Parameter | Description |
---|---|
pair | Available pairs (default is BTCPLN) |
limit | Limit number of results |
offset | Offset |
Transfers
Transfers endpoints allows to list user’s history of withdrawals and deposits as well as order new withdrawal.
Transfer statuses
- IN_PROGRESS
- FINISHED
Transfer types
- INCOMING
- OUTGOING
Order a new Transfer (withdrawal)
data = {
'currency': 'btc',
'amount': 0.015,
}
r = requests.post(server_address + '/private/transfer/', auth=auth, data=data)
Creating a new Transfer will withdraw an ordered amount of a choosen currency to a proper configured outgoing_address (which you can check in the wallets API endpoint).
HTTP Request
POST /private/transfer/
Paremeters
Parameter | Description |
---|---|
currency | BTC or PLN or LTC |
amount | Amount of a currency to withdrawal |
Get a Transfer details
Endopoint that returns transfer details.
HTTP Request
GET /private/transfers/:transfer_id/
List Transfers
Get a list of user transfers.
HTTP Request
GET /private/transfers/
Available filtering
Parameter | Description |
---|---|
currency | Available currencies: BTC, PLN,LTC |
transfer_type | Available transfer types |
transfer_status | Available transfer statuses |
limit | Limit number of results |
offset | Offset |