I am facing a problem trying to fetch API data and convert to CSV
I have successfully printed data, but when I add the lines of code to sort the data, I get this error
for x in myjson['data']:
TypeError: list indices must be integers or slices, not str
Here is my full line of code.
from ast import In
from email.mime import application
from webbrowser import get
import requests
import csv
from requests.api import head
url = "https://api-devnet.magiceden.dev/v2/collections/runecible/activities?offset=0&limit=100"
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
response = requests.request("GET", url,headers=headers,data={})
myjson = response.json()
ourdata =[]
for x in myjson['data']:
listing = [['collection'], ['price']]
ourdata.append(listing)
print(ourdata)