Skip to content

Commit c52cfa0

Browse files
New API: wtfismyip.com (#96)
* feat : _wtfismyip_com_ipv6 function added * fix : IPv6API enum updated * doc : README.md updated * doc : CHANGELOG.md updated * fix : IPv6 tests updated * fix : function location changed
1 parent 852ac5a commit c52cfa0

5 files changed

Lines changed: 46 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Support [wtfismyip.com](https://wtfismyip.com/json) IPv6 API
810
### Changed
911
- `README.md` updated
1012
## [0.7] - 2025-12-09

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Public IP and Location Info:
230230

231231
#### IPv6 API
232232

233-
ℹ️ `ipv6-api` valid choices: [`auto-safe`, `auto`, `ip.sb`, `ident.me`, `tnedi.me`, `ipleak.net`, `my-ip.io`, `ifconfig.co`, `reallyfreegeoip.org`, `myip.la`, `freeipapi.com`]
233+
ℹ️ `ipv6-api` valid choices: [`auto-safe`, `auto`, `ip.sb`, `ident.me`, `tnedi.me`, `ipleak.net`, `my-ip.io`, `ifconfig.co`, `reallyfreegeoip.org`, `myip.la`, `freeipapi.com`, `wtfismyip.com`]
234234

235235
ℹ️ The default value: `auto-safe`
236236

ipspot/ipv6.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,34 @@ def _freeipapi_com_ipv6(geo: bool, timeout: Union[float, Tuple[float, float]]
292292
return {"status": False, "error": str(e)}
293293

294294

295+
def _wtfismyip_com_ipv6(geo: bool, timeout: Union[float, Tuple[float, float]]
296+
) -> Dict[str, Union[bool, Dict[str, Union[str, float]], str]]:
297+
"""
298+
Get public IP and geolocation using wtfismyip.com.
299+
300+
:param geo: geolocation flag
301+
:param timeout: timeout value for API
302+
"""
303+
try:
304+
data = _get_json_standard(url="https://json.ipv6.wtfismyip.com", timeout=timeout)
305+
result = {"status": True, "data": {"ip": data["YourFuckingIPAddress"], "api": "wtfismyip.com"}}
306+
if geo:
307+
geo_data = {
308+
"city": data.get("YourFuckingCity"),
309+
"region": None,
310+
"country": data.get("YourFuckingCountry"),
311+
"country_code": data.get("YourFuckingCountryCode"),
312+
"latitude": None,
313+
"longitude": None,
314+
"organization": data.get("YourFuckingISP"),
315+
"timezone": None
316+
}
317+
result["data"].update(geo_data)
318+
return result
319+
except Exception as e:
320+
return {"status": False, "error": str(e)}
321+
322+
295323
IPV6_API_MAP = {
296324
IPv6API.IP_SB: {
297325
"thread_safe": True,
@@ -337,7 +365,12 @@ def _freeipapi_com_ipv6(geo: bool, timeout: Union[float, Tuple[float, float]]
337365
"thread_safe": False,
338366
"geo": True,
339367
"function": _freeipapi_com_ipv6
340-
}
368+
},
369+
IPv6API.WTFISMYIP_COM: {
370+
"thread_safe": True,
371+
"geo": True,
372+
"function": _wtfismyip_com_ipv6
373+
},
341374
}
342375

343376

ipspot/params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class IPv6API(Enum):
5454
REALLYFREEGEOIP_ORG = "reallyfreegeoip.org"
5555
MYIP_LA = "myip.la"
5656
FREEIPAPI_COM = "freeipapi.com"
57+
WTFISMYIP_COM = "wtfismyip.com"
5758

5859

5960
PARAMETERS_NAME_MAP = {

tests/test_ipv6_api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ def test_public_freeipapi_com_success():
7676
assert result["data"]["api"] == "freeipapi.com"
7777

7878

79+
def test_public_ipv6_wtfismyip_com_success():
80+
result = get_public_ipv6(api=IPv6API.WTFISMYIP_COM, geo=True, timeout=40, max_retries=4, retry_delay=90, backoff_factor=1.1)
81+
assert result["status"]
82+
assert is_ipv6(result["data"]["ip"])
83+
assert set(result["data"].keys()) == DATA_ITEMS
84+
assert result["data"]["api"] == "wtfismyip.com"
85+
86+
7987
def test_public_ipv6_auto_success():
8088
result = get_public_ipv6(api=IPv6API.AUTO, geo=True, timeout=40, max_retries=4, retry_delay=90, backoff_factor=1.1)
8189
assert result["status"]

0 commit comments

Comments
 (0)