-
Notifications
You must be signed in to change notification settings - Fork 3
/
openapi.yaml
1885 lines (1740 loc) · 69.3 KB
/
openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.0
info:
title: Market Data API
version: 'v3'
x-logo:
url: 'https://docs.bravenewcoin.com/images/logo.png'
altText: 'Brave New Coin'
contact:
name: Brave New Coin
servers:
- url: 'https://api.bravenewcoin.com/{basePath}'
description: Production API Server
variables:
basePath:
default: v3
components:
securitySchemes:
auth:
type: oauth2
flows:
clientCredentials:
tokenUrl: 'https://api.bravenewcoin.com/v3/oauth/token'
scopes:
read:exchange-ticker: Read the latest exchange ticker
read:index-ticker: Read the historical index tickers
read:ohlcv: Read end of day open, high, low, close and volume
read:market-cap: Read the market capatilization
read:LX: Read historical LX index tickers and end of day open, high, low, close and volume
read:derivatives: Read derivatives contract information and latest ticker data
schemas:
Error:
type: object
properties:
status:
description: The status of the error.
type: string
timestamp:
description: The timestamp of the error.
type: string
format: date-time
message:
description: description of error.
type: string
errors:
description: A list of errors.
type: array
items:
type: object
properties:
object:
description: The object that caused the error.
type: string
field:
description: The field that caused the error.
type: string
rejectedValue:
description: The value which caused the error.
type: string
message:
description: A message which usually provides a hint on how to resolve the error.
type: string
Asset:
type: object
properties:
id:
description: Unique identifier for the resource.
type: string
format: uuid
name:
description: The friendly name of the asset.
type: string
symbol:
description: The ticker symbol of the asset.
type: string
status:
description: The status of the asset.
type: string
enum:
- ACTIVE
- INACTIVE
type:
description: Indicator for the type of the asset.
type: string
enum:
- FIAT
- CRYPTO
url:
description: The url of where information about the asset can be found.
type: string
contractAddress:
description: (Optional) The contract address on primary blockchain of issuance if the asset is a token.
type: string
Market:
type: object
properties:
id:
description: Unique identifier for the resource.
type: string
format: uuid
baseAssetId:
description: The base asset id which makes up the market
type: string
format: uuid
quoteAssetId:
description: The quote asset id which makes up the market
type: string
format: uuid
Exchange:
type: object
properties:
id:
description: Unique identifier for the resource.
type: string
format: uuid
name:
description: The name of the exchange
type: string
url:
description: The URL of the exchange
type: string
status:
description: The status of the exchange
type: string
enum:
- ACTIVE
- INACTIVE
- MAINTENANCE
markets:
description: The markets available on the exchange
type: array
items:
type: object
properties:
marketId:
description: The market id
type: string
format: uuid
marketStatus:
description: The status of the market on the exchange
type: string
enum:
- ACTIVE
- INACTIVE
qualified:
description: Indicates if the market on the exchange contributes to the BNC indices
type: string
enum:
- YES
- NO
symbols:
description: Mapping for asset symbols identifying an exchange's markets that differ from generally accepted usage
type: array
items:
type: object
properties:
assetId:
description: The asset id
type: string
format: uuid
symbol:
description: The asset symbol used by the exchange
type: string
Tick:
type: object
properties:
id:
description: Unique identifier for the resource.
type: string
format: uuid
exchangeId:
description: Unique identifier for the exchange.
type: string
format: uuid
marketId:
description: Unique identifier for the market.
type: string
format: uuid
last:
description: The last traded price at the timestamp in the quote asset.
type: string
volume:
description: The volume of the base asset in the last 24 hours.
type: string
bid:
description: 'The bid price in the quote asset.'
type: string
ask:
description: 'The ask price in the quote asset.'
type: string
timestamp:
description: The timestamp from when the market data was collected from the exchange.
type: string
format: date-time
lastMoved:
description: The timestamp of the last traded price of the quote asset at the exchange.
type: string
format: date-time
IndexTicker:
type: object
properties:
indexId:
description: Unique identifier for the constituent used to calculate the index. Or a unique ID for the index in the case of LX indices.
type: string
format: uuid
indexType:
description: The type of the index
type: string
enum:
- MWA
- GWA
- LX
price:
description: The calculated price.
type: string
timestamp:
description: The timestamp the marketed weighted average was calculated.
type: string
format: date-time
id:
description: Unique identifier for the resource.
type: string
format: uuid
volume:
description: The calculated volume in the last 24 hours.
type: string
tickVolume:
description: The calculated volume in the tick. Only for LX 30 second ticks.
type: string
OpenHighLowCloseVolume:
type: object
properties:
id:
description: Unique identifier for the resource.
type: string
format: uuid
indexId:
description: Unique identifier for the market, asset or index (see above).
type: string
format: uuid
indexType:
description: The index type
required: true
type: string
enum:
- MWA
- GWA
- LX
open:
description: The opening price within the period
type: string
close:
description: The closing price within the period
type: string
high:
description: The highest price within the period
type: string
low:
description: The lowest price within the period
type: string
volume:
description: The 24h volume in base asset
type: string
volumeUsd:
description: The 24h volume in USD
type: string
vwap:
description: The mean price within the period, weighted by 24h volume
type: string
twap:
description: The mean price within the period
type: string
startTimestamp:
description: The date and time for the start of the period
type: string
format: date-time
endTimestamp:
description: The date and time for the end of the period
type: string
format: date-time
MarketCapPercentChange:
type: object
description: The percent change over a period of time.
properties:
change24h:
description: Percentage change for the 24 hour period.
type: string
change7d:
description: Percentage change for the 7 day period.
type: string
change30d:
description: Percentage change for the 30 day period.
type: string
MarketCap:
type: object
properties:
id:
description: Unique identifier for the resource.
type: string
format: uuid
assetId:
description: The asset id
type: string
format: uuid
timestamp:
description: The timestamp the market capitalisation was calculated.
type: string
format: date-time
marketCapRank:
description: The market cap ranking order.
type: string
volumeRank:
description: The 24hr volume ranking order.
type: string
price:
description: The global weighted average price of the asset in USD.
type: string
volume:
description: The total global weighted average 24h volume of the asset.
type: string
totalSupply:
description: The total supply of the asset.
type: string
freeFloatSupply:
description: The circulating supply of the asset. It is the total supply less any supply that has been removed from circulation.
type: string
marketCap:
description: Market cap in USD based on the price and the free float supply.
type: string
totalMarketCap:
description: USD market cap figure based on total supply.
type: string
marketCapPercentChange:
$ref: '#/components/schemas/MarketCapPercentChange'
totalMarketCapPercentChange:
$ref: '#/components/schemas/MarketCapPercentChange'
volumePercentChange:
$ref: '#/components/schemas/MarketCapPercentChange'
pricePercentChange:
$ref: '#/components/schemas/MarketCapPercentChange'
DerivativeContract:
type: object
properties:
id:
description: Unique identifier for the resource. Known as `contractId` in other endpoints.
type: string
format: uuid
exchangeId:
description: Unique identifier for the exchange.
type: string
format: uuid
marketId:
description: Unique identifier for the market.
type: string
format: uuid
exchangeName:
description: The contract name provided by exchange.
type: string
settlementCurrency:
description: The currency symbol which the contract is settled in.
type: string
contractValue:
description: The size of the contract in units of the valueCurrency
type: string
valueCurrency:
description: The currency symbol which the contract is settled in.
type: string
optionType:
description: The options type. Only for derivativeType `OPTION`.
type: string
enum:
- CALL
- PUT
optionStrike:
description: The options strike price. Only for derivativeType `OPTION`.
type: string
listing:
description: The timestamp when the contract was listed. Only for derivativeType `FUTURE` and `OPTION`.
type: string
format: date-time
expiration:
description: The timestamp when the contract expires. Only for derivativeType `FUTURE` and `OPTION`.
type: string
format: date-time
DerivativeTicker:
type: object
properties:
id:
description: Unique identifier for the resource.
type: string
format: uuid
contractId:
description: Unique identifier for the contract.
type: string
format: uuid
exchangeId:
description: Unique identifier for the exchange.
type: string
format: uuid
marketId:
description: Unique identifier for the market.
type: string
format: uuid
timestamp:
description: The timestamp from when the market data was collected from the exchange.
type: string
format: date-time
price:
description: The last traded price measured in the quote asset of the underlying market.
type: string
volume:
description: The volume in the last 24 hours measured in number of contracts.
type: string
volumeUsd:
description: The volume in the last 24 hours measured in USD.
type: string
bid:
description: The bid price measured in the quote asset of the underlying market.
type: string
ask:
description: The ask price measured in the quote asset of the underlying market.
type: string
openInterest:
description: The open interest measured in number of contracts.
type: string
openInterestUsd:
description: The open interest measured in USD.
type: string
indexPrice:
description: The index price measured in the quote asset of the underlying market.
type: string
markPrice:
description: The mark price measured in the quote asset of the underlying market.
type: string
fundingRate:
description: The funding rate.
type: string
parameters:
idParam:
name: id
in: path
required: true
description: The unique resource identifier
schema:
type: string
format: uuid
responses:
Error:
description: General Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
x-tagGroups:
- name: Overview
tags:
- Introduction
- Authentication
- IDs
- Pagination
- Timezones
- Support
- Versioning
- name: Quickstart
tags:
- GWA
- MWA
- name: Rest API
tags:
- Rest API Overview
- Rest API Errors
- Asset
- Market
- Exchange
- XchangeFeed
- GWA / MWA / LX
- Market Cap
- Derivatives
- name: Websocket API
tags:
- Websocket Overview
- Websocket Errors
- Websocket XchangeFeed
- Websocket LX
- Websocket GWA / MWA
tags:
- name: GWA
description: |
### Global weighted average Spot Rates:
The Global Weighted Average for an asset, say Litecoin (LTC), can be obtained by passing the indexType query parameter as GWA and indexId as the Asset Id(UUID) for LTC.
You can find detailed explanation under:
* [GWA](#tag/GWA-MWA)
In order to get the Asset Id(UUID) for LTC, you need to query the Asset API:
* [Asset](#tag/Asset)
```
curl https://api.bravenewcoin.com/v3/asset?symbol=LTC
```
### Example API call for GWA Intraday LTC:
To request LTC index tickers with a timestamp before `17th March 2020`.
```
curl https://api.bravenewcoin.com/v3/index-ticker?timestamp=2020-03-17T00:00:00.000Z&indexType=GWA&indexId=220cbd0c-e466-4a75-9833-755307f872f3 -H 'Authorization: Bearer test_SiHrnL5NKsea0G2W4LHd' -G
```
### Example API call for GWA Open, High, Low, Close, Volume for LTC:
```
curl https://api.bravenewcoin.com/v3/ohlcv?timestamp=2019-09-25T00:00:00.000Z&indexType=GWA&indexId={LTC_Asset_Id} -H 'Authorization: Bearer test_SiHrnL5NKsea0G2W4LHd' -G
```
- name: MWA
description: |
### Market Weighted Average Reference Rates:
The Market weighted average for a market, say BTC/USD (base/quote) can be obtained by passing the indexType query parameter as MWA and indexId as the Market Id(UUID) for BTC/USD.
You can find detailed explanation under:
* [MWA](#tag/GWA-MWA)
In order to get the Market Id(UUID) for BTC/USD, you need to query the Market API:
* [Market](#tag/Market)
```
curl https://api.bravenewcoin.com/v3/market?baseAssetId={BTC_Asset_Id}"eAssetId={USD_Asset_Id}
```
The respective asset Ids can be obtained by querying the Asset API as shown in the GWA section.
### Example API call for MWA Intraday BTC/USD:
```
curl https://api.bravenewcoin.com/v3/index-ticker?timestamp=2019-09-25T00:00:00.000Z&indexType=MWA&indexId={BTC_USD_Market_Id} -H 'Authorization: Bearer test_SiHrnL5NKsea0G2W4LHd' -G
```
### Example API call for MWA Open, High, Low, Close, Volume for BTC/USD:
```
curl https://api.bravenewcoin.com/v3/ohlcv?timestamp=2019-09-25T00:00:00.000Z&indexType=MWA&indexId={BTC_USD_Market_Id} -H 'Authorization: Bearer test_SiHrnL5NKsea0G2W4LHd' -G
```
- name: Authentication
description: |
BNC uses OAuth2 flows for security. When on-boarding to the BNC API platform for the first time, clients are provided with API credentials that allow them to be authenticated and authorised to make API calls. With these credentials a user may obtain an access token which must be submitted as a Header with each API request. The token will contain the information to permit the client to make the call and the scopes that define which endpoints will be accessible to them depending on their contract.
## Websocket API Authentication
Our websocket endpoint requires the bearer token to be sent as *access_token* parameter in the connection url. The token will have to be used within 86400 seconds (24 hours) of being issued.
```
wss://ws.bravenewcoin.com?access_token=<token>
```
## Rest API Authentication
Our REST endpoints require a bearer token, valid for 24 hours, to be sent in the Authorization header.
```
Authorization: Bearer <token>
```
<!-- ReDoc-Inject: <security-definitions> -->
- name: Introduction
description: |
Brave New Coin (BNC) has been providing data for the cryptographic asset marketplace since April 2014. BNC makes this data available through its API's. The V3 platform is the latest iteration, currently presenting market data but expanding to include indices, taxonomy and newsfeeds through a single interface. Access is either via REST or Websockets. In both cases authentication is by OAuth token. Contact [email protected] to obtain the API credentials.
Market data includes the ticker data from over 200 exchanges representing the markets for more than 1500 crypto assets.
BNC aggregates market prices from across exchanges to provide reference rates - the market weighted average (MWA) - for the 6000+ traded market pairs being tracked. These international market reference rates provide the basis to derive a single USD rate, the global weighted average (GWA), for each asset.
Market data is available both as intraday values or as daily summaries (EOD) based on a midnight UTC close providing the open, high, low and close for the 24hr period. Intraday data is limited to a 200 day trailing window. Historic datasets covering the full history back to April 2014 are available on request by contacting [email protected]
A typical interaction with an API endpoint might include:
* A call to obtain an OAuth token based on client credentials.
* A call to one of the lookups to get the UUID for an asset, market or an exchange.
* A call to the API endpoint to get the response.
The following sections provide further details about the general features of the API. You can jump to the [Quickstart](#tag/GWA) section if preferred or to the full details of the [REST API](#tag/Rest-API-Overview) or [Websocket](#tag/Websocket-Overview)
- name: Support
description: |
The overall service status for Brave New Coin's platform including the APIs is visible [here](https://status.bravenewcoin.com/).
If there any issues or problems arising from using the API's then please contact [email protected] and one of the team will reply within at most one working day if not immediately available.
- name: IDs
description: |
BNC utilises UUIDs to identify entities such as assets, markets and exchanges. These UUIDs often provide the values for API endpoint parameters.
The following resources are our informational API endpoints that can be queried to provide UUIDs:
* [Asset](#tag/Asset): Identifier for an asset, coin or token. e.g. BTC, LTC, ETH etc.
* [Market](#tag/Market): Identifier for a market pair, consisting of a base asset and quote asset. e.g. BTC/USD, BTC/ETH etc.
* [Exchange](#tag/Exchange): Identifier for an exchange. e.g. Binance, Bitstamp, Kraken.
* [Contract](#tag/Derivatives): Identifier for a derivatives contract. e.g. Bybit's *BTCUSDM23* Future or Deribit's *ETH-31MAR23-4000-C* Option.
- name: Rest API Overview
description: |
Brave New Coin REST API exposes the following endpoints:
* [GWA / MWA / LX](#tag/GWA-MWA-LX): Data from intraday API's is limited to a 200 day trailing window and refreshed every 30 seconds from June 1st, 2019.
* [OHLCV](#tag/GWA-MWA-LX): OHLCV API's can provide the full historic dataset.
* [Market Cap](#tag/Market-Cap): Latest ranking within the last 5 minutes.
* [XchangeFeed](#tag/XchangeFeed): Standardized exchange market tickers updated every 30 seconds.
There are currently no rate limits on API requests, but pagination is enforced on API responses to limit the payload of any one call. See [Pagination](#tag/Pagination)
A sample Java API client project using the BNC REST API is available on Github :
* [Java](https://github.com/bnc-projects/java-api-client)
Please feel free to create issues and/or pull requests on Github if you would like to contribute to these projects.
You can download the OpenAPI specification and generate your own clients if the language which you are working with is not found in the list. The download link can be found at the top of this page; and is available on [github](https://github.com/bnc-projects/web-api)
- name: Websocket Overview
description: |
Brave New Coin Websocket API exposes the
[LX](#tag/Websocket-LX) indices,
[GWA / MWA](#tag/Websocket-GWA-MWA) indices,
[trade data](#tag/Websocket-Trade-Data) (for selected markets) and [XchangeFeed](#tag/Websocket-XchangeFeed)
(for all the exchanges and markets covered by BNC) via Websockets.
Clients need to send a subscribe message to authenticate and start receiving data.
A sample project using the BNC Websocket API is available on Github :
* [Node.js](https://github.com/bnc-projects/bnc-websocket-client-sample)
### Connection URL
`wss://ws.bravenewcoin.com?access_token=<token>`
### Authentication
All websocket connections require authentication. For more information see -
* [Authentication](#tag/Authentication)
### Common Message Types
Websocket messages have an `event` field to identify them
#### Connection Message
Once the client connection is successful, the server will send back a connection message
```
{
"event" : "CONNECTED",
"timestamp" : "2018-09-05T01:34:39Z"
}
```
#### Ping message
Clients or server can send a ping request to check if the connection is active. Clients are expected to implement a `pong` response.
The server may terminate the connection if the client does not respond to `ping` from the server.
Request
```
{
"event": "PING",
"requestId": 1
}
```
Response
```
{
"event": "PONG",
"timestamp": "2018-09-05T01:34:39Z",
"requestId": 1
}
```
A requestId is an optional field that users may include for their own benefit.
- name: Websocket Errors
description: |
Server will return an error message in the below format
```
{
"event": "ERROR",
"code": "400",
"message": "Invalid event type provided",
"timestamp": "2018-09-05T01:34:39Z"
}
```
### Error code summary
Error Code | Description
-----------------------------------|------------
400 - Bad Request | The request was unacceptable, often due to missing a required parameter.
401 - Unauthorized | No valid OAuth2 token provided
403 - Forbidden | Not authorized to access this resource (please contact sales about adding access to your profile).
404 - Not Found | Requested resource not found (typically the marketId or exchangeId passed through the subscription request not found)
There may be other types of errors that may be returned and we recommend handling the ERROR type gracefully.
- name: Websocket XchangeFeed
description: |
This endpoint can be used to subscribe to the raw ticker data from different exchanges. Clients can send a Subscribe message to start receiving.
To subscribe to all the ticks of an exchange only the exchangeId can be sent. To subscribe to all the ticks of an market only the marketId or marketName can be sent. Both exchangeId and marketId can be sent to subscribe to the market in an exchange. Clients can subscribe to multiple sources as required. Clients need to call the [Market](#tag/Market) and [Exchange](#tag/Exchange) REST API's to get the ids.
### Parameters
Name | Description
--------------------------|------------
marketId | Subscribe to the exchange ticks for this market
exchangeId | Subscribe to the exchange ticks for this exchange
marketName | Subscribe to the exchange ticks for this exchange by the trade pair. e.g. BTC_USD. It is recommended to subscribe by the marketId rather than the marketName
#### Subscribe to Exchange by Id
```
{
"event": "SUBSCRIBE_EXCHANGE_TICKER",
"exchangeId": "359107d3-bd1a-418c-9470-58831ed9a45e"
}
```
#### Subscribe to Market by Id
```
{
"event": "SUBSCRIBE_EXCHANGE_TICKER",
"marketId": "359107d3-bd1a-418c-9470-58831ed9a45e"
}
```
#### Subscribe to Market by Name
```
{
"event": "SUBSCRIBE_EXCHANGE_TICKER",
"marketName": "BTC_USD"
}
```
#### Subscribe to a Market in an Exchange
```
{
"event": "SUBSCRIBE_EXCHANGE_TICKER",
"exchangeId": "359107d3-bd1a-418c-9470-58831ed9a45e",
"marketId": "f7cbc588-283e-41da-9c28-eee2113d7b8d"
}
```
#### Responses
Subscription response
```
{
"event": "SUBSCRIBED_EXCHANGE_TICKER",
"exchangeId": "359107d3-bd1a-418c-9470-58831ed9a45e",
"marketId": "f7cbc588-283e-41da-9c28-eee2113d7b8d",
"timestamp": "2020-06-25T05:01:17.429649Z"
}
```
The server will return ticks in this format
```
{
"event": "EXCHANGE_TICKER"
"id": "string",
"exchangeId": "string",
"marketId": "string",
"last": "string",
"volume": "string",
"bid": "string",
"ask": "string",
"timestamp": "2020-06-25T05:02:17.429649Z"
}
```
#### Unsubscribe
To unsubscribe, the user should send a payload with the exact same body as the subscribe payload except the event becomes unsubscribe instead of subscribe
```
{
"event": "UNSUBSCRIBE_EXCHANGE_TICKER",
"exchangeId": "359107d3-bd1a-418c-9470-58831ed9a45e",
"marketId": "f7cbc588-283e-41da-9c28-eee2113d7b8d"
}
```
x-traitTag: true
- name: Websocket LX
description: |
This websocket endpoint can be used to subscribe to [BNC's LX indices](https://bravenewcoin.com/enterprise-solutions/indices-program).
Clients need to send a Subscribe message to start receiving. The LX Indices can be subscribed by the indexId or the indexType `LX`.
The following table provides the available index Ids to subscribe to an LX index.
| Index Type | Index Id | Example Id | Description |
| -----------| --------- | ---------- | ----------- |
| LX | Index Id | 191724d4-7915-491b-8b73-bc293e03a93e | [BLX](https://bravenewcoin.com/data-and-charts/indices/blx) |
| LX | Index Id | 6560acf3-1cb7-4fe4-aa19-fbd90c7b56ee | [ELX](https://bravenewcoin.com/data-and-charts/indices/elx) |
| LX | Index Id | ce36445a-2a33-4a0f-8b5b-e56175f8db60 | [XRPLX](https://bravenewcoin.com/data-and-charts/indices/blx) |
#### Subscribe by Index ID
```
{
"event": "SUBSCRIBE_INDEX_TICKER",
"indexId": "191724d4-7915-491b-8b73-bc293e03a93e",
"requestId" : 1
}
```
#### Subscribe by Index Type
```
{
"event": "SUBSCRIBE_INDEX_TICKER",
"indexType": "LX",
"requestId": 2
}
```
#### Responses
Subscription response
```
{
"event": "SUBSCRIBED_INDEX_TICKER",
"indexType": "LX",
"timestamp": "2020-06-25T04:56:14.313516Z",
"requestId": 2
}
```
The server will return ticks in this format
```
{
"event": "INDEX_TICKER"
"id": "uuid",
"indexId": "uuid",
"indexType": "LX",
"name": "string",
"price": "string",
"volume": "string",
"tickVolume": "string",
"timestamp": "2020-06-25T04:57:01.298745Z"
}
```
#### Unsubscribe
To unsubscribe, the user should send a payload with the exact same body as the subscribe payload except the event becomes unsubscribe instead of subscribe. The requestId is a user option and isn't required.
```
{
"event": "UNSUBSCRIBE_INDEX_TICKER",
"indexType": "LX",
"requestId": 2
}
```
x-traitTag: true
- name: Websocket GWA / MWA
description: |
This endpoint can be used to subscribe to the GWA / MWA data. These indices are calculated by BNC and published to the websocket endpoint. Clients need to send a Subscribe message to start receiving.
Indices can be subscribed by the indexId or the indexType.
The index id will differ based on the index type.
| Index Type | Index Id | Example Id | Description |
| -----------| --------- | ---------- | ----------- |
| MWA | Market Id | 2e6d3ce9-9f30-464c-b73e-ba150d2dfb8a | MWA for XAUT_BTC |
| GWA | Asset Id | 1490fca6-29f8-416a-835b-e9d000f26fd0 | GWA for [XAUT](https://bravenewcoin.com/data-and-charts/assets/XAUT/price) using the BNC asset Id for XAUT. |
Clients need to call the [Market](#tag/Market) and [Asset](#tag/Asset) REST API's to get the ids.
#### Subscribe by Index ID
```
{
"event": "SUBSCRIBE_INDEX_TICKER",
"indexId": "1490fca6-29f8-416a-835b-e9d000f26fd0",
"requestId" : 1
}
```
#### Subscribe by Index Type
```
{
"event": "SUBSCRIBE_INDEX_TICKER",
"indexType": "MWA",
"requestId": 2
}
```
#### Responses
Subscription response
```
{
"event": "SUBSCRIBED_INDEX_TICKER",
"indexType": "MWA",
"timestamp": "2020-06-25T04:56:14.313516Z",
"requestId": 2
}
```
The server will return ticks in this format
```
{
"event": "INDEX_TICKER"
"id": "string",
"indexId": "string",
"indexType": "string",
"price": "string",
"volume": "string",
"timestamp": "2020-06-25T04:57:01.298745Z"
}
```
#### Unsubscribe
To unsubscribe, the user should send a payload with the exact same body as the subscribe payload except the event becomes unsubscribe instead of subscribe. The requestId is a user option and isn't required.
```
{
"event": "UNSUBSCRIBE_INDEX_TICKER",
"indexId": "1490fca6-29f8-416a-835b-e9d000f26fd0",
"requestId" : 1
}
```
x-traitTag: true
- name: Rest API Errors
description: |
Brave New Coin uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the `2xx` range indicate success. Codes in the `4xx` range indicate an error that failed given the information provided (e.g. A required parameter was missing). Codes in the `5xx` range indicate an error with Brave New Coin's servers.
Some `4xx` errors that could be handled programmatically include an error code that briefly explains the error reported.
```
{
"status": "BAD_REQUEST",
"timestamp": "2018-08-14T21:55:46.055Z",
"message": "validation error",
"errors": [
{
"object": "Asset",
"field": "status",
"rejectedValue": "ERROR",
"message": "Invalid value provided for status"
}
]
}
```
### HTTP status code summary
HTTP Code | Description
-----------------------------------|------------
200 - OK | Everything worked as expected
400 - Bad Request | The request was unacceptable, often due to missing a required parameter.
401 - Unauthorized | No valid OAuth2 token provided
403 - Forbidden | Not authorized to access this resource (please contact sales about adding access to your profile).
404 - Not Found | The requested resource doesn't exist
409 - Conflict | The request conflicts with another request (perhaps due the resource was updated)
429 - Too Many Requests | Too many requests hit the API too quickly. We recommend an expontential backoff of your requests.
500, 502, 503, 504 - Server Errors | Something went wrong on Brave New Coin's end. (These will be rare).
### Handling Errors
Our API libraries raise exceptions for many reasons, such as invalid parameters, authentication errors, and network unavailability. We recommend writing code that gracefully handles all possible API exceptions.
x-traitTag: true
- name: Pagination
description: |
All top-level API resources have support for bulk fetches via "list" API methods. For instance, you can list assets, list exchange tickers, and list GWA / MWA. These list API methods share a common structure, taking at least these three parameters: `size`, `timestamp` or `startAfter`.
APIs which support query parameters timestamp and startAfter will provide paginated results when these query parameters are provided.
Brave New Coin API's utilise cursor-based pagination using the `startAfter` parameter. The parameter should be an existing object ID and returns resources in reverse chronological order. The `startAfter` parameter returns resources listed after the named resource. For APIs which take both a `startAfter` and `timestamp` parameters, the `timestamp` is ignored if `startAfter` is provided.
Arguments | | Description
--------------|-------------------------|------------
size | Optional, default is 10 | The number of resources to be returned, between 1 and 2000.
startAfter | | A cursor for use in pagination. startAfter is an resource ID that defines your place in the list.
timestamp | | The timestamp to start searching from going backwards in time.
List Response Format | Description
---------------------|------------
content | An array containing the actual response elements, paginated by any request parameters.
nextId | The value to be provided in the `startAfter` to get the next page.
- name: Timezones
description: |
Brave New Coin APIs will return datetime values in ISO8601 format. Datetime values are always returned in UTC time (as indicated by the `Z` at the end of the datetime value).
Currently Brave New Coin APIs only accept datetimes in query parameters and request bodies which are in UTC.
- name: Versioning
description: |
When we make backwards-incompatible changes to the API, we will release a new version. The current version is **v3**.
The following changes are considered backwards-compatible:
* Adding new API resources
* Adding new optional request parameters to existing API methods
* Adding new properties to existing API responses
* Changing the order of properties in existing API responses
* Changing the length or format of object IDs or other opaque strings
x-traitTag: true
- name: Asset