What is API? Why do we need JSON data to work with API?

What is API?

Why do we need JSON data to work with API?

Convert Python Dictionary to JSON

users = {
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
}

}
print(users)
print(type(users))
print('\n Change dict to JSON')import json
result = json.dumps(users)
print(type(result))
print(result)

with open('result.json', 'w') as file:
json.dump(users, file)

Tech Developer. Visit my Github at github.com/RiauTechDev