Call API Using Python Request – Code Example
0 (0)

Code

import requests 

URL = "https://jsonplaceholder.typicode.com/todos/1"

try:
    response = requests.get(url = URL) 
    if response.status_code == 200:
        data = response.json() 
        print data['title']
    else:
        print('Error: could not receive data')
except Exception as err:
        print('Other error occurred')

Output

Explaination

Prerequisite

Tests

See More

Our Score
Click to rate this post!
[Total: 0 Average: 0]

Leave a Reply

%d bloggers like this: