-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipdetective.py
More file actions
22 lines (19 loc) · 821 Bytes
/
ipdetective.py
File metadata and controls
22 lines (19 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import requests
class IPDetective:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = "https://api.ipdetective.io/ip"
def GetIpInfo(self, ip_address):
headers = {'x-api-key': self.api_key}
url = f"{self.base_url}/{ip_address}?info=true"
response = requests.get(url, headers=headers)
if response.status_code >=500:
return {"error": "Internal server error occured"}
return response.json()
def GetBulkIpInfo(self, ip_addresses):
headers = {'x-api-key': self.api_key}
url = f"{self.base_url}?info=true"
response = requests.post(url, headers=headers, json=ip_addresses)
if response.status_code >=500:
return {"error": "Internal server error occured"}
return response.json()