P
P
Pyth
Search…
pyth-client Websocket API
The pythd daemon supports a websocket interface based on the json-rpc 2.0 standard. Methods include:
Batch requests are processed in the order the requests appear within the batch.

get_product_list

Get list of available symbols and associated meta data.
Request looks like:
1
{
2
"jsonrpc": "2.0",
3
"method": "get_product_list",
4
"id" : 1
5
}
Copied!
A successful response looks something like:
1
{
2
"jsonrpc": "2.0",
3
"result": [
4
{
5
"account": "9F6eBgAfktth93C9zmtKDXFXNjZkq6JwJR56VPKqWmJm",
6
"attr_dict": {
7
"symbol": "SYMBOL1/USD",
8
"asset_type": "Equity",
9
"country": "USA",
10
"description": "pyth example product #1",
11
"quote_currency": "USD",
12
"tenor": "Spot",
13
"cms_symbol": "SYMBOL1",
14
"cqs_symbol": "SYMBOL1",
15
"nasdaq_symbol": "SYMBOL1"
16
},
17
"price": [
18
{
19
"account": "CrZCEEt3awgkGLnVbsv45Pp4aLhr7fZfZr3ubzrbNXaq",
20
"price_exponent": -4,
21
"price_type": "price"
22
}
23
]
24
},
25
{
26
"account": "HCFaDYyz1ajS57HfCaaqzA1cZSaa2oEccQejbHaaofd4",
27
"attr_dict": {
28
"symbol": "SYMBOL2/USD",
29
"asset_type": "Equity",
30
"country": "USA",
31
"description": "pyth example product #2",
32
"quote_currency": "USD",
33
"tenor": "Spot",
34
"cms_symbol": "SYMBOL2",
35
"cqs_symbol": "SYMBOL2",
36
"nasdaq_symbol": "SYMBOL2"
37
},
38
"price": [
39
{
40
"account": "7FUsKvvtN5rB1fgYFWZLo5DLcqHTTeu63bUPThYT6MiS",
41
"price_exponent": -4,
42
"price_type": "price"
43
}
44
]
45
}
46
],
47
"id": null
48
}
Copied!

update_price

Update component price of some symbol using the publishing key of the pythd daemon.
Request includes the pricing account from the get_product_list output and looks something like:
1
{
2
"jsonrpc": "2.0",
3
"method": "update_price",
4
"params" : {
5
"account": "CrZCEEt3awgkGLnVbsv45Pp4aLhr7fZfZr3ubzrbNXaq",
6
"price" : 42002,
7
"conf" : 3,
8
"status": "trading"
9
},
10
"id" : 1
11
}
Copied!
The price and confidence interval (conf) attributes are expressed as integers with an implied decimal point given by the the price_exponent defined by symbol. The price type is a string with one of the following values: "price" or "twap". The symbol status is a string with one of the following values: "trading" or "halted".
A successful response looks like:
1
{
2
"jsonrpc": "2.0",
3
"result" : 0,
4
"id" : 1
5
}
Copied!

subscribe_price

Subscribe to symbol price updates.
Request looks like:
1
{
2
"jsonrpc": "2.0",
3
"method": "subscribe_price",
4
"params" : {
5
"account": "CrZCEEt3awgkGLnVbsv45Pp4aLhr7fZfZr3ubzrbNXaq",
6
},
7
"id" : 1
8
}
Copied!
A successful response looks like:
1
{
2
"jsonrpc": "2.0",
3
"result" : {
4
"subscription" : 1234
5
},
6
"id" : 1
7
}
Copied!
The subscription identifier in the result is used in all subsequent notifications for this subscription. An example notification (with the same subscription id) looks like:
1
{
2
"jsonrpc": "2.0",
3
"method": "notify_price",
4
"params": {
5
"result": {
6
"price" : 42002,
7
"conf" : 3,
8
"status" : "trading",
9
"valid_slot" : 32008,
10
"pub_slot" : 32009
11
},
12
"subscription" : 1234
13
}
14
}
Copied!
Results include the most recent aggregate price, confidence interval and symbol status. pythd will submit a notify_price message immediately upon subscription with the latest price instead of waiting for an update.
Results also include two slot numbers. valid_slot corresponds to the slot containing the prices that were used to compute the aggregate price. pub_slot corresponds to the slot in which the aggregation price was published.

subscribe_price_sched

Subscribe to price update schedule. pythd will notify the client whenever it should submit the next price for a subscribed symbol.
Request looks like:
1
{
2
"jsonrpc": "2.0",
3
"method": "subscribe_price_sched",
4
"params" : {
5
"account": "CrZCEEt3awgkGLnVbsv45Pp4aLhr7fZfZr3ubzrbNXaq",
6
},
7
"id" : 1
8
}
Copied!
A successful response looks like:
1
{
2
"jsonrpc": "2.0",
3
"result" : {
4
"subscription" : 1234
5
},
6
"id" : 1
7
}
Copied!
Where the result is an integer corresponding to a subscription identifier. All subsequent notifications for this subscription correspond to this identifier.
1
{
2
"jsonrpc": "2.0",
3
"method": "notify_price_sched",
4
"params": {
5
"subscription" : 1234
6
}
7
}
Copied!

get_product

Get full set of data for the given product
Request looks like:
1
{
2
"jsonrpc": "2.0",
3
"method": "get_product",
4
"params": {
5
"account": "4aDoSXJ5o3AuvL7QFeR6h44jALQfTmUUCTVGDD6aoJTM"
6
},
7
"id" : 1
8
}
Copied!
A successful response looks something like:
1
{
2
"jsonrpc": "2.0",
3
"result": {
4
"account": "4aDoSXJ5o3AuvL7QFeR6h44jALQfTmUUCTVGDD6aoJTM",
5
"attr_dict": {
6
"asset_type": "Crypto",
7
"symbol": "BTC/USD",
8
"country": "US",
9
"quote_currency": "USD",
10
"description": "BTC/USD",
11
"tenor": "Spot",
12
"generic_symbol": "BTCUSD"
13
},
14
"price_accounts": [
15
{
16
"account": "GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU",
17
"price_type": "price",
18
"price_exponent": -8,
19
"status": "trading",
20
"price": 4426101900000,
21
"conf": 4271150000,
22
"twap": 4433467600000,
23
"twac": 1304202670,
24
"valid_slot": 91402257,
25
"pub_slot": 91402259,
26
"prev_slot": 91402256,
27
"prev_price": 4425895500000,
28
"prev_conf": 3315350000,
29
"publisher_accounts": [
30
{
31
"account": "HekM1hBawXQu6wK6Ah1yw1YXXeMUDD2bfCHEzo25vnEB",
32
"status": "trading",
33
"price": 4426958500000,
34
"conf": 1492500000,
35
"slot": 91402255
36
},
37
{
38
"account": "GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ",
39
"status": "trading",
40
"price": 4424690000000,
41
"conf": 3690000000,
42
"slot": 91402256
43
}
44
]
45
}
46
]
47
},
48
"id": 1
49
}
Copied!

get_all_products

Get full set of data for the given product
Request looks like:
1
{
2
"jsonrpc": "2.0",
3
"method": "get_all_products",
4
"id" : 1
5
}
Copied!
A successful response looks something like:
1
{
2
"jsonrpc": "2.0",
3
"result": [
4
{
5
"account": "5uKdRzB3FzdmwyCHrqSGq4u2URja617jqtKkM71BVrkw",
6
"attr_dict": {
7
"asset_type": "Crypto",
8
"symbol": "BCH/USD",
9
"country": "US",
10
"quote_currency": "USD",
11
"description": "BCH/USD",
12
"tenor": "Spot",
13
"generic_symbol": "BCHUSD"
14
},
15
"price_accounts": [
16
{
17
"account": "5ALDzwcRJfSyGdGyhP3kP628aqBNHZzLuVww7o9kdspe",
18
"price_type": "price",
19
"price_exponent": -8,
20
"status": "trading",
21
"price": 60282000000,
22
"conf": 26000000,
23
"twap": 60321475000,
24
"twac": 22504746,
25
"valid_slot": 91402601,
26
"pub_slot": 91402604,
27
"prev_slot": 91402600,
28
"prev_price": 60282000000,
29
"prev_conf": 26000000,
30
"publisher_accounts": [
31
{
32
"account": "HekM1hBawXQu6wK6Ah1yw1YXXeMUDD2bfCHEzo25vnEB",
33
"status": "trading",
34
"price": 60282000000,
35
"conf": 26000000,
36
"slot": 91402599
37
},
38
{
39
"account": "2V7t5NaKY7aGkwytCWQgvUYZfEr9XMwNChhJEakTExk6",
40
"status": "unknown",
41
"price": 0,
42
"conf": 0,
43
"slot": 0
44
}
45
]
46
}
47
]
48
},
49
{
50
"account": "3nuELNFBkbXqsXtnCzphRPCX6toKKYxVDnkyr9pTwB1K",
51
"attr_dict": {
52
"asset_type": "Crypto",
53
"symbol": "SABER/USD",
54
"country": "US",
55
"quote_currency": "USD",
56
"description": "SABER/USD",
57
"tenor": "Spot",
58
"generic_symbol": "SABERUSD"
59
},
60
"price_accounts": [
61
{
62
"account": "8Td9VML1nHxQK6M8VVyzsHo32D7VBk72jSpa9U861z2A",
63
"price_type": "price",
64
"price_exponent": -8,
65
"status": "trading",
66
"price": 5785000,
67
"conf": 5000,
68
"twap": 5856365,
69
"twac": 10241,
70
"valid_slot": 91402601,
71
"pub_slot": 91402604,
72
"prev_slot": 91402600,
73
"prev_price": 5785000,
74
"prev_conf": 5000,
75
"publisher_accounts": [
76
{
77
"account": "GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ",
78
"status": "trading",
79
"price": 5785000,
80
"conf": 5000,
81
"slot": 91402601
82
}
83
]
84
}
85
]
86
}
87
],
88
"id": 1
89
}
Copied!
Last modified 4mo ago