internetdata 2.10.1__tar.gz → 2.12.0__tar.gz

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.
Files changed (160) hide show
  1. {internetdata-2.10.1 → internetdata-2.12.0}/PKG-INFO +208 -57
  2. {internetdata-2.10.1 → internetdata-2.12.0}/README.md +204 -54
  3. {internetdata-2.10.1 → internetdata-2.12.0}/pyproject.toml +8 -1
  4. {internetdata-2.10.1 → internetdata-2.12.0}/scripts/v2_subset.py +9 -3
  5. internetdata-2.12.0/spec/openapi.yaml +4635 -0
  6. internetdata-2.12.0/src/internetdata/__init__.py +147 -0
  7. internetdata-2.12.0/src/internetdata/_bogons.py +89 -0
  8. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_core.py +256 -12
  9. internetdata-2.12.0/src/internetdata/_generated/api/entitlement/my_entitlement.py +156 -0
  10. internetdata-2.12.0/src/internetdata/_generated/api/lookup/__init__.py +1 -0
  11. internetdata-2.12.0/src/internetdata/_generated/api/lookup/lookup_asn.py +209 -0
  12. internetdata-2.12.0/src/internetdata/_generated/api/lookup/lookup_batch.py +219 -0
  13. internetdata-2.12.0/src/internetdata/_generated/api/lookup/lookup_domain.py +209 -0
  14. internetdata-2.12.0/src/internetdata/_generated/api/lookup/lookup_ip.py +209 -0
  15. internetdata-2.12.0/src/internetdata/_generated/api/lookup/lookup_my_ip.py +161 -0
  16. internetdata-2.12.0/src/internetdata/_generated/api/organization/__init__.py +1 -0
  17. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/__init__.py +84 -0
  18. internetdata-2.12.0/src/internetdata/_generated/models/abuse_contact.py +127 -0
  19. internetdata-2.12.0/src/internetdata/_generated/models/asn.py +114 -0
  20. internetdata-2.12.0/src/internetdata/_generated/models/asn_lookup_response.py +224 -0
  21. internetdata-2.12.0/src/internetdata/_generated/models/asn_lookup_response_whois.py +47 -0
  22. internetdata-2.12.0/src/internetdata/_generated/models/asn_prefix.py +109 -0
  23. internetdata-2.12.0/src/internetdata/_generated/models/batch_lookup_error.py +69 -0
  24. internetdata-2.12.0/src/internetdata/_generated/models/batch_lookup_request.py +86 -0
  25. internetdata-2.12.0/src/internetdata/_generated/models/batch_lookup_response.py +77 -0
  26. internetdata-2.12.0/src/internetdata/_generated/models/batch_lookup_response_errors.py +60 -0
  27. internetdata-2.12.0/src/internetdata/_generated/models/batch_lookup_response_results.py +99 -0
  28. internetdata-2.12.0/src/internetdata/_generated/models/bit_torrent_detail.py +144 -0
  29. internetdata-2.12.0/src/internetdata/_generated/models/carrier_detail.py +97 -0
  30. internetdata-2.12.0/src/internetdata/_generated/models/class_detail.py +88 -0
  31. internetdata-2.12.0/src/internetdata/_generated/models/company.py +91 -0
  32. internetdata-2.12.0/src/internetdata/_generated/models/disposable_detail.py +90 -0
  33. internetdata-2.12.0/src/internetdata/_generated/models/dns_address_record.py +69 -0
  34. internetdata-2.12.0/src/internetdata/_generated/models/dns_cname_record.py +69 -0
  35. internetdata-2.12.0/src/internetdata/_generated/models/dns_mx_record.py +77 -0
  36. internetdata-2.12.0/src/internetdata/_generated/models/dns_ns_record.py +69 -0
  37. internetdata-2.12.0/src/internetdata/_generated/models/dns_resolver_detail.py +106 -0
  38. internetdata-2.12.0/src/internetdata/_generated/models/domain_dns.py +146 -0
  39. internetdata-2.12.0/src/internetdata/_generated/models/domain_ip_range.py +77 -0
  40. internetdata-2.12.0/src/internetdata/_generated/models/domain_ip_ranges.py +108 -0
  41. internetdata-2.12.0/src/internetdata/_generated/models/domain_lookup_response.py +190 -0
  42. internetdata-2.12.0/src/internetdata/_generated/models/entitlement.py +97 -0
  43. internetdata-2.12.0/src/internetdata/_generated/models/entitlement_apikey.py +99 -0
  44. internetdata-2.12.0/src/internetdata/_generated/models/entitlement_error.py +61 -0
  45. internetdata-2.12.0/src/internetdata/_generated/models/entitlement_plan.py +77 -0
  46. internetdata-2.12.0/src/internetdata/_generated/models/entitlement_plan_tier.py +11 -0
  47. internetdata-2.12.0/src/internetdata/_generated/models/entitlement_usage.py +103 -0
  48. internetdata-2.12.0/src/internetdata/_generated/models/hosted_domains.py +62 -0
  49. internetdata-2.12.0/src/internetdata/_generated/models/location.py +227 -0
  50. internetdata-2.12.0/src/internetdata/_generated/models/lookup_error.py +61 -0
  51. internetdata-2.12.0/src/internetdata/_generated/models/lookup_response.py +600 -0
  52. internetdata-2.12.0/src/internetdata/_generated/models/proxy_detail.py +115 -0
  53. internetdata-2.12.0/src/internetdata/_generated/models/pubproxy_detail.py +117 -0
  54. internetdata-2.12.0/src/internetdata/_generated/models/rwhois.py +102 -0
  55. internetdata-2.12.0/src/internetdata/_generated/models/satellite_detail.py +115 -0
  56. internetdata-2.12.0/src/internetdata/_generated/models/smtp_detail.py +97 -0
  57. internetdata-2.12.0/src/internetdata/_generated/models/ssh_detail.py +106 -0
  58. internetdata-2.12.0/src/internetdata/_generated/models/web_detail.py +165 -0
  59. internetdata-2.12.0/src/internetdata/_generated/models/whois.py +126 -0
  60. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/aio.py +325 -6
  61. internetdata-2.12.0/src/internetdata/bogon.py +187 -0
  62. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/client.py +343 -15
  63. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/errors.py +10 -8
  64. internetdata-2.12.0/src/internetdata/middleware/__init__.py +50 -0
  65. internetdata-2.12.0/src/internetdata/middleware/condition.py +177 -0
  66. internetdata-2.12.0/src/internetdata/middleware/core.py +374 -0
  67. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/models.py +655 -1
  68. internetdata-2.12.0/testdata/bogons.json +86 -0
  69. internetdata-2.12.0/testdata/testdata.json +12449 -0
  70. {internetdata-2.10.1 → internetdata-2.12.0}/tests/helpers.py +147 -2
  71. {internetdata-2.10.1 → internetdata-2.12.0}/tests/test_client.py +38 -9
  72. {internetdata-2.10.1 → internetdata-2.12.0}/tests/test_conformance.py +249 -20
  73. internetdata-2.12.0/tests/test_lookup.py +871 -0
  74. internetdata-2.12.0/tests/test_middleware.py +392 -0
  75. {internetdata-2.10.1 → internetdata-2.12.0}/tests/test_oauth.py +39 -4
  76. internetdata-2.12.0/tests/test_sharing.py +235 -0
  77. internetdata-2.10.1/spec/openapi.yaml +0 -1901
  78. internetdata-2.10.1/src/internetdata/__init__.py +0 -76
  79. internetdata-2.10.1/testdata/testdata.json +0 -1855
  80. {internetdata-2.10.1 → internetdata-2.12.0}/.gitignore +0 -0
  81. {internetdata-2.10.1 → internetdata-2.12.0}/LICENSE +0 -0
  82. {internetdata-2.10.1 → internetdata-2.12.0}/scripts/download-spec.sh +0 -0
  83. {internetdata-2.10.1 → internetdata-2.12.0}/scripts/generate.sh +0 -0
  84. {internetdata-2.10.1 → internetdata-2.12.0}/scripts/publish.sh +0 -0
  85. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/__init__.py +0 -0
  86. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/__init__.py +0 -0
  87. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/account/__init__.py +0 -0
  88. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/account/account_identity.py +0 -0
  89. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/api_keys/__init__.py +0 -0
  90. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/api_keys/account_create_apikey.py +0 -0
  91. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/api_keys/account_list_apikeys.py +0 -0
  92. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/api_keys/account_reveal_apikey.py +0 -0
  93. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/api_keys/account_revoke_apikey.py +0 -0
  94. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/api_keys/account_rotate_apikey.py +0 -0
  95. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/authorization/__init__.py +0 -0
  96. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/authorization/oauth_authorize.py +0 -0
  97. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/authorization/oauth_device_authorization.py +0 -0
  98. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/authorization/oauth_metadata.py +0 -0
  99. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/authorization/oauth_register.py +0 -0
  100. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/authorization/oauth_revoke.py +0 -0
  101. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/authorization/oauth_token.py +0 -0
  102. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/database_v_2/__init__.py +0 -0
  103. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/database_v_2/database_checksum_v2.py +0 -0
  104. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/database_v_2/database_metadata_v2.py +0 -0
  105. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/database_v_2/download_database_v2.py +0 -0
  106. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/database_v_2/list_databases.py +0 -0
  107. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/database_v_2/list_downloads.py +0 -0
  108. {internetdata-2.10.1/src/internetdata/_generated/api/organization → internetdata-2.12.0/src/internetdata/_generated/api/entitlement}/__init__.py +0 -0
  109. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/organization/account_org.py +0 -0
  110. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/api/organization/account_org_members.py +0 -0
  111. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/client.py +0 -0
  112. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/errors.py +0 -0
  113. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/account_create_apikey_request.py +0 -0
  114. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/account_created_apikey.py +0 -0
  115. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/account_org.py +0 -0
  116. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/account_org_ref.py +0 -0
  117. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/account_org_wrap.py +0 -0
  118. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/account_rc.py +0 -0
  119. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/account_revealed_apikey.py +0 -0
  120. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/account_user.py +0 -0
  121. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/apikey_detail.py +0 -0
  122. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/apikey_list.py +0 -0
  123. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/client_registration.py +0 -0
  124. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/client_registration_request.py +0 -0
  125. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database.py +0 -0
  126. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_checksum_v2_response_200.py +0 -0
  127. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_format.py +0 -0
  128. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_license_type_type_1.py +0 -0
  129. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_license_type_type_2_type_1.py +0 -0
  130. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_license_type_type_3_type_1.py +0 -0
  131. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_metadata.py +0 -0
  132. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_metadata_column.py +0 -0
  133. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_metadata_sample.py +0 -0
  134. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_metadata_sample_additional_property_item.py +0 -0
  135. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_metadata_sample_size.py +0 -0
  136. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_metadata_schema.py +0 -0
  137. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_metadata_size.py +0 -0
  138. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/database_version.py +0 -0
  139. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/db_checksums.py +0 -0
  140. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/device_authorization.py +0 -0
  141. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/device_authorization_request.py +0 -0
  142. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/download.py +0 -0
  143. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/download_outcome.py +0 -0
  144. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/error.py +0 -0
  145. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/identity.py +0 -0
  146. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/list_databases_response_200.py +0 -0
  147. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/list_downloads_response_200.py +0 -0
  148. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/oauth_authorize_code_challenge_method.py +0 -0
  149. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/oauth_authorize_response_type.py +0 -0
  150. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/oauth_error.py +0 -0
  151. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/oauth_metadata.py +0 -0
  152. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/oauth_revoke_response_200.py +0 -0
  153. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/revoke_request.py +0 -0
  154. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/standing.py +0 -0
  155. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/token_request.py +0 -0
  156. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/models/token_response.py +0 -0
  157. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/_generated/types.py +0 -0
  158. {internetdata-2.10.1 → internetdata-2.12.0}/src/internetdata/py.typed +0 -0
  159. {internetdata-2.10.1 → internetdata-2.12.0}/tests/conftest.py +0 -0
  160. {internetdata-2.10.1 → internetdata-2.12.0}/tests/test_download.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: internetdata
3
- Version: 2.10.1
4
- Summary: Official Python client library for the InternetData API. Download and verify licensed IP datasets.
3
+ Version: 2.12.0
4
+ Summary: Official Python client library for the InternetData API. Look up IP addresses, ASNs and domains, and download licensed IP databases.
5
5
  Project-URL: Homepage, https://internetdata.io
6
6
  Project-URL: Documentation, https://docs.internetdata.io
7
7
  Project-URL: Source, https://github.com/internetdata/sdk-python
@@ -9,7 +9,7 @@ Project-URL: Issues, https://github.com/internetdata/sdk-python/issues
9
9
  Author-email: Mslm Dev <support@internetdata.io>
10
10
  License-Expression: MIT
11
11
  License-File: LICENSE
12
- Keywords: asn,bogon,dataset,geolocation,hosting,internetdata,ip-database,ip-intelligence,mmdb,proxy,vpn
12
+ Keywords: asn,bogon,dataset,domain,geolocation,hosting,internetdata,ip-database,ip-intelligence,ip-lookup,mmdb,proxy,vpn
13
13
  Classifier: Development Status :: 5 - Production/Stable
14
14
  Classifier: Intended Audience :: Developers
15
15
  Classifier: Programming Language :: Python :: 3
@@ -23,6 +23,7 @@ Classifier: Topic :: Security
23
23
  Classifier: Typing :: Typed
24
24
  Requires-Python: >=3.11
25
25
  Requires-Dist: attrs>=22.2.0
26
+ Requires-Dist: cachetools>=5.3
26
27
  Requires-Dist: httpx<1,>=0.27
27
28
  Provides-Extra: dev
28
29
  Requires-Dist: mypy>=1.11; extra == 'dev'
@@ -39,7 +40,7 @@ Description-Content-Type: text/markdown
39
40
 
40
41
  The official Python client library for the [InternetData](https://internetdata.io) API.
41
42
 
42
- The library helps you browse the databases your organization is licensed for, check what is in each build before you fetch it, and download and verify the files.
43
+ It tells you what every InternetData database says about an IP address, an AS or a domain: where it is, who runs it, whether it is a VPN, proxy, Tor node or hosting server, and what it serves. It also downloads the databases your organization is licensed for.
43
44
 
44
45
  ## Getting Started
45
46
 
@@ -51,26 +52,204 @@ Requires Python 3.11 or newer. Type hints are included, and the package ships `p
51
52
 
52
53
  ## Usage
53
54
 
54
- Every database call needs an API key carrying the `db.download` scope. Create one in the console, then:
55
+ **No API key needed to start.** Unlimited, the free plan, answers `location`, `asn`, `company`, `abuse` and every flag but the VPN, proxy, hosting and CDN ones, limited per address per minute, with a key or without one.
55
56
 
56
57
  ```python
57
- import os
58
58
  from internetdata import InternetData
59
59
 
60
- client = InternetData(os.environ["INTERNETDATA_API_KEY"])
60
+ client = InternetData()
61
61
 
62
- for family in client.database.list():
63
- print(family.base, family.standing, [v.id for v in family.versions])
62
+ result = client.lookup("146.70.116.130")
63
+ print(result.location.country) # 'AT'
64
+ print(result.asn.name) # 'M247 Europe SRL'
65
+ print(result.company.name) # who uses the address
64
66
  ```
65
67
 
66
68
  The client holds an HTTP connection pool, so use it as a context manager, or call `client.close()` when you are done with it:
67
69
 
68
70
  ```python
69
- with InternetData(api_key) as client:
70
- print(len(client.database.list()))
71
+ with InternetData() as client:
72
+ print(client.lookup("146.70.116.130").asn.name)
73
+ ```
74
+
75
+ ### With an API key
76
+
77
+ Every paid plan answers every field: the VPN, proxy, hosting and CDN flags, the detail behind each flag, the city, the Whois records and more. The plans differ only in how many lookups they include, and a free account tries every field, 100 lookups a day. Create a key in the [console](https://app.internetdata.io), then pass it in:
78
+
79
+ ```python
80
+ import os
81
+
82
+ client = InternetData(os.environ["INTERNETDATA_API_KEY"])
83
+
84
+ result = client.lookup("146.70.116.130")
85
+ print(result.is_vpn) # True, on a paid plan
86
+ print(result.vpn.provider) # 'mullvad', on a paid plan
87
+ print(result.location.city) # 'Vienna', on a paid plan
88
+ ```
89
+
90
+ ### Async
91
+
92
+ Everything above works the same way under asyncio, with `AsyncInternetData`:
93
+
94
+ ```python
95
+ import asyncio
96
+ from internetdata import AsyncInternetData
97
+
98
+ async def main():
99
+ async with AsyncInternetData() as client:
100
+ result = await client.lookup("146.70.116.130")
101
+ print(result.asn.name) # 'M247 Europe SRL'
102
+
103
+ asyncio.run(main())
104
+ ```
105
+
106
+ ### Your own address
107
+
108
+ ```python
109
+ result = client.my_ip()
110
+ print(result.ip) # the address we saw this call come from
111
+ ```
112
+
113
+ Same answer `lookup` would give for that address, and the same cost against your allowance. It is deliberately not cached: which address you are is the whole question, and a machine that moves between networks would otherwise be told where it used to be.
114
+
115
+ ### Your plan and usage
116
+
117
+ ```python
118
+ acct = client.my_entitlement()
119
+ print(acct.plan.key) # starter
120
+ print(acct.usage.requests) # 580
121
+ print(acct.usage.window_end) # when the allowance resets
122
+ ```
123
+
124
+ Usage counts against the anniversary of your subscription on a paid plan, not the calendar month and not the billing period, and against the UTC day on the free plan; it is the same number a lookup is gated on. `hard_limit` is `None` on an uncapped plan, which is not the same as zero.
125
+
126
+ Both are on the async client too: `await client.my_ip()` and `await client.my_entitlement()`.
127
+
128
+ ### Batch lookup
129
+
130
+ Look up as many addresses as you like at once. Bogons and cached answers are handled locally, and everything else goes to the batch endpoint in chunks of up to 1000 addresses, in parallel. The batch endpoint needs a paid plan:
131
+
132
+ ```python
133
+ results = client.lookup_batch(["146.70.116.130", "8.8.8.8", "1.1.1.1"])
134
+
135
+ for ip, result in results.items():
136
+ if isinstance(result, Exception):
137
+ print(f"{ip}: {result}")
138
+ continue
139
+ print(f"{ip}: {result.is_vpn}")
140
+ ```
141
+
142
+ Results are keyed by address, in the order you first listed each one, so duplicates in your list collapse into a single entry and one address failing never loses the rest: it carries its error as its value, with the status the API would have given that address on its own.
143
+
144
+ How many chunks are in flight at once, how many times a failed chunk is retried and how long each request may take are configurable per call:
145
+
146
+ ```python
147
+ results = client.lookup_batch(many_ips, concurrency=4, retries=4, timeout=30)
148
+ ```
149
+
150
+ ### Caching
151
+
152
+ Answers are cached by default, so repeat lookups of the same address are free:
153
+
154
+ ```python
155
+ client = InternetData()
156
+
157
+ result = client.lookup("146.70.116.130")
158
+ print(result.asn.name) # API request
159
+
160
+ result2 = client.lookup("146.70.116.130")
161
+ print(result2.asn.name) # no API request, result was cached
162
+ ```
163
+
164
+ You can change the default cache variables (max size, TTL in seconds, etc) on initialization, or even disable it:
165
+
166
+ ```python
167
+ client = InternetData(cache_max_size=50_000, cache_ttl=6 * 60 * 60)
168
+ client_no_cache = InternetData(cache=False)
169
+ ```
170
+
171
+ ### Private and reserved addresses
172
+
173
+ Private, loopback, link-local, documentation and multicast addresses (and their IPv6 equivalents, including the 6to4 and Teredo ranges) are in no database. The library answers them locally, so they cost no request and no quota:
174
+
175
+ ```python
176
+ result = client.lookup("192.168.1.1")
177
+ result.is_bogon # True
178
+ result.is_vpn # False
179
+ ```
180
+
181
+ The answer has the shape the API gives a bogon on a paid plan, whatever your plan, so don't read your plan off it. The check is available on the client, which is handy when your inputs are addresses anyway:
182
+
183
+ ```python
184
+ client.is_bogon("10.0.0.1") # True
185
+ client.is_bogon("8.8.8.8") # False
186
+ ```
187
+
188
+ It is also importable on its own, if you want it without a client:
189
+
190
+ ```python
191
+ from internetdata import is_bogon
192
+
193
+ is_bogon("10.0.0.1") # True
71
194
  ```
72
195
 
73
- ### The catalog
196
+ ### AS and domain lookups
197
+
198
+ ```python
199
+ asn = client.lookup_asn(9009)
200
+ print(asn.name, asn.registry) # M247 Europe SRL ripe
201
+
202
+ domain = client.lookup_domain("example.com")
203
+ print(domain.is_registered, domain.has_mx) # True True
204
+ ```
205
+
206
+ On a paid plan an AS answer also carries its Whois record, its counts and every prefix it announces, and a domain answer its DNS records, its organization's IP ranges and `is_disposable`. Neither is cached, and neither goes through the batch. `lookup` takes addresses alone, and refuses an AS or a domain with a `bad_request` before sending anything.
207
+
208
+ ### Errors
209
+
210
+ Failures raise an `InternetDataError` carrying a `kind` and a `retryable` flag:
211
+
212
+ ```python
213
+ from internetdata import InternetDataError
214
+
215
+ try:
216
+ client.lookup("1.1.1.1")
217
+ except InternetDataError as err:
218
+ print(err.kind, err.retryable, err.message)
219
+ ```
220
+
221
+ `kind` is one of `bad_request`, `unauthorized`, `forbidden`, `rate_limited`, `quota_exceeded`, `server_error` or `network`. `message` is the API's own: a lookup's error message, or a database call's result code, passed through as it was sent, so you can switch on `NOT_LICENSED` against `LICENSE_EXPIRED` without reading the status.
222
+
223
+ A request that runs past its `timeout` fails with `network`, and is retried like any other network failure. The default is 30 seconds per attempt, body included, so a retried call can take longer in total. A database transfer is exempt, so `download` and `download_bytes` are never cut off part way through a large file. Set it on the client, or on a single `lookup`, `lookup_asn`, `lookup_domain`, `my_ip`, `my_entitlement`, `lookup_batch`, `oauth` or `database` call (transfers aside), in seconds:
224
+
225
+ ```python
226
+ client = InternetData(timeout=10)
227
+ result = client.lookup("146.70.116.130", timeout=2)
228
+ ```
229
+
230
+ `None` means no bound on the client, and the client's own on a call. Anything else that is not a number greater than 0 raises `ValueError` where it is set, before any request is made.
231
+
232
+ **Changed in 2.1.0:** the default was 10 seconds, and it bounded each read of a response rather than the whole attempt, so a response trickling in slowly could run past it for as long as the server kept sending.
233
+
234
+ **Changed in 2.2.0:** a timeout of 0 or less, NaN or a string used to be accepted, and failed every call.
235
+
236
+ Note that `rate_limited` and `quota_exceeded` both arrive as HTTP 429 and are not the same thing. A rate limit carries `Retry-After`, and retrying after it works: Unlimited's per-minute limit is one. A spent quota needs your allowance raised or the window to roll over. The library retries rate limits for you, but not a spent quota, and nothing else you sent either.
237
+
238
+ ### Database downloads
239
+
240
+ Every database call needs an API key carrying the `db.download` scope. Create one in the console, then:
241
+
242
+ ```python
243
+ import os
244
+ from internetdata import InternetData
245
+
246
+ client = InternetData(os.environ["INTERNETDATA_API_KEY"])
247
+
248
+ for family in client.database.list():
249
+ print(family.base, family.standing, [v.id for v in family.versions])
250
+ ```
251
+
252
+ #### The catalog
74
253
 
75
254
  `list` answers database FAMILIES. A license is held against a family, while a download names a specific version, so the IDs the other calls take come from each family's `versions`:
76
255
 
@@ -86,7 +265,7 @@ for family in client.database.list():
86
265
 
87
266
  A rolling license also carries `renews_at`, when it next renews, and `notice_due_at`, the last day you can give notice of non-renewal for that term. Both are `None` when there is no license, when it has no defined term, or when `expires` sets a hard stop instead. `DATABASE_FORMATS`, `STANDINGS` and `LICENSE_TYPES` hold the published values at runtime, for checking one that came from a flag or a form before you make a call.
88
267
 
89
- ### What is inside a build
268
+ #### What is inside a build
90
269
 
91
270
  `metadata` is cheap enough to poll. It answers when the build was generated, how many rows it has, its columns and a few real rows, and the size of each format in bytes, all without moving the file:
92
271
 
@@ -101,7 +280,7 @@ print([c.name for c in meta.schema["csvgz"]])
101
280
 
102
281
  Checking `size` before a download is worth the round trip: the catalog spans a few hundred bytes to several gigabytes.
103
282
 
104
- ### Downloading
283
+ #### Downloading
105
284
 
106
285
  Three ways, depending on what you want to do with the bytes:
107
286
 
@@ -134,7 +313,7 @@ digests = client.database.checksums("bogon_ip_v1", "csvgz")
134
313
  assert hashlib.sha256(raw).hexdigest() == digests["sha256"]
135
314
  ```
136
315
 
137
- ### Download history
316
+ #### Download history
138
317
 
139
318
  `downloads` answers your organization's recent attempts, newest first, refusals included. A denial is what answers "it stopped working", and its absence answers nothing:
140
319
 
@@ -143,52 +322,13 @@ for attempt in client.database.downloads(limit=20):
143
322
  print(attempt.created, attempt.dataset_id, attempt.outcome, attempt.http_status)
144
323
  ```
145
324
 
146
- ### Async
147
-
148
- Everything above works the same way under asyncio, with `AsyncInternetData`:
149
-
150
- ```python
151
- import asyncio
152
- from internetdata import AsyncInternetData
153
-
154
- async def main():
155
- async with AsyncInternetData(api_key) as client:
156
- meta = await client.database.metadata("bogon_ip_v1")
157
- await client.database.download("bogon_ip_v1", "csvgz", "./bogon_ip_v1.csv.gz")
158
- print(meta.entries)
159
-
160
- asyncio.run(main())
161
- ```
162
-
163
- ### Errors
164
-
165
- Failures raise an `InternetDataError` carrying a `kind` and a `retryable` flag:
166
-
167
- ```python
168
- from internetdata import InternetDataError
169
-
170
- try:
171
- client.database.download_url("vpn_ip_v1", "mmdb")
172
- except InternetDataError as err:
173
- print(err.kind, err.retryable, err.message) # forbidden False NOT_LICENSED
174
- ```
175
-
176
- `kind` is one of `bad_request`, `unauthorized`, `forbidden`, `rate_limited`, `quota_exceeded`, `server_error` or `network`. `message` is the API's own result code, passed through as it was sent, so you can switch on `NOT_LICENSED` against `LICENSE_EXPIRED` without reading the status.
177
-
178
- A request that runs past its `timeout` fails with `network`, and is retried like any other network failure. The default is 30 seconds per attempt, body included, so a retried call can take longer in total. A database transfer is exempt, so `download` and `download_bytes` are never cut off part way through a large file. Set it on the client, in seconds, or pass `None` for no bound. Anything else that is not a number greater than 0 raises `ValueError` where it is set:
325
+ From 2.3.0, `list`, `metadata`, `checksums`, `downloads` and `download_url` each take a keyword-only `timeout` in seconds, bounding each attempt at that one call in place of the client's; `None` there means the client's own rather than no bound. `download` and `download_bytes` deliberately take none and raise `TypeError` if handed one, rather than accepting it and quietly doing nothing: a transfer runs to gigabytes and minutes, so any bound that suits a JSON call would abandon a healthy download. `download_url` does take one, because minting the link is an ordinary API request - it bounds that request, not whatever you do with the link afterwards:
179
326
 
180
327
  ```python
181
- client = InternetData(api_key, timeout=10)
182
328
  catalog = client.database.list(timeout=2)
183
329
  ```
184
330
 
185
- From 2.3.0, `list`, `metadata`, `checksums`, `downloads` and `download_url` each take a keyword-only `timeout` in seconds, bounding each attempt at that one call in place of the client's; `None` there means the client's own rather than no bound. `download` and `download_bytes` deliberately take none and raise `TypeError` if handed one, rather than accepting it and quietly doing nothing: a transfer runs to gigabytes and minutes, so any bound that suits a JSON call would abandon a healthy download. `download_url` does take one, because minting the link is an ordinary API request - it bounds that request, not whatever you do with the link afterwards.
186
-
187
- **Changed in 2.1.0:** the default was 10 seconds, and it bounded each read of a response rather than the whole attempt, so a response trickling in slowly could run past it for as long as the server kept sending.
188
-
189
- **Changed in 2.2.0:** a timeout of 0 or less, NaN or a string used to be accepted, and failed every call.
190
-
191
- `rate_limited` is a 429 that carries `Retry-After`, and the library retries it for you, as it does server and network failures. `quota_exceeded` is a 429 without one, which it never retries, and it retries nothing else you sent either. InternetData's database API has no quota, so you won't see `quota_exceeded` from it.
331
+ InternetData's database API has no quota, so you won't see `quota_exceeded` from it.
192
332
 
193
333
  ### Sign in with OAuth (device flow)
194
334
 
@@ -244,13 +384,24 @@ registration = client.oauth.register(
244
384
 
245
385
  Each redirect URI must be https on a public host name, or http on a loopback address, which then matches any port. Nothing is kept until a person approves the client, so an app with no client ID saved can simply register again.
246
386
 
387
+ ### Fields your plan does not include
388
+
389
+ Unlimited leaves out the VPN, proxy, hosting and CDN flags, the detail behind every flag but Tor's and relay's, the city and region, the Whois records and the hosted domains; a free-plan key's answer carries `trial_expired`, true once its daily trial is spent. Those are `None` when your key does not include them, which means "not in your plan" rather than "checked, and no", inside `location`, `asn`, `company` and `abuse` too.
390
+
391
+ ```python
392
+ result.flagged("is_hosting") # False rather than None on a plan without it
393
+ result.is_hosting is None # True on Unlimited: not in your plan
394
+ result.location.city is None # True on Unlimited
395
+ result.trial_expired is True # a free-plan key's daily trial is spent
396
+ ```
397
+
247
398
  ## Other Libraries
248
399
 
249
400
  There are official InternetData client libraries available for many languages including PHP, Python, Go, Java, and Ruby. See our GitHub at https://github.com/internetdata for more.
250
401
 
251
402
  ## About InternetData
252
403
 
253
- Geolocation, anonymity, ownership and network databases for IP addresses and AS numbers, licensed as files you download and query yourself.
404
+ Geolocation, anonymity, ownership and network data for IP addresses, AS numbers and domains, through an API or as database files you download and query yourself.
254
405
 
255
406
  [<img src="https://s3.internetdata.io/internetdata-public/brand/mark.svg" alt="InternetData" height="64"/>](https://internetdata.io/)
256
407