DEV Community

Vamsi Krishna
Vamsi Krishna

Posted on

How to fetch API in Python πŸ”₯

We can create Awesome Projects If we know how to fetch an API in python.

We all know python is the most easiest and widely used programming language even though it is slow.

so in this blog we will learn how to fetch an API in python.
we will use an API which will give us a list of words.

API -- Click Here

import requests
import json

# fetching API 
response_API = requests.get('https://www.randomlists.com/data/words.json')
data = response_API.text # gives in a text format

# converting it into json object
json_data = json.loads(data)

# getting list of words
words = json_data["data"]
print(words)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)