K
K
kleryk2020-10-27 16:49:56
PHP
kleryk, 2020-10-27 16:49:56

I received a JSON response and how to get the data I need from it?

Hello.
In Python, I receive JSON data through the request library.

import requests
import json

urlwaves = 'https://matcher.waves.exchange/matcher/orderbook/WAVES/8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS/status'

r = requests.get(urlwaves)
r.json()
print(r.json())

How to get ask and bid data?
The data itself looks like this: {'success': True, 'ask': 23846, 'bidAmount': 40115670140, 'bid': 23808, 'lastAmount': 1432183571, 'askAmount': 43822140028, 'lastSide': 'buy', 'status': 'SimpleResponse', 'lastPrice': 23860}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Optimus, 2016-05-02
@Mixailhr

Remove middle brackets in option 2

if ($_SERVER['REQUEST_URI'] == "url1" || $_SERVER['REQUEST_URI'] == "url2") {}

Z
zexer, 2020-10-27
@kleryk

import requests

urlwaves = 'https://matcher.waves.exchange/matcher/orderbook/WAVES/8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS/status'

r = requests.get(urlwaves)
content = r.json()
print(content['ask'], content['bid'])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question