Working with APIs in Python Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Import the a Python library to work with APIs

A

import requests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Send a get request to an endpoint

A

response = requests.get(“Endpoint_address_as_string”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Examine the status code from a response object

A

response.status_code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Import a library to work with JSON

A

import jason

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Use a function from json library to convert a Python object into a string

A

new_string = json.dumps( Python_Object )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Use a function from json library to convert a JSON string into a Python object

A

Python_Object = json.loads( JASON_String )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Retrieve a Python object from a response object

A

response.json()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Retrieve a JSON text from a response object

A

response.content

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Retrieve metadata from a response object

A
response.headers 
#returns as a dictionary object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly