I am relatively new to working with APIs, so I might overlook something obvious. I’m currently implementing the Skyscanner API via RapidAPI for my project. While testing the API endpoint in the RapidAPI playground, everything operates smoothly. However, when I copy and paste the code into my development environment, it generates several error messages, particularly one stating “certificate verification failed.” Below is the code I executed (the API key is deliberately masked):
import requests
api_url = "https://skyscanner44.p.rapidapi.com/search"
params = {
"adults": "1",
"origin": "LAX",
"destination": "DCA",
"departureDate": "2022-08-01",
"returnDate": "2022-08-15",
"cabinClass": "economy",
"currency": "USD"
}
headers = {
"X-RapidAPI-Key": "XXX",
"X-RapidAPI-Host": "skyscanner44.p.rapidapi.com"
}
response = requests.get(api_url, headers=headers, params=params)
print(response.text)
Below are the error messages I receive:
Traceback (most recent call last):
File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\ssl.py", line 512, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\ssl.py", line 1070, in _create
self.do_handshake()
File "C:\Users\624237\Anaconda3\envs\atmsTesting\lib\ssl.py", line 1341, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
I would greatly appreciate any assistance!