Skip to content

Commit e72aa50

Browse files
Add connection.is_anycast to the response model
1 parent b6b47f2 commit e72aa50

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎CHANGELOG.md‎

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

88
## [Unreleased]
9+
### Added
10+
- New field `Connection.is_anycast` (JSON `connection.is_anycast`): whether the IP address is announced
11+
via anycast, i.e. simultaneously from multiple locations.
912

1013
## [5.0.1] - 2026-07-09
1114
### Fixed

‎ipregistry/json.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class Company(BaseModel):
8787
class Connection(BaseModel):
8888
asn: Optional[int] = None
8989
domain: Optional[str] = None
90+
is_anycast: Optional[bool] = None
9091
organization: Optional[str] = None
9192
route: Optional[str] = None
9293
type: Optional[str] = None

‎tests/test_model.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ def test_connection_fields_optional(self):
3333
info = IpInfo(ip='8.8.8.8', connection={'asn': 15169})
3434
self.assertEqual(15169, info.connection.asn)
3535

36+
def test_connection_is_anycast(self):
37+
"""
38+
Test that Connection exposes the is_anycast flag and leaves it unset
39+
when the field is missing from the response
40+
"""
41+
info = IpInfo(ip='8.8.8.8', connection={'asn': 15169, 'is_anycast': True})
42+
self.assertTrue(info.connection.is_anycast)
43+
44+
info = IpInfo(ip='66.165.2.7', connection={'asn': 3853, 'is_anycast': False})
45+
self.assertFalse(info.connection.is_anycast)
46+
47+
self.assertIsNone(Connection(asn=15169).is_anycast)
48+
3649
def test_currency_format_fields_optional(self):
3750
"""
3851
Test that CurrencyFormat validates when negative/positive are missing

0 commit comments

Comments
 (0)