Skip to content

Commit 2c5698a

Browse files
committed
added static_ip_score to the API
1 parent 2a9f2cd commit 2c5698a

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ History
1616
* Updated documentation of anonymizer attributes - ``is_anonymous_vpn`` and
1717
``is_hosting_provider`` - to be more descriptive.
1818
* Added support for ``user_count`` trait for the GeoIP2 Precision webservice.
19+
* Added ``static_ip_score`` property to ``geoip2.record.Traits`` for GeoIP2 Precision Insights.
1920

2021
2.9.0 (2018-05-25)
2122
++++++++++++++++++

geoip2/records.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,19 @@ class Traits(Record):
684684
685685
:type: unicode
686686
687+
.. attribute:: static_ip_score
688+
689+
An indicator of how static or dynamic an IP address is. The value ranges
690+
from 0 to 99.99 with higher values meaning a greater static association.
691+
For example, many IP addresses with a user_type of cellular have a
692+
lifetime under one. Static Cable/DSL IPs typically have a lifetime above
693+
thirty.
694+
695+
This indicator can be useful for deciding whether an IP address represents
696+
the same user over time.
697+
698+
:type: decimal
699+
687700
.. attribute:: user_count
688701
689702
The estimated number of users sharing the IP/network during the past 24
@@ -738,6 +751,7 @@ def __init__(self,
738751
network=None,
739752
organization=None,
740753
prefix_len=None,
754+
static_ip_score=None,
741755
user_count=None,
742756
user_type=None,
743757
**_):
@@ -755,6 +769,7 @@ def __init__(self,
755769
self.is_tor_exit_node = is_tor_exit_node
756770
self.isp = isp
757771
self.organization = organization
772+
self.static_ip_score = static_ip_score
758773
self.user_type = user_type
759774
self.user_count = user_count
760775
self.ip_address = ip_address

tests/models_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def test_insights_full(self):
104104
'isp': 'Comcast',
105105
'network_speed': 'cable/DSL',
106106
'organization': 'Blorg',
107+
'static_ip_score': 1.3,
107108
'user_count': 2,
108109
'user_type': 'college',
109110
},
@@ -183,8 +184,8 @@ def test_insights_full(self):
183184
self.assertIs(model.traits.is_public_proxy, True)
184185
self.assertIs(model.traits.is_satellite_provider, True)
185186
self.assertIs(model.traits.is_tor_exit_node, True)
186-
187187
self.assertEqual(model.traits.user_count, 2)
188+
self.assertEqual(model.traits.static_ip_score, 1.3)
188189

189190
def test_insights_min(self):
190191
model = geoip2.models.Insights({'traits': {'ip_address': '5.6.7.8'}})

tests/webservice_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def setUp(self):
6464
# JSON from the server
6565
insights = copy.deepcopy(country)
6666
insights['traits']['user_count'] = 2
67+
insights['traits']['static_ip_score'] = 1.3
6768

6869
def _content_type(self, endpoint):
6970
return ('application/vnd.maxmind.com-' + endpoint +
@@ -290,6 +291,7 @@ def test_insights_ok(self, mock):
290291
'return value of client.insights')
291292
self.assertEqual(insights.traits.network,
292293
compat_ip_network('1.2.3.0/24'), 'network')
294+
self.assertEqual(insights.traits.static_ip_score, 1.3, 'static_ip_score is 1.3')
293295
self.assertEqual(insights.traits.user_count, 2, 'user_count is 2')
294296

295297
def test_named_constructor_args(self):

0 commit comments

Comments
 (0)