0

I am using the API found here: https://docs.deribit.com/v2/?shell#public-ticker (specifically the shell documentation for curl requests)

I am looking to run the request on multiple instrument names. Then I would like to extract a certain value from the response. How would I get the specific value of "min_price" from the result produced?

import requests

name = "BTC-29NOV19-8000-C"
r = requests.get("https://testapp.deribit.com/api/v2/public/ticker?instrument_name="+name)

print(r.text)

1 Answer 1

1

Your example uses requests and not curl so I will assume that is what you want:

You can use json.loads() which will convert the response to a dict , this allows you to access the key needed. In this case result.min_price.

import requests
import json

name = "BTC-29NOV19-8000-C"
r = requests.get("https://testapp.deribit.com/api/v2/public/ticker?instrument_name="+name)

result = json.loads(r.text)

print(result)
print(result['result']['min_price'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.