ipview 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ipview/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .client import IPView
ipview/client.py ADDED
@@ -0,0 +1,217 @@
1
+ import requests as r
2
+ import socket as s
3
+ import ipaddress
4
+
5
+
6
+
7
+
8
+ def fetch(url, params=None):
9
+ return r.get(url, params=params, timeout=5).json()
10
+
11
+ """
12
+ Basic Information
13
+
14
+ """
15
+
16
+ def get_usage_type(ip: str, api_key: str):
17
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
18
+ return data["company"]["type"]
19
+
20
+
21
+ def get_hostname(ip: str):
22
+ return s.gethostbyaddr(ip)[0]
23
+
24
+
25
+ def is_anycast(ip: str, api_key: str):
26
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
27
+ return data["is_anycast"]
28
+
29
+
30
+ def is_satellite(ip: str, api_key: str):
31
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
32
+ return data["is_satellite"]
33
+
34
+
35
+ def get_isp(ip: str):
36
+ data = fetch("http://ip-api.com/json/" + ip, params={"fields": "isp"})
37
+ return data["isp"]
38
+
39
+
40
+ def get_asn(ip: str):
41
+ data = fetch("http://ip-api.com/json/" + ip, params={"fields": "asn"})
42
+ return data["connection"]["asn"]
43
+
44
+
45
+ def get_org(ip: str):
46
+ data = fetch("http://ip-api.com/json/" + ip, params={"fields": "org"})
47
+ return data["org"]
48
+
49
+ """
50
+
51
+ Geographical Information
52
+
53
+ """
54
+
55
+ def get_timezone(ip: str):
56
+ data = fetch("http://ip-api.com/json/" + ip, params={"fields": "timezone"})
57
+ return data["timezone"]
58
+
59
+
60
+ def get_country(ip: str):
61
+ data = fetch("http://ip-api.com/json/" + ip, params={"fields": "country"})
62
+ return data["country"]
63
+
64
+
65
+ def get_country_code(ip: str):
66
+ data = fetch("http://ip-api.com/json/" + ip, params={"fields": "countryCode"})
67
+ return data["countryCode"]
68
+
69
+
70
+ def get_region_code(ip: str):
71
+ data = fetch("http://ip-api.com/json/" + ip, params={"fields": "region"})
72
+ return data["region"]
73
+
74
+
75
+ def get_region_name(ip: str):
76
+ data = fetch("http://ip-api.com/json/" + ip, params={"fields": "regionName"})
77
+ return data["regionName"]
78
+
79
+
80
+ def get_city(ip: str):
81
+ data = fetch("http://ip-api.com/json/" + ip, params={"fields": "city"})
82
+ return data["city"]
83
+
84
+
85
+ def get_longitude(ip: str):
86
+ data = fetch(f"https://geolocation-db.com/json/{ip}")
87
+ return data.get("longitude")
88
+
89
+
90
+ def get_latitude(ip: str):
91
+ data = fetch(f"https://geolocation-db.com/json/{ip}")
92
+ return data.get("latitude")
93
+
94
+ def is_likely_datacenter(ip: str):
95
+ hostname = get_hostname(ip).lower()
96
+ keywords = ["amazon", "google", "azure", "digitalocean", "linode", "ovh"]
97
+ return any(k in hostname for k in keywords)
98
+
99
+ """
100
+
101
+ Privacy / Evasion / Threat intel:
102
+
103
+ """
104
+
105
+
106
+ def is_abuser(ip: str, api_key: str):
107
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
108
+ return data["privacy"]["is_abuser"]
109
+
110
+
111
+ def is_anonymous(ip: str, api_key: str):
112
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
113
+ return data["privacy"]["is_anonymous"]
114
+
115
+
116
+ def is_bogon(ip: str, api_key: str):
117
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
118
+ return data["privacy"]["is_bogon"]
119
+
120
+
121
+ def is_hosting(ip: str, api_key: str):
122
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
123
+ return data["privacy"]["is_hosting"]
124
+
125
+
126
+ def is_icloud_relay(ip: str, api_key: str):
127
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
128
+ return data["privacy"]["is_icloud_relay"]
129
+
130
+
131
+ def is_proxy(ip: str, api_key: str):
132
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
133
+ return data["privacy"]["is_proxy"]
134
+
135
+
136
+ def is_tor(ip: str, api_key: str):
137
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
138
+ return data["privacy"]["is_tor"]
139
+
140
+
141
+ def is_vpn(ip: str, api_key: str):
142
+ data = fetch(f"https://iplocate.io/api/lookup/{ip}?apikey={api_key}")
143
+ return data["privacy"]["is_vpn"]
144
+
145
+ def get_abuse_score(ip: str, api_key: str):
146
+ pass
147
+
148
+
149
+ """"
150
+
151
+ IP Manipulation
152
+ """
153
+
154
+ def ipv6_to_ipv4(ip: str):
155
+ try:
156
+ ipv6 = ipaddress.IPv6Address(ip)
157
+
158
+ if not ipv6.ipv4_mapped:
159
+ return "Not a valid IPv4-mapped IPv6 address."
160
+
161
+ ipv4_int = int(ipv6) & 0xFFFFFFFF
162
+ return str(ipaddress.IPv4Address(ipv4_int))
163
+
164
+ except ValueError as e:
165
+ return f"Error: {e}"
166
+
167
+
168
+ def ipv4_to_ipv6(ip: str):
169
+ try:
170
+ ipv4 = ipaddress.IPv4Address(ip)
171
+
172
+ parts = list(map(int, str(ipv4).split(".")))
173
+
174
+ hex_part1 = (parts[0] << 8) + parts[1]
175
+ hex_part2 = (parts[2] << 8) + parts[3]
176
+
177
+ return f"0:0:0:0:0:ffff:{hex_part1:04x}:{hex_part2:04x}"
178
+
179
+ except ValueError as e:
180
+ return f"Error: {e}"
181
+
182
+ """"
183
+
184
+ Edge Cases
185
+
186
+ """
187
+
188
+ def is_iphone_hotspot(ip: str):
189
+ try:
190
+ addr = ipaddress.ip_address(ip)
191
+
192
+ if isinstance(addr, ipaddress.IPv6Address):
193
+ if addr.ipv4_mapped:
194
+ ip = str(addr.ipv4_mapped)
195
+ else:
196
+ return False
197
+
198
+ return ip.startswith("172.20.10.")
199
+
200
+ except ValueError:
201
+ return False
202
+
203
+
204
+ def is_android_hotspot(ip: str):
205
+ try:
206
+ addr = ipaddress.ip_address(ip)
207
+
208
+ if isinstance(addr, ipaddress.IPv6Address):
209
+ if addr.ipv4_mapped:
210
+ ip = str(addr.ipv4_mapped)
211
+ else:
212
+ return False
213
+
214
+ return ip.startswith("192.168.43.")
215
+
216
+ except ValueError:
217
+ return False
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: ipview
3
+ Version: 0.1.0
4
+ Summary: Simple IP lookup and analysis toolkit
5
+ Author: kevin
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/ribsremoved/ipview
8
+ Project-URL: Bug Tracker, https://github.com/yourusername/ipview/issues
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: requests
13
+ Dynamic: license-file
14
+
15
+ # IPView
16
+
17
+ A simple Python library for IP lookup and analysis.
18
+ It provides geolocation, ISP, ASN, and usage type information in an easy-to-use Python interface.
19
+
20
+ ---
21
+
22
+ ## Description
23
+
24
+ IPView is a lightweight Python tool that allows developers to quickly retrieve detailed information about an IP address, including:
25
+
26
+ - Country and city location
27
+ - ISP (Internet Service Provider)
28
+ - ASN (Autonomous System Number)
29
+ - Usage type (hosting, residential, etc.)
30
+ - And more
31
+
32
+ It is designed to be simple, fast, and easy to integrate into other Python projects.
33
+
34
+ ---
35
+
36
+ ## Getting Started
37
+
38
+ ### Dependencies
39
+
40
+ Before installing IPView, ensure you have:
41
+
42
+ - Python 3.8+
43
+ - `requests` library
44
+ - Internet connection (for API requests)
45
+
46
+ Compatible with:
47
+ - Windows 10/11
48
+ - Linux
49
+ - macOS
50
+
51
+ ---
52
+
53
+ ## Installing
54
+
55
+ Install via pip:
56
+
57
+ ```bash
58
+ pip install ipview
@@ -0,0 +1,7 @@
1
+ ipview/__init__.py,sha256=hvdM3fwc591Jz4oCaOau0q7K9UcXlwC9PJ9snHIv7Ug,26
2
+ ipview/client.py,sha256=tg7bEdTQro9MtPuWa4A6lOZY1ExSDgJ4w5_w5P0qITI,5342
3
+ ipview-0.1.0.dist-info/licenses/LICENSE,sha256=BMILPSX8uIAuZdKzx198bCoCDlOoNgRWu0tPppiaAow,1064
4
+ ipview-0.1.0.dist-info/METADATA,sha256=KvshItiv7chTJq-dbS1qdTE9myYdB_n9IvVfsbyDtsM,1279
5
+ ipview-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
+ ipview-0.1.0.dist-info/top_level.txt,sha256=t8SYIOwqfvVFs9HkQkBQow11tuPCE3vwHq2JHSD6Kew,7
7
+ ipview-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,7 @@
1
+ Copyright 2026 ribsremoved
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ ipview