|
1 | 1 | # pyth-client websocket API
|
2 |
| -The pythd daemon supports a websocket interface based on the jsoni-rpc 2.0 standard. Methods include: |
| 2 | +The pythd daemon supports a websocket interface based on the json-rpc 2.0 standard. Methods include: |
3 | 3 |
|
4 | 4 | - [get_product_list](#get_product_list)
|
5 | 5 | - [update_price](#update_price)
|
6 | 6 | - [subscribe_price](#subscribe_price)
|
7 | 7 | - [subscribe_price_sched](#subscribe_price_sched)
|
| 8 | +- [get_product](#get_product) |
| 9 | +- [get_all_products](#get_all_products) |
8 | 10 |
|
9 | 11 | Batch requests are processed in the order the requests appear within the batch.
|
10 | 12 |
|
@@ -196,3 +198,178 @@ Where the result is an integer corresponding to a subscription identifier. All s
|
196 | 198 | }
|
197 | 199 | }
|
198 | 200 | ```
|
| 201 | + |
| 202 | +## get_product |
| 203 | + |
| 204 | +Get full set of data for the given product. |
| 205 | + |
| 206 | +Request looks like: |
| 207 | +``` |
| 208 | +{ |
| 209 | + "jsonrpc": "2.0", |
| 210 | + "method": "get_product", |
| 211 | + "params": { |
| 212 | + "account": "4aDoSXJ5o3AuvL7QFeR6h44jALQfTmUUCTVGDD6aoJTM" |
| 213 | + }, |
| 214 | + "id" : 1 |
| 215 | +} |
| 216 | +``` |
| 217 | + |
| 218 | +A successful response looks something like: |
| 219 | +``` |
| 220 | +{ |
| 221 | + "jsonrpc": "2.0", |
| 222 | + "result": { |
| 223 | + "account": "4aDoSXJ5o3AuvL7QFeR6h44jALQfTmUUCTVGDD6aoJTM", |
| 224 | + "attr_dict": { |
| 225 | + "asset_type": "Crypto", |
| 226 | + "symbol": "BTC/USD", |
| 227 | + "country": "US", |
| 228 | + "quote_currency": "USD", |
| 229 | + "description": "BTC/USD", |
| 230 | + "tenor": "Spot", |
| 231 | + "generic_symbol": "BTCUSD" |
| 232 | + }, |
| 233 | + "price_accounts": [ |
| 234 | + { |
| 235 | + "account": "GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU", |
| 236 | + "price_type": "price", |
| 237 | + "price_exponent": -8, |
| 238 | + "status": "trading", |
| 239 | + "price": 4426101900000, |
| 240 | + "conf": 4271150000, |
| 241 | + "twap": 4433467600000, |
| 242 | + "twac": 1304202670, |
| 243 | + "valid_slot": 91402257, |
| 244 | + "pub_slot": 91402259, |
| 245 | + "prev_slot": 91402256, |
| 246 | + "prev_price": 4425895500000, |
| 247 | + "prev_conf": 3315350000, |
| 248 | + "publisher_accounts": [ |
| 249 | + { |
| 250 | + "account": "HekM1hBawXQu6wK6Ah1yw1YXXeMUDD2bfCHEzo25vnEB", |
| 251 | + "status": "trading", |
| 252 | + "price": 4426958500000, |
| 253 | + "conf": 1492500000, |
| 254 | + "slot": 91402255 |
| 255 | + }, |
| 256 | + { |
| 257 | + "account": "GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ", |
| 258 | + "status": "trading", |
| 259 | + "price": 4424690000000, |
| 260 | + "conf": 3690000000, |
| 261 | + "slot": 91402256 |
| 262 | + } |
| 263 | + ] |
| 264 | + } |
| 265 | + ] |
| 266 | + }, |
| 267 | + "id": 1 |
| 268 | +} |
| 269 | +``` |
| 270 | + |
| 271 | +## get_all_products |
| 272 | + |
| 273 | +Get full set of data for all products. |
| 274 | + |
| 275 | +Request looks like: |
| 276 | +``` |
| 277 | +{ |
| 278 | + "jsonrpc": "2.0", |
| 279 | + "method": "get_all_products", |
| 280 | + "id" : 1 |
| 281 | +} |
| 282 | +``` |
| 283 | + |
| 284 | +A successful response looks something like: |
| 285 | +``` |
| 286 | +{ |
| 287 | + "jsonrpc": "2.0", |
| 288 | + "result": [ |
| 289 | + { |
| 290 | + "account": "5uKdRzB3FzdmwyCHrqSGq4u2URja617jqtKkM71BVrkw", |
| 291 | + "attr_dict": { |
| 292 | + "asset_type": "Crypto", |
| 293 | + "symbol": "BCH/USD", |
| 294 | + "country": "US", |
| 295 | + "quote_currency": "USD", |
| 296 | + "description": "BCH/USD", |
| 297 | + "tenor": "Spot", |
| 298 | + "generic_symbol": "BCHUSD" |
| 299 | + }, |
| 300 | + "price_accounts": [ |
| 301 | + { |
| 302 | + "account": "5ALDzwcRJfSyGdGyhP3kP628aqBNHZzLuVww7o9kdspe", |
| 303 | + "price_type": "price", |
| 304 | + "price_exponent": -8, |
| 305 | + "status": "trading", |
| 306 | + "price": 60282000000, |
| 307 | + "conf": 26000000, |
| 308 | + "twap": 60321475000, |
| 309 | + "twac": 22504746, |
| 310 | + "valid_slot": 91402601, |
| 311 | + "pub_slot": 91402604, |
| 312 | + "prev_slot": 91402600, |
| 313 | + "prev_price": 60282000000, |
| 314 | + "prev_conf": 26000000, |
| 315 | + "publisher_accounts": [ |
| 316 | + { |
| 317 | + "account": "HekM1hBawXQu6wK6Ah1yw1YXXeMUDD2bfCHEzo25vnEB", |
| 318 | + "status": "trading", |
| 319 | + "price": 60282000000, |
| 320 | + "conf": 26000000, |
| 321 | + "slot": 91402599 |
| 322 | + }, |
| 323 | + { |
| 324 | + "account": "2V7t5NaKY7aGkwytCWQgvUYZfEr9XMwNChhJEakTExk6", |
| 325 | + "status": "unknown", |
| 326 | + "price": 0, |
| 327 | + "conf": 0, |
| 328 | + "slot": 0 |
| 329 | + } |
| 330 | + ] |
| 331 | + } |
| 332 | + ] |
| 333 | + }, |
| 334 | + { |
| 335 | + "account": "3nuELNFBkbXqsXtnCzphRPCX6toKKYxVDnkyr9pTwB1K", |
| 336 | + "attr_dict": { |
| 337 | + "asset_type": "Crypto", |
| 338 | + "symbol": "SABER/USD", |
| 339 | + "country": "US", |
| 340 | + "quote_currency": "USD", |
| 341 | + "description": "SABER/USD", |
| 342 | + "tenor": "Spot", |
| 343 | + "generic_symbol": "SABERUSD" |
| 344 | + }, |
| 345 | + "price_accounts": [ |
| 346 | + { |
| 347 | + "account": "8Td9VML1nHxQK6M8VVyzsHo32D7VBk72jSpa9U861z2A", |
| 348 | + "price_type": "price", |
| 349 | + "price_exponent": -8, |
| 350 | + "status": "trading", |
| 351 | + "price": 5785000, |
| 352 | + "conf": 5000, |
| 353 | + "twap": 5856365, |
| 354 | + "twac": 10241, |
| 355 | + "valid_slot": 91402601, |
| 356 | + "pub_slot": 91402604, |
| 357 | + "prev_slot": 91402600, |
| 358 | + "prev_price": 5785000, |
| 359 | + "prev_conf": 5000, |
| 360 | + "publisher_accounts": [ |
| 361 | + { |
| 362 | + "account": "GKNcUmNacSJo4S2Kq3DuYRYRGw3sNUfJ4tyqd198t6vQ", |
| 363 | + "status": "trading", |
| 364 | + "price": 5785000, |
| 365 | + "conf": 5000, |
| 366 | + "slot": 91402601 |
| 367 | + } |
| 368 | + ] |
| 369 | + } |
| 370 | + ] |
| 371 | + } |
| 372 | + ], |
| 373 | + "id": 1 |
| 374 | +} |
| 375 | +``` |
0 commit comments