We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 64585aa commit 0ab7751Copy full SHA for 0ab7751
src/ipdata/ipdata.py
@@ -18,6 +18,7 @@
18
:class:`~.IPData` is the primary class for making API requests.
19
"""
20
21
+import os
22
import ipaddress
23
import requests
24
import logging
@@ -99,13 +100,15 @@ class IPData(object):
99
100
101
def __init__(
102
self,
- api_key,
103
+ api_key=os.environ.get("IPDATA_API_KEY"),
104
endpoint="https://api.ipdata.co/",
105
timeout=60,
106
retry_limit=7,
107
retry_backoff_factor=1,
108
debug=False,
109
):
110
+ if not api_key:
111
+ raise IPDataException("API Key not set. Set an API key via the 'IPDATA_API_KEY' environment variable or see the docs for other ways to do so.")
112
# Request settings
113
self.api_key = api_key
114
self.endpoint = endpoint.rstrip("/") # remove trailing /
0 commit comments