1

I am a newbie to the world of Python and JSON though I've managed to work my way through most problems. The latest though is stumping me. I am trying to work with the API at localbitcoins.com and the JSON file is here LBC_JSON--it's a public file.

The output is quite large. I have tried working with it pandas using this code:

from pandas.io.json import json_normalize
from pandas.io.json import read_json

pandas_json = read_json('https://localbitcoins.com/buy-bitcoins-online/alipay/.json')

print(len(pandas_json))
print(type(pandas_json))
print(pandas_json)

But the completed data is not outputted, and then, not completely.

I have tried using the requests library and generating a response.json() on the response. Even though this brings in the complete data I cannot find a way to access the data that I need. I've tried iteration through the data with no luck. All I need is the first price in the API.

I have managed to get this info by using BeautifulSoup and CSS tags but I don't feel this is the correct way to access this info since an API is provided.

Thanks in advance for your answers.

0

1 Answer 1

1

You have to iterate over ad_list, for example:

for ad in pandas_json['data']['ad_list']:
    print(ad['data']['profile']['username'], ad['data']['temp_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.