Complete the code to open the API explorer URL in a browser.
import webbrowser webbrowser.[1]('https://api.example.com/explorer')
The open function from the webbrowser module opens a URL in the default browser.
Complete the code to send a GET request to the API explorer endpoint.
import requests response = requests.[1]('https://api.example.com/explorer') print(response.status_code)
The get method sends a GET request to retrieve data from the API.
Fix the error in the code to parse JSON response from the API explorer.
import requests response = requests.get('https://api.example.com/explorer') data = response.[1]() print(data)
The json() method parses the response content as JSON.
Fill both blanks to create a function that fetches and returns JSON data from the API explorer.
import requests def fetch_data(url): response = requests.[1](url) return response.[2]()
The function uses get to request data and json() to parse it.
Fill all three blanks to build a function that sends a POST request with JSON data to the API explorer and returns the JSON response.
import requests def post_data(url, payload): response = requests.[1](url, json=[2]) return response.[3]()
The function uses post to send data, passes the payload as JSON, and parses the response JSON.