From 18ee4d39a6ae08f0a9b77bd159c8d53284d647a3 Mon Sep 17 00:00:00 2001 From: qasimleoo Date: Tue, 13 Oct 2026 19:01:32 +0500 Subject: [PATCH] docs: correct examples for all 10 SDKs, spec sync, GitHub Pages config --- .github/workflows/docs.yml | 29 + LICENSE | 22 +- README.md | 57 +- _config.yml | 64 + docs/authentication.md | 248 +- docs/endpoints/README.md | 52 +- docs/endpoints/account-utilities.md | 10 +- docs/endpoints/account.md | 275 +- docs/endpoints/api-solutions.md | 64 +- docs/endpoints/asn-whois.md | 104 +- docs/endpoints/databases-asn-whois.md | 222 +- docs/endpoints/databases-dns.md | 389 ++- docs/endpoints/databases-expiring-dropped.md | 653 +++-- docs/endpoints/databases-ip-geolocation.md | 442 ++- docs/endpoints/databases-ip-security.md | 222 +- docs/endpoints/databases-ip-whois.md | 222 +- docs/endpoints/databases-newly-registered.md | 893 ++++-- docs/endpoints/databases-subdomains.md | 392 ++- docs/endpoints/databases-threat-feed.md | 760 +++-- docs/endpoints/databases-whois.md | 389 ++- docs/endpoints/databases.md | 100 +- docs/endpoints/dns.md | 509 ++-- docs/endpoints/domain-availability.md | 249 +- docs/endpoints/domain-reputation.md | 105 +- docs/endpoints/geolocation.md | 207 +- docs/endpoints/ip-reputation.md | 209 +- docs/endpoints/ip-whois.md | 104 +- docs/endpoints/ssl.md | 120 +- docs/endpoints/subdomains.md | 136 +- docs/endpoints/typosquatting.md | 110 +- docs/endpoints/whois.md | 467 +-- docs/languages/csharp.md | 1366 +++++---- docs/languages/go.md | 2577 +++++++++++------ docs/languages/java.md | 1141 ++++++-- docs/languages/javascript.md | 1893 +++++++----- docs/languages/kotlin.md | 613 ++-- docs/languages/php.md | 1951 ++++++++++--- docs/languages/python.md | 1977 ++++++++----- docs/languages/ruby.md | 1453 +++++++--- docs/languages/swift.md | 1498 +++++++--- docs/languages/typescript.md | 2037 ++++++++----- examples/README.md | 2 +- examples/csharp/AccountUsage.cs | 19 +- examples/csharp/AsnWhois.cs | 19 +- examples/csharp/BulkDomainAvailabilityV2.cs | 22 +- examples/csharp/BulkGeolocation.cs | 23 +- examples/csharp/BulkIpReputation.cs | 23 +- examples/csharp/BulkWhois.cs | 22 +- examples/csharp/DatabaseFileStatus.cs | 19 +- examples/csharp/DbAsnWhois.cs | 24 +- examples/csharp/DbAsnWhoisStatus.cs | 19 +- examples/csharp/DbDnsDaily.cs | 24 +- examples/csharp/DbDnsMonthly.cs | 24 +- examples/csharp/DbDnsWeekly.cs | 24 +- examples/csharp/DbDropped.cs | 24 +- examples/csharp/DbDroppedBacklinks.cs | 24 +- examples/csharp/DbDroppedJson.cs | 20 +- examples/csharp/DbExpired.cs | 24 +- examples/csharp/DbExpiredCleaned.cs | 24 +- examples/csharp/DbIpCity.cs | 24 +- examples/csharp/DbIpCityStatus.cs | 19 +- examples/csharp/DbIpCountry.cs | 24 +- examples/csharp/DbIpCountryStatus.cs | 19 +- examples/csharp/DbIpSecurity.cs | 24 +- examples/csharp/DbIpSecurityStatus.cs | 19 +- examples/csharp/DbIpWhois.cs | 24 +- examples/csharp/DbIpWhoisStatus.cs | 19 +- examples/csharp/DbNewlyCctld.cs | 24 +- examples/csharp/DbNewlyCctldCleaned.cs | 24 +- examples/csharp/DbNewlyCctldJson.cs | 20 +- examples/csharp/DbNewlyDns.cs | 24 +- examples/csharp/DbNewlyGtld.cs | 24 +- examples/csharp/DbNewlyGtldCleaned.cs | 24 +- examples/csharp/DbNewlyGtldJson.cs | 20 +- examples/csharp/DbSubdomainsDaily.cs | 24 +- examples/csharp/DbSubdomainsMonthly.cs | 24 +- examples/csharp/DbSubdomainsWeekly.cs | 24 +- examples/csharp/DbWhoisDaily.cs | 24 +- examples/csharp/DbWhoisMonthly.cs | 24 +- examples/csharp/DbWhoisWeekly.cs | 24 +- examples/csharp/DnsBulk.cs | 22 +- examples/csharp/DnsHistorical.cs | 19 +- examples/csharp/DnsLive.cs | 23 +- examples/csharp/DnsReverse.cs | 19 +- examples/csharp/DomainAvailabilityV2.cs | 19 +- examples/csharp/DomainReputation.cs | 19 +- examples/csharp/DownloadThreatFeedMalware.cs | 26 +- .../csharp/DownloadThreatFeedMalwareSample.cs | 24 +- examples/csharp/DownloadThreatFeedPhishing.cs | 26 +- .../DownloadThreatFeedPhishingSample.cs | 24 +- examples/csharp/DownloadThreatFeedSpam.cs | 26 +- .../csharp/DownloadThreatFeedSpamSample.cs | 24 +- examples/csharp/Geolocation.cs | 19 +- examples/csharp/IpReputation.cs | 19 +- examples/csharp/IpWhois.cs | 19 +- examples/csharp/README.md | 124 +- examples/csharp/RotateApiKey.cs | 19 +- examples/csharp/SslLookup.cs | 19 +- examples/csharp/Subdomains.cs | 19 +- examples/csharp/Typosquatting.cs | 19 +- examples/csharp/WhoisHistoricalOrReverse.cs | 26 - examples/csharp/WhoisHistory.cs | 20 +- examples/csharp/WhoisLive.cs | 19 +- examples/csharp/WhoisReverse.cs | 19 +- examples/go/AccountUsage.go | 33 +- examples/go/AsnWhois.go | 33 +- examples/go/BulkDomainAvailabilityV2.go | 38 +- examples/go/BulkGeolocation.go | 37 +- examples/go/BulkIpReputation.go | 37 +- examples/go/BulkWhois.go | 36 +- examples/go/DatabaseFileStatus.go | 33 +- examples/go/DbAsnWhois.go | 49 +- examples/go/DbAsnWhoisStatus.go | 33 +- examples/go/DbDnsDaily.go | 49 +- examples/go/DbDnsMonthly.go | 49 +- examples/go/DbDnsWeekly.go | 49 +- examples/go/DbDropped.go | 50 +- examples/go/DbDroppedBacklinks.go | 50 +- examples/go/DbDroppedJson.go | 35 +- examples/go/DbExpired.go | 50 +- examples/go/DbExpiredCleaned.go | 50 +- examples/go/DbIpCity.go | 49 +- examples/go/DbIpCityStatus.go | 33 +- examples/go/DbIpCountry.go | 49 +- examples/go/DbIpCountryStatus.go | 33 +- examples/go/DbIpSecurity.go | 49 +- examples/go/DbIpSecurityStatus.go | 33 +- examples/go/DbIpWhois.go | 49 +- examples/go/DbIpWhoisStatus.go | 33 +- examples/go/DbNewlyCctld.go | 50 +- examples/go/DbNewlyCctldCleaned.go | 50 +- examples/go/DbNewlyCctldJson.go | 35 +- examples/go/DbNewlyDns.go | 49 +- examples/go/DbNewlyGtld.go | 50 +- examples/go/DbNewlyGtldCleaned.go | 50 +- examples/go/DbNewlyGtldJson.go | 35 +- examples/go/DbSubdomainsDaily.go | 50 +- examples/go/DbSubdomainsMonthly.go | 50 +- examples/go/DbSubdomainsWeekly.go | 50 +- examples/go/DbWhoisDaily.go | 49 +- examples/go/DbWhoisMonthly.go | 49 +- examples/go/DbWhoisWeekly.go | 49 +- examples/go/DnsBulk.go | 37 +- examples/go/DnsHistorical.go | 34 +- examples/go/DnsLive.go | 38 +- examples/go/DnsReverse.go | 33 +- examples/go/DomainAvailabilityV2.go | 34 +- examples/go/DomainReputation.go | 34 +- examples/go/DownloadThreatFeedMalware.go | 52 +- .../go/DownloadThreatFeedMalwareSample.go | 48 +- examples/go/DownloadThreatFeedPhishing.go | 52 +- .../go/DownloadThreatFeedPhishingSample.go | 48 +- examples/go/DownloadThreatFeedSpam.go | 52 +- examples/go/DownloadThreatFeedSpamSample.go | 48 +- examples/go/Geolocation.go | 33 +- examples/go/IpReputation.go | 33 +- examples/go/IpWhois.go | 33 +- examples/go/README.md | 124 +- examples/go/RotateApiKey.go | 32 +- examples/go/SslLookup.go | 33 +- examples/go/Subdomains.go | 34 +- examples/go/Typosquatting.go | 33 +- examples/go/WhoisHistoricalOrReverse.go | 32 - examples/go/WhoisHistory.go | 34 +- examples/go/WhoisLive.go | 33 +- examples/go/WhoisReverse.go | 33 +- examples/java/AccountUsage.java | 11 +- examples/java/AsnWhois.java | 12 +- examples/java/BulkDomainAvailabilityV2.java | 18 +- examples/java/BulkGeolocation.java | 18 +- examples/java/BulkIpReputation.java | 20 +- examples/java/BulkWhois.java | 18 +- examples/java/DatabaseFileStatus.java | 10 +- examples/java/DbAsnWhois.java | 22 +- examples/java/DbAsnWhoisStatus.java | 11 +- examples/java/DbDnsDaily.java | 22 +- examples/java/DbDnsMonthly.java | 22 +- examples/java/DbDnsWeekly.java | 22 +- examples/java/DbDropped.java | 22 +- examples/java/DbDroppedBacklinks.java | 23 +- examples/java/DbDroppedJson.java | 14 +- examples/java/DbExpired.java | 22 +- examples/java/DbExpiredCleaned.java | 22 +- examples/java/DbIpCity.java | 22 +- examples/java/DbIpCityStatus.java | 11 +- examples/java/DbIpCountry.java | 22 +- examples/java/DbIpCountryStatus.java | 11 +- examples/java/DbIpSecurity.java | 22 +- examples/java/DbIpSecurityStatus.java | 11 +- examples/java/DbIpWhois.java | 22 +- examples/java/DbIpWhoisStatus.java | 11 +- examples/java/DbNewlyCctld.java | 23 +- examples/java/DbNewlyCctldCleaned.java | 22 +- examples/java/DbNewlyCctldJson.java | 14 +- examples/java/DbNewlyDns.java | 22 +- examples/java/DbNewlyGtld.java | 23 +- examples/java/DbNewlyGtldCleaned.java | 22 +- examples/java/DbNewlyGtldJson.java | 14 +- examples/java/DbSubdomainsDaily.java | 22 +- examples/java/DbSubdomainsMonthly.java | 22 +- examples/java/DbSubdomainsWeekly.java | 22 +- examples/java/DbWhoisDaily.java | 22 +- examples/java/DbWhoisMonthly.java | 22 +- examples/java/DbWhoisWeekly.java | 22 +- examples/java/DnsBulk.java | 18 +- examples/java/DnsHistorical.java | 12 +- examples/java/DnsLive.java | 16 +- examples/java/DnsReverse.java | 12 +- examples/java/DomainAvailabilityV2.java | 12 +- examples/java/DomainReputation.java | 12 +- examples/java/DownloadThreatFeedMalware.java | 23 +- .../java/DownloadThreatFeedMalwareSample.java | 21 +- examples/java/DownloadThreatFeedPhishing.java | 23 +- .../DownloadThreatFeedPhishingSample.java | 21 +- examples/java/DownloadThreatFeedSpam.java | 23 +- .../java/DownloadThreatFeedSpamSample.java | 21 +- examples/java/Geolocation.java | 11 +- examples/java/IpReputation.java | 11 +- examples/java/IpWhois.java | 12 +- examples/java/README.md | 124 +- examples/java/RotateApiKey.java | 13 +- examples/java/SslLookup.java | 12 +- examples/java/Subdomains.java | 12 +- examples/java/Typosquatting.java | 12 +- examples/java/WhoisHistoricalOrReverse.java | 27 - examples/java/WhoisHistory.java | 13 +- examples/java/WhoisLive.java | 12 +- examples/java/WhoisReverse.java | 12 +- examples/javascript/AccountUsage.js | 27 +- examples/javascript/AsnWhois.js | 30 +- .../javascript/BulkDomainAvailabilityV2.js | 33 +- examples/javascript/BulkGeolocation.js | 29 +- examples/javascript/BulkIpReputation.js | 29 +- examples/javascript/BulkWhois.js | 31 +- examples/javascript/DatabaseFileStatus.js | 29 +- examples/javascript/DbAsnWhois.js | 32 +- examples/javascript/DbAsnWhoisStatus.js | 27 +- examples/javascript/DbDnsDaily.js | 32 +- examples/javascript/DbDnsMonthly.js | 32 +- examples/javascript/DbDnsWeekly.js | 32 +- examples/javascript/DbDropped.js | 34 +- examples/javascript/DbDroppedBacklinks.js | 34 +- examples/javascript/DbDroppedJson.js | 31 +- examples/javascript/DbExpired.js | 34 +- examples/javascript/DbExpiredCleaned.js | 32 +- examples/javascript/DbIpCity.js | 32 +- examples/javascript/DbIpCityStatus.js | 27 +- examples/javascript/DbIpCountry.js | 32 +- examples/javascript/DbIpCountryStatus.js | 27 +- examples/javascript/DbIpSecurity.js | 32 +- examples/javascript/DbIpSecurityStatus.js | 27 +- examples/javascript/DbIpWhois.js | 32 +- examples/javascript/DbIpWhoisStatus.js | 27 +- examples/javascript/DbNewlyCctld.js | 36 +- examples/javascript/DbNewlyCctldCleaned.js | 32 +- examples/javascript/DbNewlyCctldJson.js | 31 +- examples/javascript/DbNewlyDns.js | 32 +- examples/javascript/DbNewlyGtld.js | 36 +- examples/javascript/DbNewlyGtldCleaned.js | 32 +- examples/javascript/DbNewlyGtldJson.js | 31 +- examples/javascript/DbSubdomainsDaily.js | 32 +- examples/javascript/DbSubdomainsMonthly.js | 32 +- examples/javascript/DbSubdomainsWeekly.js | 32 +- examples/javascript/DbWhoisDaily.js | 32 +- examples/javascript/DbWhoisMonthly.js | 32 +- examples/javascript/DbWhoisWeekly.js | 32 +- examples/javascript/DnsBulk.js | 33 +- examples/javascript/DnsHistorical.js | 34 +- examples/javascript/DnsLive.js | 34 +- examples/javascript/DnsReverse.js | 36 +- examples/javascript/DomainAvailabilityV2.js | 34 +- examples/javascript/DomainReputation.js | 30 +- .../javascript/DownloadThreatFeedMalware.js | 32 +- .../DownloadThreatFeedMalwareSample.js | 31 +- .../javascript/DownloadThreatFeedPhishing.js | 32 +- .../DownloadThreatFeedPhishingSample.js | 31 +- examples/javascript/DownloadThreatFeedSpam.js | 32 +- .../DownloadThreatFeedSpamSample.js | 31 +- examples/javascript/Geolocation.js | 28 +- examples/javascript/IpReputation.js | 28 +- examples/javascript/IpWhois.js | 30 +- examples/javascript/README.md | 124 +- examples/javascript/RotateApiKey.js | 27 +- examples/javascript/SslLookup.js | 34 +- examples/javascript/Subdomains.js | 38 +- examples/javascript/Typosquatting.js | 32 +- .../javascript/WhoisHistoricalOrReverse.js | 23 - examples/javascript/WhoisHistory.js | 31 +- examples/javascript/WhoisLive.js | 30 +- examples/javascript/WhoisReverse.js | 32 +- examples/kotlin/AccountUsage.kt | 4 +- examples/kotlin/AsnWhois.kt | 6 +- examples/kotlin/BulkDomainAvailabilityV2.kt | 9 +- examples/kotlin/BulkGeolocation.kt | 9 +- examples/kotlin/BulkIpReputation.kt | 11 +- examples/kotlin/BulkWhois.kt | 9 +- examples/kotlin/DatabaseFileStatus.kt | 7 +- examples/kotlin/DbAsnWhois.kt | 12 +- examples/kotlin/DbAsnWhoisStatus.kt | 4 +- examples/kotlin/DbDnsDaily.kt | 12 +- examples/kotlin/DbDnsMonthly.kt | 12 +- examples/kotlin/DbDnsWeekly.kt | 12 +- examples/kotlin/DbDropped.kt | 12 +- examples/kotlin/DbDroppedBacklinks.kt | 12 +- examples/kotlin/DbDroppedJson.kt | 7 +- examples/kotlin/DbExpired.kt | 12 +- examples/kotlin/DbExpiredCleaned.kt | 12 +- examples/kotlin/DbIpCity.kt | 12 +- examples/kotlin/DbIpCityStatus.kt | 4 +- examples/kotlin/DbIpCountry.kt | 12 +- examples/kotlin/DbIpCountryStatus.kt | 4 +- examples/kotlin/DbIpSecurity.kt | 12 +- examples/kotlin/DbIpSecurityStatus.kt | 4 +- examples/kotlin/DbIpWhois.kt | 12 +- examples/kotlin/DbIpWhoisStatus.kt | 4 +- examples/kotlin/DbNewlyCctld.kt | 12 +- examples/kotlin/DbNewlyCctldCleaned.kt | 12 +- examples/kotlin/DbNewlyCctldJson.kt | 7 +- examples/kotlin/DbNewlyDns.kt | 12 +- examples/kotlin/DbNewlyGtld.kt | 12 +- examples/kotlin/DbNewlyGtldCleaned.kt | 12 +- examples/kotlin/DbNewlyGtldJson.kt | 7 +- examples/kotlin/DbSubdomainsDaily.kt | 12 +- examples/kotlin/DbSubdomainsMonthly.kt | 12 +- examples/kotlin/DbSubdomainsWeekly.kt | 12 +- examples/kotlin/DbWhoisDaily.kt | 12 +- examples/kotlin/DbWhoisMonthly.kt | 12 +- examples/kotlin/DbWhoisWeekly.kt | 12 +- examples/kotlin/DnsBulk.kt | 9 +- examples/kotlin/DnsHistorical.kt | 6 +- examples/kotlin/DnsLive.kt | 10 +- examples/kotlin/DnsReverse.kt | 6 +- examples/kotlin/DomainAvailabilityV2.kt | 6 +- examples/kotlin/DomainReputation.kt | 6 +- examples/kotlin/DownloadThreatFeedMalware.kt | 13 +- .../kotlin/DownloadThreatFeedMalwareSample.kt | 11 +- examples/kotlin/DownloadThreatFeedPhishing.kt | 13 +- .../DownloadThreatFeedPhishingSample.kt | 11 +- examples/kotlin/DownloadThreatFeedSpam.kt | 13 +- .../kotlin/DownloadThreatFeedSpamSample.kt | 11 +- examples/kotlin/Geolocation.kt | 4 +- examples/kotlin/IpReputation.kt | 4 +- examples/kotlin/IpWhois.kt | 6 +- examples/kotlin/README.md | 124 +- examples/kotlin/RotateApiKey.kt | 9 +- examples/kotlin/SslLookup.kt | 6 +- examples/kotlin/Subdomains.kt | 6 +- examples/kotlin/Typosquatting.kt | 6 +- examples/kotlin/WhoisHistoricalOrReverse.kt | 20 - examples/kotlin/WhoisHistory.kt | 7 +- examples/kotlin/WhoisLive.kt | 6 +- examples/kotlin/WhoisReverse.kt | 6 +- examples/php/AccountUsage.php | 29 +- examples/php/AsnWhois.php | 29 +- examples/php/BulkDomainAvailabilityV2.php | 38 +- examples/php/BulkGeolocation.php | 40 +- examples/php/BulkIpReputation.php | 40 +- examples/php/BulkWhois.php | 38 +- examples/php/DatabaseFileStatus.php | 34 +- examples/php/DbAsnWhois.php | 32 +- examples/php/DbAsnWhoisStatus.php | 29 +- examples/php/DbDnsDaily.php | 32 +- examples/php/DbDnsMonthly.php | 32 +- examples/php/DbDnsWeekly.php | 32 +- examples/php/DbDropped.php | 32 +- examples/php/DbDroppedBacklinks.php | 32 +- examples/php/DbDroppedJson.php | 29 +- examples/php/DbExpired.php | 32 +- examples/php/DbExpiredCleaned.php | 32 +- examples/php/DbIpCity.php | 32 +- examples/php/DbIpCityStatus.php | 29 +- examples/php/DbIpCountry.php | 32 +- examples/php/DbIpCountryStatus.php | 29 +- examples/php/DbIpSecurity.php | 32 +- examples/php/DbIpSecurityStatus.php | 29 +- examples/php/DbIpWhois.php | 32 +- examples/php/DbIpWhoisStatus.php | 29 +- examples/php/DbNewlyCctld.php | 32 +- examples/php/DbNewlyCctldCleaned.php | 32 +- examples/php/DbNewlyCctldJson.php | 29 +- examples/php/DbNewlyDns.php | 32 +- examples/php/DbNewlyGtld.php | 32 +- examples/php/DbNewlyGtldCleaned.php | 32 +- examples/php/DbNewlyGtldJson.php | 29 +- examples/php/DbSubdomainsDaily.php | 32 +- examples/php/DbSubdomainsMonthly.php | 32 +- examples/php/DbSubdomainsWeekly.php | 32 +- examples/php/DbWhoisDaily.php | 32 +- examples/php/DbWhoisMonthly.php | 32 +- examples/php/DbWhoisWeekly.php | 32 +- examples/php/DnsBulk.php | 38 +- examples/php/DnsHistorical.php | 29 +- examples/php/DnsLive.php | 33 +- examples/php/DnsReverse.php | 29 +- examples/php/DomainAvailabilityV2.php | 29 +- examples/php/DomainReputation.php | 29 +- examples/php/DownloadThreatFeedMalware.php | 36 +- .../php/DownloadThreatFeedMalwareSample.php | 32 +- examples/php/DownloadThreatFeedPhishing.php | 36 +- .../php/DownloadThreatFeedPhishingSample.php | 32 +- examples/php/DownloadThreatFeedSpam.php | 36 +- examples/php/DownloadThreatFeedSpamSample.php | 32 +- examples/php/Geolocation.php | 29 +- examples/php/IpReputation.php | 29 +- examples/php/IpWhois.php | 29 +- examples/php/README.md | 124 +- examples/php/RotateApiKey.php | 30 +- examples/php/SslLookup.php | 29 +- examples/php/Subdomains.php | 29 +- examples/php/Typosquatting.php | 29 +- examples/php/WhoisHistoricalOrReverse.php | 21 - examples/php/WhoisHistory.php | 30 +- examples/php/WhoisLive.php | 29 +- examples/php/WhoisReverse.php | 29 +- examples/python/AccountUsage.py | 31 +- examples/python/AsnWhois.py | 34 +- examples/python/BulkDomainAvailabilityV2.py | 35 +- examples/python/BulkGeolocation.py | 35 +- examples/python/BulkIpReputation.py | 35 +- examples/python/BulkWhois.py | 37 +- examples/python/DatabaseFileStatus.py | 30 +- examples/python/DbAsnWhois.py | 35 +- examples/python/DbAsnWhoisStatus.py | 31 +- examples/python/DbDnsDaily.py | 35 +- examples/python/DbDnsMonthly.py | 35 +- examples/python/DbDnsWeekly.py | 35 +- examples/python/DbDropped.py | 37 +- examples/python/DbDroppedBacklinks.py | 37 +- examples/python/DbDroppedJson.py | 36 +- examples/python/DbExpired.py | 37 +- examples/python/DbExpiredCleaned.py | 35 +- examples/python/DbIpCity.py | 35 +- examples/python/DbIpCityStatus.py | 31 +- examples/python/DbIpCountry.py | 35 +- examples/python/DbIpCountryStatus.py | 31 +- examples/python/DbIpSecurity.py | 35 +- examples/python/DbIpSecurityStatus.py | 31 +- examples/python/DbIpWhois.py | 35 +- examples/python/DbIpWhoisStatus.py | 31 +- examples/python/DbNewlyCctld.py | 39 +- examples/python/DbNewlyCctldCleaned.py | 35 +- examples/python/DbNewlyCctldJson.py | 36 +- examples/python/DbNewlyDns.py | 35 +- examples/python/DbNewlyGtld.py | 39 +- examples/python/DbNewlyGtldCleaned.py | 35 +- examples/python/DbNewlyGtldJson.py | 36 +- examples/python/DbSubdomainsDaily.py | 35 +- examples/python/DbSubdomainsMonthly.py | 35 +- examples/python/DbSubdomainsWeekly.py | 35 +- examples/python/DbWhoisDaily.py | 35 +- examples/python/DbWhoisMonthly.py | 35 +- examples/python/DbWhoisWeekly.py | 35 +- examples/python/DnsBulk.py | 35 +- examples/python/DnsHistorical.py | 38 +- examples/python/DnsLive.py | 38 +- examples/python/DnsReverse.py | 36 +- examples/python/DomainAvailabilityV2.py | 38 +- examples/python/DomainReputation.py | 34 +- examples/python/DownloadThreatFeedMalware.py | 34 +- .../python/DownloadThreatFeedMalwareSample.py | 36 +- examples/python/DownloadThreatFeedPhishing.py | 34 +- .../DownloadThreatFeedPhishingSample.py | 36 +- examples/python/DownloadThreatFeedSpam.py | 34 +- .../python/DownloadThreatFeedSpamSample.py | 36 +- examples/python/Geolocation.py | 32 +- examples/python/IpReputation.py | 32 +- examples/python/IpWhois.py | 34 +- examples/python/README.md | 124 +- examples/python/RotateApiKey.py | 30 +- examples/python/SslLookup.py | 38 +- examples/python/Subdomains.py | 39 +- examples/python/Typosquatting.py | 36 +- examples/python/WhoisHistoricalOrReverse.py | 22 - examples/python/WhoisHistory.py | 35 +- examples/python/WhoisLive.py | 34 +- examples/python/WhoisReverse.py | 36 +- examples/ruby/AccountUsage.rb | 20 +- examples/ruby/AsnWhois.rb | 20 +- examples/ruby/BulkDomainAvailabilityV2.rb | 24 +- examples/ruby/BulkGeolocation.rb | 24 +- examples/ruby/BulkIpReputation.rb | 24 +- examples/ruby/BulkWhois.rb | 24 +- examples/ruby/DatabaseFileStatus.rb | 23 +- examples/ruby/DbAsnWhois.rb | 25 +- examples/ruby/DbAsnWhoisStatus.rb | 20 +- examples/ruby/DbDnsDaily.rb | 25 +- examples/ruby/DbDnsMonthly.rb | 25 +- examples/ruby/DbDnsWeekly.rb | 25 +- examples/ruby/DbDropped.rb | 25 +- examples/ruby/DbDroppedBacklinks.rb | 25 +- examples/ruby/DbDroppedJson.rb | 21 +- examples/ruby/DbExpired.rb | 25 +- examples/ruby/DbExpiredCleaned.rb | 25 +- examples/ruby/DbIpCity.rb | 25 +- examples/ruby/DbIpCityStatus.rb | 20 +- examples/ruby/DbIpCountry.rb | 25 +- examples/ruby/DbIpCountryStatus.rb | 20 +- examples/ruby/DbIpSecurity.rb | 25 +- examples/ruby/DbIpSecurityStatus.rb | 20 +- examples/ruby/DbIpWhois.rb | 25 +- examples/ruby/DbIpWhoisStatus.rb | 20 +- examples/ruby/DbNewlyCctld.rb | 25 +- examples/ruby/DbNewlyCctldCleaned.rb | 25 +- examples/ruby/DbNewlyCctldJson.rb | 21 +- examples/ruby/DbNewlyDns.rb | 25 +- examples/ruby/DbNewlyGtld.rb | 25 +- examples/ruby/DbNewlyGtldCleaned.rb | 25 +- examples/ruby/DbNewlyGtldJson.rb | 21 +- examples/ruby/DbSubdomainsDaily.rb | 25 +- examples/ruby/DbSubdomainsMonthly.rb | 25 +- examples/ruby/DbSubdomainsWeekly.rb | 25 +- examples/ruby/DbWhoisDaily.rb | 25 +- examples/ruby/DbWhoisMonthly.rb | 25 +- examples/ruby/DbWhoisWeekly.rb | 25 +- examples/ruby/DnsBulk.rb | 24 +- examples/ruby/DnsHistorical.rb | 22 +- examples/ruby/DnsLive.rb | 24 +- examples/ruby/DnsReverse.rb | 20 +- examples/ruby/DomainAvailabilityV2.rb | 20 +- examples/ruby/DomainReputation.rb | 22 +- examples/ruby/DownloadThreatFeedMalware.rb | 26 +- .../ruby/DownloadThreatFeedMalwareSample.rb | 23 +- examples/ruby/DownloadThreatFeedPhishing.rb | 26 +- .../ruby/DownloadThreatFeedPhishingSample.rb | 23 +- examples/ruby/DownloadThreatFeedSpam.rb | 26 +- examples/ruby/DownloadThreatFeedSpamSample.rb | 23 +- examples/ruby/Geolocation.rb | 20 +- examples/ruby/IpReputation.rb | 20 +- examples/ruby/IpWhois.rb | 20 +- examples/ruby/README.md | 124 +- examples/ruby/RotateApiKey.rb | 20 +- examples/ruby/SslLookup.rb | 24 +- examples/ruby/Subdomains.rb | 21 +- examples/ruby/Typosquatting.rb | 22 +- examples/ruby/WhoisHistoricalOrReverse.rb | 19 - examples/ruby/WhoisHistory.rb | 23 +- examples/ruby/WhoisLive.rb | 22 +- examples/ruby/WhoisReverse.rb | 20 +- examples/swift/AccountUsage.swift | 20 +- examples/swift/AsnWhois.swift | 22 +- examples/swift/BulkDomainAvailabilityV2.swift | 26 +- examples/swift/BulkGeolocation.swift | 26 +- examples/swift/BulkIpReputation.swift | 26 +- examples/swift/BulkWhois.swift | 26 +- examples/swift/DatabaseFileStatus.swift | 23 +- examples/swift/DbAsnWhois.swift | 25 +- examples/swift/DbAsnWhoisStatus.swift | 20 +- examples/swift/DbDnsDaily.swift | 25 +- examples/swift/DbDnsMonthly.swift | 25 +- examples/swift/DbDnsWeekly.swift | 25 +- examples/swift/DbDropped.swift | 25 +- examples/swift/DbDroppedBacklinks.swift | 25 +- examples/swift/DbDroppedJson.swift | 21 +- examples/swift/DbExpired.swift | 25 +- examples/swift/DbExpiredCleaned.swift | 25 +- examples/swift/DbIpCity.swift | 25 +- examples/swift/DbIpCityStatus.swift | 20 +- examples/swift/DbIpCountry.swift | 25 +- examples/swift/DbIpCountryStatus.swift | 20 +- examples/swift/DbIpSecurity.swift | 25 +- examples/swift/DbIpSecurityStatus.swift | 20 +- examples/swift/DbIpWhois.swift | 25 +- examples/swift/DbIpWhoisStatus.swift | 20 +- examples/swift/DbNewlyCctld.swift | 25 +- examples/swift/DbNewlyCctldCleaned.swift | 25 +- examples/swift/DbNewlyCctldJson.swift | 21 +- examples/swift/DbNewlyDns.swift | 25 +- examples/swift/DbNewlyGtld.swift | 25 +- examples/swift/DbNewlyGtldCleaned.swift | 25 +- examples/swift/DbNewlyGtldJson.swift | 21 +- examples/swift/DbSubdomainsDaily.swift | 25 +- examples/swift/DbSubdomainsMonthly.swift | 25 +- examples/swift/DbSubdomainsWeekly.swift | 25 +- examples/swift/DbWhoisDaily.swift | 25 +- examples/swift/DbWhoisMonthly.swift | 25 +- examples/swift/DbWhoisWeekly.swift | 25 +- examples/swift/DnsBulk.swift | 26 +- examples/swift/DnsHistorical.swift | 22 +- examples/swift/DnsLive.swift | 26 +- examples/swift/DnsReverse.swift | 22 +- examples/swift/DomainAvailabilityV2.swift | 22 +- examples/swift/DomainReputation.swift | 22 +- .../swift/DownloadThreatFeedMalware.swift | 27 +- .../DownloadThreatFeedMalwareSample.swift | 26 +- .../swift/DownloadThreatFeedPhishing.swift | 27 +- .../DownloadThreatFeedPhishingSample.swift | 26 +- examples/swift/DownloadThreatFeedSpam.swift | 27 +- .../swift/DownloadThreatFeedSpamSample.swift | 26 +- examples/swift/Geolocation.swift | 20 +- examples/swift/IpReputation.swift | 20 +- examples/swift/IpWhois.swift | 22 +- examples/swift/README.md | 124 +- examples/swift/RotateApiKey.swift | 23 +- examples/swift/SslLookup.swift | 22 +- examples/swift/Subdomains.swift | 21 +- examples/swift/Typosquatting.swift | 22 +- examples/swift/WhoisHistoricalOrReverse.swift | 21 - examples/swift/WhoisHistory.swift | 23 +- examples/swift/WhoisLive.swift | 22 +- examples/swift/WhoisReverse.swift | 22 +- examples/typescript/AccountUsage.ts | 28 +- examples/typescript/AsnWhois.ts | 31 +- .../typescript/BulkDomainAvailabilityV2.ts | 34 +- examples/typescript/BulkGeolocation.ts | 30 +- examples/typescript/BulkIpReputation.ts | 30 +- examples/typescript/BulkWhois.ts | 32 +- examples/typescript/DatabaseFileStatus.ts | 29 +- examples/typescript/DbAsnWhois.ts | 33 +- examples/typescript/DbAsnWhoisStatus.ts | 28 +- examples/typescript/DbDnsDaily.ts | 33 +- examples/typescript/DbDnsMonthly.ts | 33 +- examples/typescript/DbDnsWeekly.ts | 33 +- examples/typescript/DbDropped.ts | 35 +- examples/typescript/DbDroppedBacklinks.ts | 35 +- examples/typescript/DbDroppedJson.ts | 32 +- examples/typescript/DbExpired.ts | 35 +- examples/typescript/DbExpiredCleaned.ts | 33 +- examples/typescript/DbIpCity.ts | 33 +- examples/typescript/DbIpCityStatus.ts | 28 +- examples/typescript/DbIpCountry.ts | 33 +- examples/typescript/DbIpCountryStatus.ts | 28 +- examples/typescript/DbIpSecurity.ts | 33 +- examples/typescript/DbIpSecurityStatus.ts | 28 +- examples/typescript/DbIpWhois.ts | 33 +- examples/typescript/DbIpWhoisStatus.ts | 28 +- examples/typescript/DbNewlyCctld.ts | 37 +- examples/typescript/DbNewlyCctldCleaned.ts | 33 +- examples/typescript/DbNewlyCctldJson.ts | 32 +- examples/typescript/DbNewlyDns.ts | 33 +- examples/typescript/DbNewlyGtld.ts | 37 +- examples/typescript/DbNewlyGtldCleaned.ts | 33 +- examples/typescript/DbNewlyGtldJson.ts | 32 +- examples/typescript/DbSubdomainsDaily.ts | 33 +- examples/typescript/DbSubdomainsMonthly.ts | 33 +- examples/typescript/DbSubdomainsWeekly.ts | 33 +- examples/typescript/DbWhoisDaily.ts | 33 +- examples/typescript/DbWhoisMonthly.ts | 33 +- examples/typescript/DbWhoisWeekly.ts | 33 +- examples/typescript/DnsBulk.ts | 34 +- examples/typescript/DnsHistorical.ts | 35 +- examples/typescript/DnsLive.ts | 35 +- examples/typescript/DnsReverse.ts | 37 +- examples/typescript/DomainAvailabilityV2.ts | 35 +- examples/typescript/DomainReputation.ts | 31 +- .../typescript/DownloadThreatFeedMalware.ts | 33 +- .../DownloadThreatFeedMalwareSample.ts | 32 +- .../typescript/DownloadThreatFeedPhishing.ts | 33 +- .../DownloadThreatFeedPhishingSample.ts | 32 +- examples/typescript/DownloadThreatFeedSpam.ts | 33 +- .../DownloadThreatFeedSpamSample.ts | 32 +- examples/typescript/Geolocation.ts | 27 +- examples/typescript/IpReputation.ts | 27 +- examples/typescript/IpWhois.ts | 31 +- examples/typescript/README.md | 124 +- examples/typescript/RotateApiKey.ts | 28 +- examples/typescript/SslLookup.ts | 35 +- examples/typescript/Subdomains.ts | 39 +- examples/typescript/Typosquatting.ts | 33 +- .../typescript/WhoisHistoricalOrReverse.ts | 23 - examples/typescript/WhoisHistory.ts | 32 +- examples/typescript/WhoisLive.ts | 31 +- examples/typescript/WhoisReverse.ts | 33 +- scripts/docs_lang/__init__.py | 1 + scripts/docs_lang/csharp.py | 190 ++ scripts/docs_lang/go.py | 178 ++ scripts/docs_lang/java.py | 249 ++ scripts/docs_lang/javascript.py | 229 ++ scripts/docs_lang/kotlin.py | 175 ++ scripts/docs_lang/php.py | 204 ++ scripts/docs_lang/python.py | 239 ++ scripts/docs_lang/ruby.py | 192 ++ scripts/docs_lang/swift.py | 209 ++ scripts/docs_lang/typescript.py | 245 ++ scripts/gen_docs.py | 966 ++---- spec/whoisfreaks-openapi.yaml | 1637 ++++++----- 675 files changed, 30954 insertions(+), 15604 deletions(-) create mode 100644 .github/workflows/docs.yml create mode 100644 _config.yml delete mode 100644 examples/csharp/WhoisHistoricalOrReverse.cs delete mode 100644 examples/go/WhoisHistoricalOrReverse.go delete mode 100644 examples/java/WhoisHistoricalOrReverse.java delete mode 100644 examples/javascript/WhoisHistoricalOrReverse.js delete mode 100644 examples/kotlin/WhoisHistoricalOrReverse.kt delete mode 100644 examples/php/WhoisHistoricalOrReverse.php delete mode 100644 examples/python/WhoisHistoricalOrReverse.py delete mode 100644 examples/ruby/WhoisHistoricalOrReverse.rb delete mode 100644 examples/swift/WhoisHistoricalOrReverse.swift delete mode 100644 examples/typescript/WhoisHistoricalOrReverse.ts create mode 100644 scripts/docs_lang/__init__.py create mode 100644 scripts/docs_lang/csharp.py create mode 100644 scripts/docs_lang/go.py create mode 100644 scripts/docs_lang/java.py create mode 100644 scripts/docs_lang/javascript.py create mode 100644 scripts/docs_lang/kotlin.py create mode 100644 scripts/docs_lang/php.py create mode 100644 scripts/docs_lang/python.py create mode 100644 scripts/docs_lang/ruby.py create mode 100644 scripts/docs_lang/swift.py create mode 100644 scripts/docs_lang/typescript.py diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..2175220 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,29 @@ +name: Docs +on: + push: + branches: [main] + pull_request: + paths: ["spec/**", "scripts/**", "docs/**", "examples/**", "README.md"] + +permissions: + contents: read + +jobs: + verify-in-sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-python@v5 + with: { python-version: "3.11" } + - run: pip install "pyyaml==6.0.2" + - name: Regenerate docs from spec + run: python3 scripts/gen_docs.py spec/whoisfreaks-openapi.yaml . + - name: Fail if docs are out of date + run: | + # --porcelain also reports new (untracked) and deleted files + if [ -n "$(git status --porcelain)" ]; then + echo "::error::Docs are out of sync with the spec. Run: python3 scripts/gen_docs.py spec/whoisfreaks-openapi.yaml ." + git status --short + exit 1 + fi + echo "Docs are in sync with the spec." diff --git a/LICENSE b/LICENSE index a25018d..d3b90d4 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1,21 @@ -MIT License — Copyright (c) 2026 WhoisFreaks +MIT License + +Copyright (c) 2026 WhoisFreaks + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/README.md b/README.md index e6809fa..462ab62 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ # WhoisFreaks SDK Documentation -Official documentation for the **WhoisFreaks** SDKs — one API, 10 +Official documentation for the **WhoisFreaks** SDKs: one API, 10 languages, 60 endpoints. Every SDK is generated from the same -[OpenAPI specification](https://whoisfreaks.com/documentation) and published to +[OpenAPI specification](spec/whoisfreaks-openapi.yaml) and published to its language's standard registry. -> Complete WhoisFreaks API — WHOIS, DNS, SSL, Geolocation, Typosquatting, IP Intelligence, Domain Reputation, and bulk database downloads. +> Complete WhoisFreaks API: WHOIS, DNS, SSL, Geolocation, Typosquatting, IP Intelligence, Domain Reputation, and bulk database downloads. ## Contents -- [Authentication](docs/authentication.md) — get and configure your API key -- [Language guides](#language-guides) — install + usage for each SDK -- [Endpoint reference](docs/endpoints/README.md) — all 60 endpoints, grouped by category -- [Runnable examples](examples/README.md) — copy-paste, ready-to-run example for every endpoint in every language +- [Authentication](docs/authentication.md): get and configure your API key +- [Language guides](#language-guides): install + usage for each SDK +- [Endpoint reference](docs/endpoints/README.md): all 60 endpoints, grouped by category +- [Runnable examples](examples/README.md): copy-paste, ready-to-run example for every endpoint in every language ## Language guides @@ -22,12 +22,12 @@ its language's standard registry. | JavaScript | npm | `whoisfreaks-js` | [Guide](docs/languages/javascript.md) | | TypeScript | npm | `whoisfreaks` | [Guide](docs/languages/typescript.md) | | Java | Maven Central | `com.whoisfreaks:whoisfreaks` | [Guide](docs/languages/java.md) | -| Kotlin | Maven Central | `com.whoisfreaks:whoisfreaks` | [Guide](docs/languages/kotlin.md) | +| Kotlin | Maven Central | `com.whoisfreaks:whoisfreaks-kotlin` | [Guide](docs/languages/kotlin.md) | | C# / .NET | NuGet | `WhoisFreaks` | [Guide](docs/languages/csharp.md) | | Ruby | RubyGems | `whoisfreaks` | [Guide](docs/languages/ruby.md) | | Go | Go modules | `github.com/WhoisFreaks/whoisfreaks-go` | [Guide](docs/languages/go.md) | | Swift | Swift PM | `github.com/WhoisFreaks/whoisfreaks-swift` | [Guide](docs/languages/swift.md) | -| PHP | Packagist | `WhoisFreaks/whoisfreaks-php` | [Guide](docs/languages/php.md) | +| PHP | Packagist | `whoisfreaks/whoisfreaks-php` | [Guide](docs/languages/php.md) | ## Quick start @@ -39,36 +39,36 @@ pip install whoisfreaks ``` ```python +import os import whoisfreaks -from whoisfreaks import Configuration, ApiClient -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" -client = ApiClient(config) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] -result = client.whois_live(domainName="example.com") -print(result) +with whoisfreaks.ApiClient(config) as client: + record = whoisfreaks.WHOISApi(client).whois_live("example.com") + print(record.domain_registrar.registrar_name, record.expiry_date) ``` The equivalent for every other language is in its [language guide](#language-guides). ## Endpoint sections -The API is organized into three sections. See the [full endpoint reference](docs/endpoints/README.md) for every operation with parameters, response fields, and per-language examples. +The API is organized into three sections. See the [full endpoint reference](docs/endpoints/README.md) for every operation with its URL, parameters, response fields and Python, TypeScript and Go examples. The [language guides](#language-guides) show every operation in all 10 languages. -### [API Solutions](docs/endpoints/api-solutions.md) — 20 endpoints +### [API Solutions](docs/endpoints/api-solutions.md) (20 endpoints) Real-time and on-demand lookup APIs. Query a single domain, IP, or ASN and get structured JSON (or XML) back immediately. [WHOIS](docs/endpoints/whois.md), [DNS](docs/endpoints/dns.md), [Domain Availability](docs/endpoints/domain-availability.md), [Typosquatting](docs/endpoints/typosquatting.md), [SSL](docs/endpoints/ssl.md), [Geolocation](docs/endpoints/geolocation.md), [Subdomains](docs/endpoints/subdomains.md), [IP Reputation](docs/endpoints/ip-reputation.md), [Domain Reputation](docs/endpoints/domain-reputation.md), [ASN WHOIS](docs/endpoints/asn-whois.md), [IP WHOIS](docs/endpoints/ip-whois.md) -### [Databases](docs/endpoints/databases.md) — 37 endpoints +### [Databases](docs/endpoints/databases.md) (37 endpoints) -Bulk data feeds and downloadable database snapshots for large-scale processing — newly registered, expiring/dropped, and full WHOIS/DNS/IP datasets. +Bulk data feeds and downloadable database snapshots for large-scale processing: newly registered, expiring/dropped, and full WHOIS/DNS/IP datasets. [Databases - Newly Registered](docs/endpoints/databases-newly-registered.md), [Databases - Expiring & Dropped](docs/endpoints/databases-expiring-dropped.md), [Databases - WHOIS](docs/endpoints/databases-whois.md), [Databases - DNS](docs/endpoints/databases-dns.md), [Databases - Subdomains](docs/endpoints/databases-subdomains.md), [Databases - IP Geolocation](docs/endpoints/databases-ip-geolocation.md), [Databases - ASN WHOIS](docs/endpoints/databases-asn-whois.md), [Databases - IP WHOIS](docs/endpoints/databases-ip-whois.md), [Databases - IP Security](docs/endpoints/databases-ip-security.md), [Databases - Threat Feed](docs/endpoints/databases-threat-feed.md) -### [Account & Utilities](docs/endpoints/account-utilities.md) — 3 endpoints +### [Account & Utilities](docs/endpoints/account-utilities.md) (3 endpoints) Manage your account, monitor API usage and credits, and rotate your API key. @@ -77,24 +77,25 @@ Manage your account, monitor API usage and credits, and rotate your API key. ## Authentication at a glance -All requests require an `apiKey` query parameter. Get a key at -, then configure it once via each SDK's -configuration object — see [Authentication](docs/authentication.md). +Every request except the public database file status check needs an `apiKey` +query parameter. Get a key at , then configure it +once via each SDK's configuration object. See [Authentication](docs/authentication.md). Base URLs: | Purpose | URL | |---------|-----| -| Live lookups | `https://api.whoisfreaks.com` | -| Database downloads | `https://files.whoisfreaks.com` | +| Live lookups, bulk lookups and account | `https://api.whoisfreaks.com` | +| Database downloads, threat feeds and database file status | `https://files.whoisfreaks.com` | ## About these docs These docs are generated from the OpenAPI spec by `scripts/gen_docs.py`, so they -stay in sync with the API. To regenerate after a spec change: +stay in sync with the API. To regenerate after a spec change or an SDK release +(`SDK_VERSION` sets the version in install lines): ```bash -python3 scripts/gen_docs.py path/to/whoisfreaks-openapi.yaml . +SDK_VERSION=0.23.0 python3 scripts/gen_docs.py spec/whoisfreaks-openapi.yaml . ``` ## Support @@ -105,4 +106,4 @@ python3 scripts/gen_docs.py path/to/whoisfreaks-openapi.yaml . ## License -MIT — see individual SDK repositories for details. +MIT. See individual SDK repositories for details. diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..df2b0db --- /dev/null +++ b/_config.yml @@ -0,0 +1,64 @@ +# GitHub Pages site: https://whoisfreaks.github.io +# The Markdown under docs/ and examples/ is generated by scripts/gen_docs.py and +# carries no front matter, so page titles and descriptions for search results +# are set here with front matter defaults instead. +title: WhoisFreaks Docs +description: >- + Documentation for the WhoisFreaks WHOIS, reverse WHOIS, WHOIS history, DNS lookup, + domain availability, IP geolocation and threat intelligence APIs, with official SDKs + for Python, JavaScript, TypeScript, Java, Kotlin, Go, C#, Ruby, PHP and Swift. +url: https://whoisfreaks.github.io +baseurl: "" +lang: en + +plugins: + - jekyll-seo-tag + - jekyll-sitemap + +exclude: + - scripts/ + +defaults: + - scope: { path: "README.md" } + values: + title: "WhoisFreaks API and SDK Documentation: WHOIS, DNS and Domain APIs" + - scope: { path: "docs/endpoints/whois.md" } + values: + title: "WHOIS API: Live, History, Reverse and Bulk WHOIS Lookup" + description: "WHOIS API reference: live WHOIS lookup, WHOIS history back to 1986, reverse WHOIS search by keyword, and bulk WHOIS, with parameters, response fields and SDK examples." + - scope: { path: "docs/endpoints/dns.md" } + values: + title: "DNS Lookup API: Live, Historical, Reverse and Bulk DNS" + description: "DNS lookup API reference: live DNS records (A, AAAA, MX, NS, CNAME, SOA, TXT, SPF), historical DNS, reverse DNS and bulk DNS lookups, with SDK examples." + - scope: { path: "docs/endpoints/domain-availability.md" } + values: + title: "Domain Availability API: Single, Bulk and TLD Suggestions" + description: "Domain availability API reference: check if a domain is available, get up to 100 suggestions on other TLDs, and check up to 100 domains in one request." + - scope: { path: "docs/endpoints/typosquatting.md" } + values: + title: "Typosquatting API: Find Lookalike and Typo Domains" + description: "Typosquatting API reference: find registered domains that look like typo variants of a brand, by keyword or wildcard pattern." + - scope: { path: "docs/endpoints/ip-whois.md" } + values: + title: "IP WHOIS API: IP Address Ownership Lookup" + - scope: { path: "docs/endpoints/asn-whois.md" } + values: + title: "ASN WHOIS API: Autonomous System Lookup" + - scope: { path: "docs/endpoints/ssl.md" } + values: + title: "SSL Certificate API: Live Certificate and Chain Lookup" + - scope: { path: "docs/endpoints/geolocation.md" } + values: + title: "IP Geolocation API: Single and Bulk IP Lookup" + - scope: { path: "docs/endpoints/ip-reputation.md" } + values: + title: "IP Reputation API: IP Threat Intelligence Lookup" + - scope: { path: "docs/endpoints/domain-reputation.md" } + values: + title: "Domain Reputation API: Domain Threat Scoring" + - scope: { path: "docs/endpoints/subdomains.md" } + values: + title: "Subdomains API: Subdomain Enumeration Lookup" + - scope: { path: "docs/endpoints/databases-threat-feed.md" } + values: + title: "Threat Intelligence Feed: Phishing, Malware and Spam Domains" diff --git a/docs/authentication.md b/docs/authentication.md index eb048ce..84ce3ac 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -1,8 +1,9 @@ # Authentication -Every WhoisFreaks API request requires an **API key**, passed as the `apiKey` -query parameter. Each SDK exposes a configuration hook so you set the key once -and it is attached to every request automatically. +Every WhoisFreaks API request needs an **API key**, passed as the `apiKey` +query parameter. The one exception is the public database file status check +(`GET /v3.4/status`). Each SDK exposes a configuration hook so you set the key +once and it is attached to every request automatically. ## Get an API key @@ -12,98 +13,126 @@ In short: 1. Sign in at . 2. Copy your API key from the dashboard. -3. Keep it secret — do **not** commit it to source control. Prefer an - environment variable (e.g. `WHOISFREAKS_API_KEY`). +3. Keep it secret. Do **not** commit it to source control; the examples read it + from the `WHOISFREAKS_API_KEY` environment variable. ## Base URLs | Purpose | Base URL | |---------|----------| -| Live API lookups | `https://api.whoisfreaks.com` | -| Database file downloads | `https://files.whoisfreaks.com` | +| Live lookups, bulk lookups and account | `https://api.whoisfreaks.com` | +| Database downloads, threat feeds and database file status | `https://files.whoisfreaks.com` | + +The SDKs pick the right host for each endpoint; every endpoint page shows its full URL. ## Setting the key per language ### Python ```python -"""Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi +"""Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live -# Parameters for whoisLive (GET /v2.0/whois/live): -# - domainName (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisLive.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.whois_live(domain_name="example.com") -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + # whois_live parameters: + # domain_name (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.whois_live("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ``` ### JavaScript ```javascript -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) -// Parameters for whoisLive (GET /v2.0/whois/live): -// - domainName (string, required) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live +// Run: WHOISFREAKS_API_KEY=your_api_key node WhoisLive.js +const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.whoisLive("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// whoisLive(domainName, opts) +// domainName (string, required) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.whoisLive("whoisfreaks.com"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### TypeScript ```typescript -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) -// Parameters for whoisLive (GET /v2.0/whois/live): -// - domainName (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; +// Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisLive.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisLive({ domainName: "example.com", format: undefined }); - console.log(result); +// whoisLive({ domainName, format? }) +// domainName (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.whoisLive({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Java ```java // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=WhoisLive // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.WhoisResponse; public class WhoisLive { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.whoisLive("example.com", null); + + // whoisLive(domainName, format); null leaves an optional parameter unset + WhoisResponse result = api.whoisLive("whoisfreaks.com", null); System.out.println(result); } } @@ -114,6 +143,7 @@ public class WhoisLive { ```kotlin // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: gradle run -PmainClass=WhoisLiveKt // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) @@ -121,9 +151,10 @@ import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.whoisLive("example.com", null) + + val result = api.whoisLive("whoisfreaks.com") println(result) } @@ -133,41 +164,52 @@ fun main() { ```csharp // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class WhoisLive { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.WhoisLive("example.com", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +WhoisResponse result = api.WhoisLive("whoisfreaks.com"); +Console.WriteLine(result.ToJson()); ``` ### Ruby ```ruby -# Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +# Live WHOIS Lookup +# # Parameters for whoisLive (GET /v2.0/whois/live): -# - domainName (string, required) +# - domain_name (string, required) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.whois_live("example.com") -puts result + +begin + result = api.whois_live("whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -175,28 +217,35 @@ puts result ```go // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -204,20 +253,30 @@ func main() { ### Swift ```swift -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Live WHOIS Lookup +// // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await WHOISAPI.whoisLive(domainName: "example.com", format: nil) - print(result) + let result = try await WHOISAPI.whoisLive(domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -226,16 +285,31 @@ do { ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->whoisLive("example.com", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\WHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new WHOISApi(new Client(), $config); + +try { + $result = $api->whoisLive('whoisfreaks.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` diff --git a/docs/endpoints/README.md b/docs/endpoints/README.md index 044b098..29dfad4 100644 --- a/docs/endpoints/README.md +++ b/docs/endpoints/README.md @@ -6,44 +6,44 @@ The WhoisFreaks API exposes **60 endpoints** across **22 categories**, organized Real-time and on-demand lookup APIs. Query a single domain, IP, or ASN and get structured JSON (or XML) back immediately. -20 endpoints across 11 categories — see the [API Solutions overview](api-solutions.md). +20 endpoints across 11 categories. See the [API Solutions overview](api-solutions.md). -- [WHOIS](whois.md) — 4 endpoint(s) -- [DNS](dns.md) — 4 endpoint(s) -- [Domain Availability](domain-availability.md) — 2 endpoint(s) -- [Typosquatting](typosquatting.md) — 1 endpoint(s) -- [SSL](ssl.md) — 1 endpoint(s) -- [Geolocation](geolocation.md) — 2 endpoint(s) -- [Subdomains](subdomains.md) — 1 endpoint(s) -- [IP Reputation](ip-reputation.md) — 2 endpoint(s) -- [Domain Reputation](domain-reputation.md) — 1 endpoint(s) -- [ASN WHOIS](asn-whois.md) — 1 endpoint(s) -- [IP WHOIS](ip-whois.md) — 1 endpoint(s) +- [WHOIS](whois.md): 4 endpoints +- [DNS](dns.md): 4 endpoints +- [Domain Availability](domain-availability.md): 2 endpoints +- [Typosquatting](typosquatting.md): 1 endpoint +- [SSL](ssl.md): 1 endpoint +- [Geolocation](geolocation.md): 2 endpoints +- [Subdomains](subdomains.md): 1 endpoint +- [IP Reputation](ip-reputation.md): 2 endpoints +- [Domain Reputation](domain-reputation.md): 1 endpoint +- [ASN WHOIS](asn-whois.md): 1 endpoint +- [IP WHOIS](ip-whois.md): 1 endpoint ## Databases -Bulk data feeds and downloadable database snapshots for large-scale processing — newly registered, expiring/dropped, and full WHOIS/DNS/IP datasets. +Bulk data feeds and downloadable database snapshots for large-scale processing: newly registered, expiring/dropped, and full WHOIS/DNS/IP datasets. -37 endpoints across 10 categories — see the [Databases overview](databases.md). +37 endpoints across 10 categories. See the [Databases overview](databases.md). -- [Databases - Newly Registered](databases-newly-registered.md) — 7 endpoint(s) -- [Databases - Expiring & Dropped](databases-expiring-dropped.md) — 5 endpoint(s) -- [Databases - WHOIS](databases-whois.md) — 3 endpoint(s) -- [Databases - DNS](databases-dns.md) — 3 endpoint(s) -- [Databases - Subdomains](databases-subdomains.md) — 3 endpoint(s) -- [Databases - IP Geolocation](databases-ip-geolocation.md) — 4 endpoint(s) -- [Databases - ASN WHOIS](databases-asn-whois.md) — 2 endpoint(s) -- [Databases - IP WHOIS](databases-ip-whois.md) — 2 endpoint(s) -- [Databases - IP Security](databases-ip-security.md) — 2 endpoint(s) -- [Databases - Threat Feed](databases-threat-feed.md) — 6 endpoint(s) +- [Databases - Newly Registered](databases-newly-registered.md): 7 endpoints +- [Databases - Expiring & Dropped](databases-expiring-dropped.md): 5 endpoints +- [Databases - WHOIS](databases-whois.md): 3 endpoints +- [Databases - DNS](databases-dns.md): 3 endpoints +- [Databases - Subdomains](databases-subdomains.md): 3 endpoints +- [Databases - IP Geolocation](databases-ip-geolocation.md): 4 endpoints +- [Databases - ASN WHOIS](databases-asn-whois.md): 2 endpoints +- [Databases - IP WHOIS](databases-ip-whois.md): 2 endpoints +- [Databases - IP Security](databases-ip-security.md): 2 endpoints +- [Databases - Threat Feed](databases-threat-feed.md): 6 endpoints ## Account & Utilities Manage your account, monitor API usage and credits, and rotate your API key. -3 endpoints across 1 categories — see the [Account & Utilities overview](account-utilities.md). +3 endpoints across 1 category. See the [Account & Utilities overview](account-utilities.md). -- [Account](account.md) — 3 endpoint(s) +- [Account](account.md): 3 endpoints ## Full endpoint list diff --git a/docs/endpoints/account-utilities.md b/docs/endpoints/account-utilities.md index 4e334d0..07b2a5f 100644 --- a/docs/endpoints/account-utilities.md +++ b/docs/endpoints/account-utilities.md @@ -2,7 +2,7 @@ Manage your account, monitor API usage and credits, and rotate your API key. -**3 endpoints** across **1 categories**. All requests require your API key — see [Authentication](../authentication.md). +**3 endpoints** across **1 category**. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Categories @@ -10,8 +10,8 @@ Manage your account, monitor API usage and credits, and rotate your API key. Account, API key, and usage utilities -3 endpoint(s): +3 endpoints: -- **Rotate API Key** — `GET /v1.0/api-key/rotate` -- **Account Usage** — `GET /v1.0/whoisapi/usage` -- **Database File Status (Public)** — `GET /v3.4/status` +- **Rotate API Key**: `GET /v1.0/api-key/rotate` +- **Account Usage**: `GET /v1.0/whoisapi/usage` +- **Database File Status (Public)**: `GET /v3.4/status` diff --git a/docs/endpoints/account.md b/docs/endpoints/account.md index cfa098d..14aec86 100644 --- a/docs/endpoints/account.md +++ b/docs/endpoints/account.md @@ -4,37 +4,41 @@ Account, API key, and usage utilities -3 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +3 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Rotate API Key -`GET /v1.0/api-key/rotate` +`GET https://api.whoisfreaks.com/v1.0/api-key/rotate` Rotate API Key. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Usage**
Python ```python -"""Runnable example: Rotate API Key (GET /v1.0/api-key/rotate).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.account_api import AccountApi +"""Rotate API Key: GET https://api.whoisfreaks.com/v1.0/api-key/rotate -# Parameters for rotateApiKey (GET /v1.0/api-key/rotate): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = AccountApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python RotateApiKey.py +""" +import os -result = api.rotate_api_key() -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.AccountApi(client) + + # rotate_api_key takes no parameters. + new_key = api.rotate_api_key() # use this key from now on + print("New API key:", new_key) ```
@@ -42,20 +46,29 @@ print(result)
TypeScript ```typescript -// Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) -// Parameters for rotateApiKey (GET /v1.0/api-key/rotate): -// (no parameters; the API key is set on the client) -import { Configuration, AccountApi } from "whoisfreaks"; +// Rotate API Key: GET https://api.whoisfreaks.com/v1.0/api-key/rotate +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx RotateApiKey.ts +import { Configuration, AccountApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new AccountApi(config); -async function main() { - const result = await api.rotateApiKey({ }); - console.log(result); +// rotateApiKey() takes no parameters. +async function main(): Promise { + const newKey = await api.rotateApiKey(); // use this key from now on + console.log("New API key:", newKey); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -64,27 +77,33 @@ main().catch(console.error); ```go // Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.AccountAPI.RotateApiKey(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + newKey, _, err := client.AccountAPI.RotateApiKey(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY. + fmt.Println("New API key:", newKey) } ``` @@ -95,14 +114,13 @@ func main() { ## Account Usage -`GET /v1.0/whoisapi/usage` +`GET https://api.whoisfreaks.com/v1.0/whoisapi/usage` Account Usage. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Response** (`AccountUsageResponse`) @@ -139,19 +157,25 @@ Account Usage. Returns the file/snapshot described by this operation.
Python ```python -"""Runnable example: Account Usage (GET /v1.0/whoisapi/usage).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.account_api import AccountApi +"""Account Usage: GET https://api.whoisfreaks.com/v1.0/whoisapi/usage + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python AccountUsage.py +""" +import json +import os + +import whoisfreaks -# Parameters for accountUsage (GET /v1.0/whoisapi/usage): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = AccountApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.account_usage() -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.AccountApi(client) + # account_usage takes no parameters. + result = api.account_usage() + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -159,20 +183,29 @@ print(result)
TypeScript ```typescript -// Runnable example: Account Usage (GET /v1.0/whoisapi/usage) -// Parameters for accountUsage (GET /v1.0/whoisapi/usage): -// (no parameters; the API key is set on the client) -import { Configuration, AccountApi } from "whoisfreaks"; +// Account Usage: GET https://api.whoisfreaks.com/v1.0/whoisapi/usage +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx AccountUsage.ts +import { Configuration, AccountApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new AccountApi(config); -async function main() { - const result = await api.accountUsage({ }); - console.log(result); +// accountUsage() takes no parameters. +async function main(): Promise { + const result = await api.accountUsage(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -181,27 +214,34 @@ main().catch(console.error); ```go // Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.AccountAPI.AccountUsage(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.AccountAPI.AccountUsage(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -212,14 +252,15 @@ func main() { ## Database File Status (Public) -`GET /v3.4/status` +`GET https://files.whoisfreaks.com/v3.4/status` + +Public endpoint: no API key required. No API key required. Returns freshness of all downloadable files. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Response** (`DatabaseFileStatus`) @@ -281,19 +322,24 @@ No API key required. Returns freshness of all downloadable files.
Python ```python -"""Runnable example: Database File Status (Public) (GET /v3.4/status).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.account_api import AccountApi +"""Database File Status (Public): GET https://files.whoisfreaks.com/v3.4/status -# Parameters for databaseFileStatus (GET /v3.4/status): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = AccountApi(ApiClient(config)) +Run it (public endpoint, no API key needed): + python DatabaseFileStatus.py +""" +import json -result = api.database_file_status() -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +# Public endpoint: no API key needed. + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.AccountApi(client) + + # database_file_status takes no parameters. + result = api.database_file_status() + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -301,20 +347,28 @@ print(result)
TypeScript ```typescript -// Runnable example: Database File Status (Public) (GET /v3.4/status) -// Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) -import { Configuration, AccountApi } from "whoisfreaks"; +// Database File Status (Public): GET https://files.whoisfreaks.com/v3.4/status +// Run (public endpoint, no API key needed): npx tsx DatabaseFileStatus.ts +import { AccountApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once -const api = new AccountApi(config); +// Public endpoint: no API key needed. +const api = new AccountApi(); -async function main() { - const result = await api.databaseFileStatus({ }); - console.log(result); +// databaseFileStatus() takes no parameters. +async function main(): Promise { + const result = await api.databaseFileStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -323,27 +377,32 @@ main().catch(console.error); ```go // Runnable example: Database File Status (Public) (GET /v3.4/status) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.AccountAPI.DatabaseFileStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Public endpoint: no API key needed. + ctx := context.Background() + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.AccountAPI.DatabaseFileStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/api-solutions.md b/docs/endpoints/api-solutions.md index 7226c7d..0e3b6ad 100644 --- a/docs/endpoints/api-solutions.md +++ b/docs/endpoints/api-solutions.md @@ -2,7 +2,7 @@ Real-time and on-demand lookup APIs. Query a single domain, IP, or ASN and get structured JSON (or XML) back immediately. -**20 endpoints** across **11 categories**. All requests require your API key — see [Authentication](../authentication.md). +**20 endpoints** across **11 categories**. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Categories @@ -10,95 +10,95 @@ Real-time and on-demand lookup APIs. Query a single domain, IP, or ASN and get s WHOIS lookup APIs (live, historical, reverse, bulk) -4 endpoint(s): +4 endpoints: -- **Live WHOIS Lookup** — `GET /v2.0/whois/live` -- **Bulk WHOIS Lookup** — `POST /v2.0/bulkwhois/live` -- **Historical WHOIS records for a domain** — `GET /v2.0/whois/history` -- **Reverse WHOIS lookup by keyword** — `GET /v2.0/whois/reverse` +- **Live WHOIS Lookup**: `GET /v2.0/whois/live` +- **Bulk WHOIS Lookup**: `POST /v2.0/bulkwhois/live` +- **Historical WHOIS records for a domain**: `GET /v2.0/whois/history` +- **Reverse WHOIS lookup by keyword**: `GET /v2.0/whois/reverse` ### [DNS](dns.md) DNS lookup APIs (live, historical, reverse, bulk) -4 endpoint(s): +4 endpoints: -- **Live DNS Lookup** — `GET /v2.0/dns/live` -- **Historical DNS Lookup** — `GET /v2.0/dns/historical` -- **Reverse DNS Lookup** — `GET /v2.1/dns/reverse` -- **Bulk DNS Lookup** — `POST /v2.0/dns/bulk/live` +- **Live DNS Lookup**: `GET /v2.0/dns/live` +- **Historical DNS Lookup**: `GET /v2.0/dns/historical` +- **Reverse DNS Lookup**: `GET /v2.1/dns/reverse` +- **Bulk DNS Lookup**: `POST /v2.0/dns/bulk/live` ### [Domain Availability](domain-availability.md) Check domain availability -2 endpoint(s): +2 endpoints: -- **Domain Availability Check with Suggestions** — `GET /v2.0/domain/availability` -- **Bulk Domain Availability Check** — `POST /v2.0/domain/availability` +- **Domain Availability Check with Suggestions**: `GET /v2.0/domain/availability` +- **Bulk Domain Availability Check**: `POST /v2.0/domain/availability` ### [Typosquatting](typosquatting.md) Detect typo variants of brand domains -1 endpoint(s): +1 endpoint: -- **Typosquatting Lookup** — `GET /v3.0/domain/typos` +- **Typosquatting Lookup**: `GET /v3.0/domain/typos` ### [SSL](ssl.md) SSL certificate lookup -1 endpoint(s): +1 endpoint: -- **SSL Certificate Lookup** — `GET /v1.0/ssl/live` +- **SSL Certificate Lookup**: `GET /v1.0/ssl/live` ### [Geolocation](geolocation.md) IP geolocation lookup -2 endpoint(s): +2 endpoints: -- **IP Geolocation Lookup** — `GET /v1.0/geolocation` -- **Bulk IP Geolocation** — `POST /v1.0/geolocation` +- **IP Geolocation Lookup**: `GET /v1.0/geolocation` +- **Bulk IP Geolocation**: `POST /v1.0/geolocation` ### [Subdomains](subdomains.md) Subdomain enumeration -1 endpoint(s): +1 endpoint: -- **Subdomains Lookup** — `GET /v1.0/subdomains` +- **Subdomains Lookup**: `GET /v1.0/subdomains` ### [IP Reputation](ip-reputation.md) IP threat intelligence -2 endpoint(s): +2 endpoints: -- **IP Reputation Lookup** — `GET /v1.0/security` -- **Bulk IP Reputation** — `POST /v1.0/security` +- **IP Reputation Lookup**: `GET /v1.0/security` +- **Bulk IP Reputation**: `POST /v1.0/security` ### [Domain Reputation](domain-reputation.md) Real-time domain threat assessment and trust scoring -1 endpoint(s): +1 endpoint: -- **Domain Reputation Lookup** — `GET /v1/domain/security` +- **Domain Reputation Lookup**: `GET /v1/domain/security` ### [ASN WHOIS](asn-whois.md) Autonomous System Number WHOIS -1 endpoint(s): +1 endpoint: -- **ASN WHOIS Lookup** — `GET /v2.0/asn-whois` +- **ASN WHOIS Lookup**: `GET /v2.0/asn-whois` ### [IP WHOIS](ip-whois.md) IP address WHOIS -1 endpoint(s): +1 endpoint: -- **IP WHOIS Lookup** — `GET /v1.0/ip-whois` +- **IP WHOIS Lookup**: `GET /v1.0/ip-whois` diff --git a/docs/endpoints/asn-whois.md b/docs/endpoints/asn-whois.md index 92277e6..c21119b 100644 --- a/docs/endpoints/asn-whois.md +++ b/docs/endpoints/asn-whois.md @@ -4,20 +4,20 @@ Autonomous System Number WHOIS -1 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +1 endpoint. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## ASN WHOIS Lookup -`GET /v2.0/asn-whois` +`GET https://api.whoisfreaks.com/v2.0/asn-whois` WHOIS for an ASN. 1 credit. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `asn` | query | yes | string | | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `asn` | query | yes | string | | | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`AsnWhoisResponse`) @@ -54,20 +54,27 @@ WHOIS for an ASN. 1 credit.
Python ```python -"""Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.asnwhois_api import ASNWHOISApi +"""ASN WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/asn-whois -# Parameters for asnWhois (GET /v2.0/asn-whois): -# - asn (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = ASNWHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python AsnWhois.py +""" +import json +import os -result = api.asn_whois(asn="AS15169") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.ASNWHOISApi(client) + + # asn_whois parameters: + # asn (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.asn_whois("as15169") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -75,21 +82,31 @@ print(result)
TypeScript ```typescript -// Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) -// Parameters for asnWhois (GET /v2.0/asn-whois): -// - asn (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, ASNWHOISApi } from "whoisfreaks"; +// ASN WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/asn-whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx AsnWhois.ts +import { Configuration, ASNWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new ASNWHOISApi(config); -async function main() { - const result = await api.asnWhois({ asn: "AS15169", format: undefined }); - console.log(result); +// asnWhois({ asn, format? }) +// asn (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.asnWhois({ asn: "as15169" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -98,28 +115,35 @@ main().catch(console.error); ```go // Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.ASNWHOISAPI.AsnWhois(ctx).Asn("AS15169").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.ASNWHOISAPI.AsnWhois(ctx).Asn("as15169").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/databases-asn-whois.md b/docs/endpoints/databases-asn-whois.md index 74676b0..741959a 100644 --- a/docs/endpoints/databases-asn-whois.md +++ b/docs/endpoints/databases-asn-whois.md @@ -4,42 +4,48 @@ ASN WHOIS database snapshots -2 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +2 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## ASN WHOIS Snapshot -`GET /v3.3/download/snapshot/asn/whois` +`GET https://files.whoisfreaks.com/v3.3/download/snapshot/asn/whois` ASN WHOIS Snapshot. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | yes | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | yes | string (date) | | | **Usage**
Python ```python -"""Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_asnwhois_api import DatabasesASNWHOISApi - -# Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesASNWHOISApi(ApiClient(config)) - -data = api.db_asn_whois(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbAsnWhois.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbAsnWhois.gz") +"""ASN WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/asn/whois +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbAsnWhois.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesASNWHOISApi(client) + + # db_asn_whois parameters: + # var_date (datetime.date, required) + data = api.db_asn_whois(date(2026, 10, 1)) # the file's raw bytes + path = "DbAsnWhois.json.gz" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -47,20 +53,34 @@ print(f"saved {len(data)} bytes to dbAsnWhois.gz")
TypeScript ```typescript -// Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) -// Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): -// - date (string, required) -import { Configuration, DatabasesASNWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// ASN WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbAsnWhois.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesASNWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesASNWHOISApi(config); -async function main() { - const result = await api.dbAsnWhois({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbAsnWhois({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbAsnWhois({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbAsnWhois.json.gz"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -69,29 +89,48 @@ main().catch(console.error); ```go // Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesASNWHOISAPI.DbAsnWhois(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbAsnWhois.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbAsnWhois.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesASNWHOISAPI.DbAsnWhois(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbAsnWhois.json.gz") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -102,14 +141,13 @@ func main() { ## ASN WHOIS Snapshot Status -`GET /v3.3/status/snapshot/asn/whois` +`GET https://files.whoisfreaks.com/v3.3/status/snapshot/asn/whois` ASN WHOIS Snapshot Status. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Response** (`SnapshotStatus`) @@ -127,19 +165,25 @@ ASN WHOIS Snapshot Status. Returns the file/snapshot described by this operation
Python ```python -"""Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_asnwhois_api import DatabasesASNWHOISApi +"""ASN WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/asn/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbAsnWhoisStatus.py +""" +import json +import os -# Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesASNWHOISApi(ApiClient(config)) +import whoisfreaks -result = api.db_asn_whois_status() -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesASNWHOISApi(client) + + # db_asn_whois_status takes no parameters. + result = api.db_asn_whois_status() + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -147,20 +191,29 @@ print(result)
TypeScript ```typescript -// Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) -// Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesASNWHOISApi } from "whoisfreaks"; +// ASN WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbAsnWhoisStatus.ts +import { Configuration, DatabasesASNWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesASNWHOISApi(config); -async function main() { - const result = await api.dbAsnWhoisStatus({ }); - console.log(result); +// dbAsnWhoisStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbAsnWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -169,27 +222,34 @@ main().catch(console.error); ```go // Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesASNWHOISAPI.DbAsnWhoisStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesASNWHOISAPI.DbAsnWhoisStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/databases-dns.md b/docs/endpoints/databases-dns.md index 5679e29..13fd309 100644 --- a/docs/endpoints/databases-dns.md +++ b/docs/endpoints/databases-dns.md @@ -4,42 +4,48 @@ DNS database snapshots -3 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +3 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## DNS Database Daily -`GET /v3.2/download/dbupdate/daily/dns` +`GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/dns` DNS Database Daily. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_dns_api import DatabasesDNSApi - -# Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesDNSApi(ApiClient(config)) - -data = api.db_dns_daily(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDnsDaily.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDnsDaily.gz") +"""DNS Database Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/dns +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDnsDaily.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesDNSApi(client) + + # db_dns_daily parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dns_daily(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDnsDaily.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -47,20 +53,34 @@ print(f"saved {len(data)} bytes to dbDnsDaily.gz")
TypeScript ```typescript -// Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) -// Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesDNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// DNS Database Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDnsDaily.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesDNSApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesDNSApi(config); -async function main() { - const result = await api.dbDnsDaily({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDnsDaily({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDnsDaily({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDnsDaily.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -69,29 +89,48 @@ main().catch(console.error); ```go // Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesDNSAPI.DbDnsDaily(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDnsDaily.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDnsDaily.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesDNSAPI.DbDnsDaily(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDnsDaily.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -102,38 +141,44 @@ func main() { ## DNS Database Weekly -`GET /v3.2/download/dbupdate/weekly/dns` +`GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/dns` DNS Database Weekly. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_dns_api import DatabasesDNSApi - -# Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesDNSApi(ApiClient(config)) - -data = api.db_dns_weekly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDnsWeekly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDnsWeekly.gz") +"""DNS Database Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/dns + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDnsWeekly.py +""" +import os +from datetime import date + +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesDNSApi(client) + + # db_dns_weekly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dns_weekly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDnsWeekly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -141,20 +186,34 @@ print(f"saved {len(data)} bytes to dbDnsWeekly.gz")
TypeScript ```typescript -// Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) -// Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesDNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// DNS Database Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDnsWeekly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesDNSApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesDNSApi(config); -async function main() { - const result = await api.dbDnsWeekly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDnsWeekly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDnsWeekly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDnsWeekly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -163,29 +222,48 @@ main().catch(console.error); ```go // Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesDNSAPI.DbDnsWeekly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDnsWeekly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDnsWeekly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesDNSAPI.DbDnsWeekly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDnsWeekly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -196,38 +274,44 @@ func main() { ## DNS Database Monthly -`GET /v3.2/download/dbupdate/monthly/dns` +`GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/dns` DNS Database Monthly. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_dns_api import DatabasesDNSApi - -# Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesDNSApi(ApiClient(config)) - -data = api.db_dns_monthly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDnsMonthly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDnsMonthly.gz") +"""DNS Database Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/dns + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDnsMonthly.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesDNSApi(client) + + # db_dns_monthly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dns_monthly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDnsMonthly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -235,20 +319,34 @@ print(f"saved {len(data)} bytes to dbDnsMonthly.gz")
TypeScript ```typescript -// Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) -// Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesDNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// DNS Database Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDnsMonthly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesDNSApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesDNSApi(config); -async function main() { - const result = await api.dbDnsMonthly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDnsMonthly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDnsMonthly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDnsMonthly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -257,29 +355,48 @@ main().catch(console.error); ```go // Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesDNSAPI.DbDnsMonthly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDnsMonthly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDnsMonthly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesDNSAPI.DbDnsMonthly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDnsMonthly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` diff --git a/docs/endpoints/databases-expiring-dropped.md b/docs/endpoints/databases-expiring-dropped.md index d8ebf18..5c29317 100644 --- a/docs/endpoints/databases-expiring-dropped.md +++ b/docs/endpoints/databases-expiring-dropped.md @@ -4,44 +4,50 @@ Expiring and dropped domain downloads -5 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +5 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Expiring Domains -`GET /v3.1/download/domainer/expired` +`GET https://files.whoisfreaks.com/v3.1/download/domainer/expired` Expiring Domains. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `whois` | query | yes | boolean | | -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `whois` | query | yes | boolean | | | +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi - -# Parameters for dbExpired (GET /v3.1/download/domainer/expired): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) - -data = api.db_expired(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbExpired.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbExpired.gz") - +"""Expiring Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbExpired.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_expired parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_expired(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbExpired.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -49,21 +55,35 @@ print(f"saved {len(data)} bytes to dbExpired.gz")
TypeScript ```typescript -// Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) -// Parameters for dbExpired (GET /v3.1/download/domainer/expired): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Expiring Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbExpired.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbExpired({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbExpired({ whois, date? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbExpired({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbExpired.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -72,30 +92,50 @@ main().catch(console.error); ```go // Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbExpired(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbExpired.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbExpired.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbExpired(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbExpired.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -106,38 +146,44 @@ func main() { ## Expiring Cleaned WHOIS -`GET /v3.1/download/domainer/expired/cleaned` +`GET https://files.whoisfreaks.com/v3.1/download/domainer/expired/cleaned` Expiring Cleaned WHOIS. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi - -# Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) - -data = api.db_expired_cleaned(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbExpiredCleaned.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbExpiredCleaned.gz") +"""Expiring Cleaned WHOIS: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired/cleaned + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbExpiredCleaned.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_expired_cleaned parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_expired_cleaned(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbExpiredCleaned.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -145,20 +191,34 @@ print(f"saved {len(data)} bytes to dbExpiredCleaned.gz")
TypeScript ```typescript -// Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) -// Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Expiring Cleaned WHOIS: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbExpiredCleaned.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbExpiredCleaned({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbExpiredCleaned({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbExpiredCleaned({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbExpiredCleaned.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -167,29 +227,49 @@ main().catch(console.error); ```go // Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbExpiredCleaned(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbExpiredCleaned.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbExpiredCleaned.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbExpiredCleaned(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbExpiredCleaned.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -200,40 +280,46 @@ func main() { ## Dropped Domains -`GET /v3.1/download/domainer/dropped` +`GET https://files.whoisfreaks.com/v3.1/download/domainer/dropped` Dropped Domains. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `whois` | query | yes | boolean | | -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `whois` | query | yes | boolean | | | +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi - -# Parameters for dbDropped (GET /v3.1/download/domainer/dropped): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) - -data = api.db_dropped(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDropped.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDropped.gz") - +"""Dropped Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/dropped + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDropped.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_dropped parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dropped(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDropped.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -241,21 +327,35 @@ print(f"saved {len(data)} bytes to dbDropped.gz")
TypeScript ```typescript -// Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) -// Parameters for dbDropped (GET /v3.1/download/domainer/dropped): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Dropped Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDropped.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbDropped({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDropped({ whois, date? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDropped({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDropped.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -264,30 +364,50 @@ main().catch(console.error); ```go // Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbDropped(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDropped.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDropped.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbDropped(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDropped.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -298,37 +418,44 @@ func main() { ## Dropped Domains (JSON) -`GET /v3.1/domains/dropped` +`GET https://files.whoisfreaks.com/v3.1/domains/dropped` Dropped Domains (JSON). Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | -| `tlds` | query | no | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | +| `tlds` | query | no | string | | | **Usage**
Python ```python -"""Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Dropped Domains (JSON): GET https://files.whoisfreaks.com/v3.1/domains/dropped + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDroppedJson.py +""" +import os +from datetime import date -# Parameters for dbDroppedJson (GET /v3.1/domains/dropped): -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +import whoisfreaks -result = api.db_dropped_json(var_date=str(date.today() - timedelta(days=1))) -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_dropped_json parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + domains = api.db_dropped_json(var_date=date(2026, 10, 1)) + print(f"{len(domains)} domains") + print("\n".join(domains[:10])) ```
@@ -336,21 +463,32 @@ print(result)
TypeScript ```typescript -// Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) -// Parameters for dbDroppedJson (GET /v3.1/domains/dropped): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; +// Dropped Domains (JSON): GET https://files.whoisfreaks.com/v3.1/domains/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDroppedJson.ts +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbDroppedJson({ date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbDroppedJson({ date?, tlds? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const domains = await api.dbDroppedJson({ date: new Date("2026-10-01") }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -359,29 +497,36 @@ main().catch(console.error); ```go // Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedJson(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedJson(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -392,40 +537,46 @@ func main() { ## Dropped With Backlinks -`GET /v3.3/download/domainer/dropped/backlinks` +`GET https://files.whoisfreaks.com/v3.3/download/domainer/dropped/backlinks` Dropped With Backlinks. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `whois` | query | no | boolean | | -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `whois` | query | no | boolean | | | +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi - -# Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): -# - whois (boolean, optional) -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) - -data = api.db_dropped_backlinks(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDroppedBacklinks.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDroppedBacklinks.gz") - +"""Dropped With Backlinks: GET https://files.whoisfreaks.com/v3.3/download/domainer/dropped/backlinks + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDroppedBacklinks.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_dropped_backlinks parameters: + # whois (bool, optional, keyword) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dropped_backlinks(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDroppedBacklinks.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -433,21 +584,35 @@ print(f"saved {len(data)} bytes to dbDroppedBacklinks.gz")
TypeScript ```typescript -// Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) -// Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): -// - whois (boolean, optional) -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Dropped With Backlinks: GET https://files.whoisfreaks.com/v3.3/download/domainer/dropped/backlinks +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDroppedBacklinks.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbDroppedBacklinks({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDroppedBacklinks({ whois?, date? }) +// whois (boolean, optional) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDroppedBacklinks({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDroppedBacklinks.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -456,30 +621,50 @@ main().catch(console.error); ```go // Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedBacklinks(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDroppedBacklinks.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDroppedBacklinks.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedBacklinks(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDroppedBacklinks.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` diff --git a/docs/endpoints/databases-ip-geolocation.md b/docs/endpoints/databases-ip-geolocation.md index d2cfe78..3e671b5 100644 --- a/docs/endpoints/databases-ip-geolocation.md +++ b/docs/endpoints/databases-ip-geolocation.md @@ -4,18 +4,17 @@ IP geolocation database snapshots -4 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +4 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## IP to Country Snapshot Status -`GET /v3.3/status/snapshot/ip/country` +`GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/country` IP to Country Snapshot Status. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Response** (`SnapshotStatus`) @@ -33,19 +32,25 @@ IP to Country Snapshot Status. Returns the file/snapshot described by this opera
Python ```python -"""Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi +"""IP to Country Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/country -# Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCountryStatus.py +""" +import json +import os -result = api.db_ip_country_status() -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_country_status takes no parameters. + result = api.db_ip_country_status() + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -53,20 +58,29 @@ print(result)
TypeScript ```typescript -// Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) -// Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; +// IP to Country Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCountryStatus.ts +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCountryStatus({ }); - console.log(result); +// dbIpCountryStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpCountryStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -75,27 +89,34 @@ main().catch(console.error); ```go // Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPGeolocationAPI.DbIpCountryStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPGeolocationAPI.DbIpCountryStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -106,38 +127,44 @@ func main() { ## IP to Country Snapshot -`GET /v3.3/download/snapshot/ip/country` +`GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/country` IP to Country Snapshot. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | yes | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | yes | string (date) | | | **Usage**
Python ```python -"""Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi - -# Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) - -data = api.db_ip_country(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpCountry.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpCountry.gz") +"""IP to Country Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/country + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCountry.py +""" +import os +from datetime import date +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_country parameters: + # var_date (datetime.date, required) + data = api.db_ip_country(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpCountry.zip" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -145,20 +172,34 @@ print(f"saved {len(data)} bytes to dbIpCountry.gz")
TypeScript ```typescript -// Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) -// Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): -// - date (string, required) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// IP to Country Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCountry.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCountry({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpCountry({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpCountry({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpCountry.zip"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -167,29 +208,48 @@ main().catch(console.error); ```go // Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPGeolocationAPI.DbIpCountry(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpCountry.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpCountry.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPGeolocationAPI.DbIpCountry(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpCountry.zip") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -200,14 +260,13 @@ func main() { ## IP to City Snapshot Status -`GET /v3.3/status/snapshot/ip/city` +`GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/city` IP to City Snapshot Status. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Response** (`SnapshotStatus`) @@ -225,19 +284,25 @@ IP to City Snapshot Status. Returns the file/snapshot described by this operatio
Python ```python -"""Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi +"""IP to City Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/city -# Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCityStatus.py +""" +import json +import os -result = api.db_ip_city_status() -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_city_status takes no parameters. + result = api.db_ip_city_status() + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -245,20 +310,29 @@ print(result)
TypeScript ```typescript -// Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) -// Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; +// IP to City Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCityStatus.ts +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCityStatus({ }); - console.log(result); +// dbIpCityStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpCityStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -267,27 +341,34 @@ main().catch(console.error); ```go // Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPGeolocationAPI.DbIpCityStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPGeolocationAPI.DbIpCityStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -298,38 +379,44 @@ func main() { ## IP to City Snapshot -`GET /v3.3/download/snapshot/ip/city` +`GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/city` IP to City Snapshot. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | yes | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | yes | string (date) | | | **Usage**
Python ```python -"""Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi - -# Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) - -data = api.db_ip_city(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpCity.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpCity.gz") +"""IP to City Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/city + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCity.py +""" +import os +from datetime import date +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_city parameters: + # var_date (datetime.date, required) + data = api.db_ip_city(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpCity.zip" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -337,20 +424,34 @@ print(f"saved {len(data)} bytes to dbIpCity.gz")
TypeScript ```typescript -// Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) -// Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): -// - date (string, required) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// IP to City Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCity.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCity({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpCity({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpCity({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpCity.zip"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -359,29 +460,48 @@ main().catch(console.error); ```go // Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPGeolocationAPI.DbIpCity(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpCity.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpCity.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPGeolocationAPI.DbIpCity(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpCity.zip") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` diff --git a/docs/endpoints/databases-ip-security.md b/docs/endpoints/databases-ip-security.md index 2b6f300..96cddc5 100644 --- a/docs/endpoints/databases-ip-security.md +++ b/docs/endpoints/databases-ip-security.md @@ -4,42 +4,48 @@ IP security database snapshots -2 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +2 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## IP Security Snapshot -`GET /v3.3/download/snapshot/ip/security` +`GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/security` IP Security Snapshot. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | yes | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | yes | string (date) | | | **Usage**
Python ```python -"""Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_security_api import DatabasesIPSecurityApi - -# Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPSecurityApi(ApiClient(config)) - -data = api.db_ip_security(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpSecurity.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpSecurity.gz") +"""IP Security Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/security +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpSecurity.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPSecurityApi(client) + + # db_ip_security parameters: + # var_date (datetime.date, required) + data = api.db_ip_security(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpSecurity.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -47,20 +53,34 @@ print(f"saved {len(data)} bytes to dbIpSecurity.gz")
TypeScript ```typescript -// Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) -// Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): -// - date (string, required) -import { Configuration, DatabasesIPSecurityApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// IP Security Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpSecurity.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPSecurityApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPSecurityApi(config); -async function main() { - const result = await api.dbIpSecurity({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpSecurity({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpSecurity({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpSecurity.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -69,29 +89,48 @@ main().catch(console.error); ```go // Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPSecurityAPI.DbIpSecurity(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpSecurity.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpSecurity.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPSecurityAPI.DbIpSecurity(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpSecurity.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -102,14 +141,13 @@ func main() { ## IP Security Snapshot Status -`GET /v3.3/status/snapshot/ip/security` +`GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/security` IP Security Snapshot Status. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Response** (`SnapshotStatus`) @@ -127,19 +165,25 @@ IP Security Snapshot Status. Returns the file/snapshot described by this operati
Python ```python -"""Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_security_api import DatabasesIPSecurityApi +"""IP Security Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpSecurityStatus.py +""" +import json +import os -# Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPSecurityApi(ApiClient(config)) +import whoisfreaks -result = api.db_ip_security_status() -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPSecurityApi(client) + + # db_ip_security_status takes no parameters. + result = api.db_ip_security_status() + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -147,20 +191,29 @@ print(result)
TypeScript ```typescript -// Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) -// Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPSecurityApi } from "whoisfreaks"; +// IP Security Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpSecurityStatus.ts +import { Configuration, DatabasesIPSecurityApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPSecurityApi(config); -async function main() { - const result = await api.dbIpSecurityStatus({ }); - console.log(result); +// dbIpSecurityStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpSecurityStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -169,27 +222,34 @@ main().catch(console.error); ```go // Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPSecurityAPI.DbIpSecurityStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPSecurityAPI.DbIpSecurityStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/databases-ip-whois.md b/docs/endpoints/databases-ip-whois.md index efff3ad..747d89f 100644 --- a/docs/endpoints/databases-ip-whois.md +++ b/docs/endpoints/databases-ip-whois.md @@ -4,42 +4,48 @@ IP WHOIS database snapshots -2 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +2 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## IP WHOIS Snapshot -`GET /v3.3/download/snapshot/ip/whois` +`GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/whois` IP WHOIS Snapshot. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | yes | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | yes | string (date) | | | **Usage**
Python ```python -"""Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ipwhois_api import DatabasesIPWHOISApi - -# Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPWHOISApi(ApiClient(config)) - -data = api.db_ip_whois(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpWhois.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpWhois.gz") +"""IP WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/whois +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpWhois.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPWHOISApi(client) + + # db_ip_whois parameters: + # var_date (datetime.date, required) + data = api.db_ip_whois(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpWhois.json.gz" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -47,20 +53,34 @@ print(f"saved {len(data)} bytes to dbIpWhois.gz")
TypeScript ```typescript -// Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) -// Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): -// - date (string, required) -import { Configuration, DatabasesIPWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// IP WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpWhois.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPWHOISApi(config); -async function main() { - const result = await api.dbIpWhois({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpWhois({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpWhois({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpWhois.json.gz"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -69,29 +89,48 @@ main().catch(console.error); ```go // Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPWHOISAPI.DbIpWhois(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpWhois.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpWhois.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPWHOISAPI.DbIpWhois(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpWhois.json.gz") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -102,14 +141,13 @@ func main() { ## IP WHOIS Snapshot Status -`GET /v3.3/status/snapshot/ip/whois` +`GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/whois` IP WHOIS Snapshot Status. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Response** (`SnapshotStatus`) @@ -127,19 +165,25 @@ IP WHOIS Snapshot Status. Returns the file/snapshot described by this operation.
Python ```python -"""Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ipwhois_api import DatabasesIPWHOISApi +"""IP WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpWhoisStatus.py +""" +import json +import os -# Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPWHOISApi(ApiClient(config)) +import whoisfreaks -result = api.db_ip_whois_status() -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPWHOISApi(client) + + # db_ip_whois_status takes no parameters. + result = api.db_ip_whois_status() + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -147,20 +191,29 @@ print(result)
TypeScript ```typescript -// Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) -// Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPWHOISApi } from "whoisfreaks"; +// IP WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpWhoisStatus.ts +import { Configuration, DatabasesIPWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPWHOISApi(config); -async function main() { - const result = await api.dbIpWhoisStatus({ }); - console.log(result); +// dbIpWhoisStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -169,27 +222,34 @@ main().catch(console.error); ```go // Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPWHOISAPI.DbIpWhoisStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPWHOISAPI.DbIpWhoisStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/databases-newly-registered.md b/docs/endpoints/databases-newly-registered.md index d4d2106..83300c3 100644 --- a/docs/endpoints/databases-newly-registered.md +++ b/docs/endpoints/databases-newly-registered.md @@ -4,46 +4,52 @@ Newly registered domain downloads -7 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +7 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Newly Registered gTLD (CSV) -`GET /v3.1/download/domainer/gtld` +`GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld` Newly Registered gTLD (CSV). Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `whois` | query | yes | boolean | | -| `date` | query | no | string | yyyy-MM-dd; omit for latest | -| `tlds` | query | no | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `whois` | query | yes | boolean | | | +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | +| `tlds` | query | no | string | | | **Usage**
Python ```python -"""Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi - -# Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) - -data = api.db_newly_gtld(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyGtld.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyGtld.gz") - +"""Newly Registered gTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyGtld.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_gtld parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + data = api.db_newly_gtld(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyGtld.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -51,22 +57,36 @@ print(f"saved {len(data)} bytes to dbNewlyGtld.gz")
TypeScript ```typescript -// Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) -// Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered gTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyGtld.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyGtld({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyGtld({ whois, date?, tlds? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const blob = await api.dbNewlyGtld({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyGtld.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -75,31 +95,51 @@ main().catch(console.error); ```go // Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtld(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyGtld.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyGtld.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtld(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyGtld.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -110,42 +150,48 @@ func main() { ## Newly Registered ccTLD (CSV) -`GET /v3.1/download/domainer/cctld` +`GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld` Newly Registered ccTLD (CSV). Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `whois` | query | yes | boolean | | -| `date` | query | no | string | yyyy-MM-dd; omit for latest | -| `tlds` | query | no | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `whois` | query | yes | boolean | | | +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | +| `tlds` | query | no | string | | | **Usage**
Python ```python -"""Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi - -# Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) - -data = api.db_newly_cctld(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyCctld.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyCctld.gz") - +"""Newly Registered ccTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyCctld.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_cctld parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + data = api.db_newly_cctld(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyCctld.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -153,22 +199,36 @@ print(f"saved {len(data)} bytes to dbNewlyCctld.gz")
TypeScript ```typescript -// Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) -// Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered ccTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyCctld.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyCctld({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyCctld({ whois, date?, tlds? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const blob = await api.dbNewlyCctld({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyCctld.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -177,31 +237,51 @@ main().catch(console.error); ```go // Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctld(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyCctld.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyCctld.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctld(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyCctld.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -212,38 +292,44 @@ func main() { ## Newly Registered gTLD Cleaned WHOIS (CSV) -`GET /v3.1/download/domainer/gtld/cleaned` +`GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld/cleaned` Newly Registered gTLD Cleaned WHOIS (CSV). Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi - -# Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) - -data = api.db_newly_gtld_cleaned(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyGtldCleaned.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyGtldCleaned.gz") +"""Newly Registered gTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld/cleaned + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyGtldCleaned.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_gtld_cleaned parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_newly_gtld_cleaned(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyGtldCleaned.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -251,20 +337,34 @@ print(f"saved {len(data)} bytes to dbNewlyGtldCleaned.gz")
TypeScript ```typescript -// Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) -// Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered gTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyGtldCleaned.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyGtldCleaned({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbNewlyGtldCleaned({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbNewlyGtldCleaned({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyGtldCleaned.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -273,29 +373,49 @@ main().catch(console.error); ```go // Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldCleaned(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyGtldCleaned.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyGtldCleaned.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldCleaned(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyGtldCleaned.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -306,38 +426,44 @@ func main() { ## Newly Registered ccTLD Cleaned WHOIS (CSV) -`GET /v3.1/download/domainer/cctld/cleaned` +`GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld/cleaned` Newly Registered ccTLD Cleaned WHOIS (CSV). Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi - -# Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) - -data = api.db_newly_cctld_cleaned(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyCctldCleaned.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyCctldCleaned.gz") +"""Newly Registered ccTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld/cleaned + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyCctldCleaned.py +""" +import os +from datetime import date + +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_cctld_cleaned parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_newly_cctld_cleaned(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyCctldCleaned.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -345,20 +471,34 @@ print(f"saved {len(data)} bytes to dbNewlyCctldCleaned.gz")
TypeScript ```typescript -// Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) -// Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered ccTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyCctldCleaned.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyCctldCleaned({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbNewlyCctldCleaned({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbNewlyCctldCleaned({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyCctldCleaned.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -367,29 +507,49 @@ main().catch(console.error); ```go // Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldCleaned(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyCctldCleaned.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyCctldCleaned.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldCleaned(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyCctldCleaned.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -400,37 +560,44 @@ func main() { ## Newly Registered gTLD (JSON) -`GET /v3.1/domains/newly/gtld` +`GET https://files.whoisfreaks.com/v3.1/domains/newly/gtld` Newly Registered gTLD (JSON). Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | -| `tlds` | query | no | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | +| `tlds` | query | no | string | | | **Usage**
Python ```python -"""Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered gTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/gtld -# Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyGtldJson.py +""" +import os +from datetime import date -result = api.db_newly_gtld_json(var_date=str(date.today() - timedelta(days=1))) -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_gtld_json parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + domains = api.db_newly_gtld_json(var_date=date(2026, 10, 1)) + print(f"{len(domains)} domains") + print("\n".join(domains[:10])) ```
@@ -438,21 +605,32 @@ print(result)
TypeScript ```typescript -// Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) -// Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered gTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyGtldJson.ts +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyGtldJson({ date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyGtldJson({ date?, tlds? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const domains = await api.dbNewlyGtldJson({ date: new Date("2026-10-01") }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -461,29 +639,36 @@ main().catch(console.error); ```go // Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldJson(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldJson(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -494,37 +679,44 @@ func main() { ## Newly Registered ccTLD (JSON) -`GET /v3.1/domains/newly/cctld` +`GET https://files.whoisfreaks.com/v3.1/domains/newly/cctld` Newly Registered ccTLD (JSON). Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | -| `tlds` | query | no | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | +| `tlds` | query | no | string | | | **Usage**
Python ```python -"""Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered ccTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/cctld -# Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyCctldJson.py +""" +import os +from datetime import date -result = api.db_newly_cctld_json(var_date=str(date.today() - timedelta(days=1))) -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_cctld_json parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + domains = api.db_newly_cctld_json(var_date=date(2026, 10, 1)) + print(f"{len(domains)} domains") + print("\n".join(domains[:10])) ```
@@ -532,21 +724,32 @@ print(result)
TypeScript ```typescript -// Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) -// Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered ccTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyCctldJson.ts +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyCctldJson({ date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyCctldJson({ date?, tlds? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const domains = await api.dbNewlyCctldJson({ date: new Date("2026-10-01") }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -555,29 +758,36 @@ main().catch(console.error); ```go // Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldJson(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldJson(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -588,38 +798,44 @@ func main() { ## Newly Registered With DNS -`GET /v3.1/download/domainer/newly/dns` +`GET https://files.whoisfreaks.com/v3.1/download/domainer/newly/dns` Newly Registered With DNS. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi - -# Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) - -data = api.db_newly_dns(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyDns.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyDns.gz") +"""Newly Registered With DNS: GET https://files.whoisfreaks.com/v3.1/download/domainer/newly/dns + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyDns.py +""" +import os +from datetime import date + +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_dns parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_newly_dns(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyDns.json" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -627,20 +843,34 @@ print(f"saved {len(data)} bytes to dbNewlyDns.gz")
TypeScript ```typescript -// Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) -// Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered With DNS: GET https://files.whoisfreaks.com/v3.1/download/domainer/newly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyDns.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyDns({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbNewlyDns({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbNewlyDns({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyDns.json"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -649,29 +879,48 @@ main().catch(console.error); ```go // Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyDns(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyDns.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyDns.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyDns(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyDns.json") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` diff --git a/docs/endpoints/databases-subdomains.md b/docs/endpoints/databases-subdomains.md index ade76a3..9fb732d 100644 --- a/docs/endpoints/databases-subdomains.md +++ b/docs/endpoints/databases-subdomains.md @@ -4,42 +4,48 @@ Subdomain database snapshots -3 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +3 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Subdomains Daily -`GET /v3.2/download/dbupdate/daily/subdomains` +`GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/subdomains` Subdomains Daily. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_subdomains_api import DatabasesSubdomainsApi - -# Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesSubdomainsApi(ApiClient(config)) - -data = api.db_subdomains_daily(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbSubdomainsDaily.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbSubdomainsDaily.gz") +"""Subdomains Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/subdomains +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbSubdomainsDaily.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesSubdomainsApi(client) + + # db_subdomains_daily parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_subdomains_daily(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbSubdomainsDaily.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -47,20 +53,34 @@ print(f"saved {len(data)} bytes to dbSubdomainsDaily.gz")
TypeScript ```typescript -// Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) -// Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesSubdomainsApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Subdomains Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbSubdomainsDaily.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesSubdomainsApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesSubdomainsApi(config); -async function main() { - const result = await api.dbSubdomainsDaily({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbSubdomainsDaily({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbSubdomainsDaily({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbSubdomainsDaily.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -69,29 +89,49 @@ main().catch(console.error); ```go // Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsDaily(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbSubdomainsDaily.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbSubdomainsDaily.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsDaily(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbSubdomainsDaily.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -102,38 +142,44 @@ func main() { ## Subdomains Weekly -`GET /v3.2/download/dbupdate/weekly/subdomains` +`GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/subdomains` Subdomains Weekly. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_subdomains_api import DatabasesSubdomainsApi - -# Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesSubdomainsApi(ApiClient(config)) - -data = api.db_subdomains_weekly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbSubdomainsWeekly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbSubdomainsWeekly.gz") +"""Subdomains Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/subdomains + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbSubdomainsWeekly.py +""" +import os +from datetime import date + +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesSubdomainsApi(client) + + # db_subdomains_weekly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_subdomains_weekly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbSubdomainsWeekly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -141,20 +187,34 @@ print(f"saved {len(data)} bytes to dbSubdomainsWeekly.gz")
TypeScript ```typescript -// Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) -// Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesSubdomainsApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Subdomains Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbSubdomainsWeekly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesSubdomainsApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesSubdomainsApi(config); -async function main() { - const result = await api.dbSubdomainsWeekly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbSubdomainsWeekly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbSubdomainsWeekly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbSubdomainsWeekly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -163,29 +223,49 @@ main().catch(console.error); ```go // Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsWeekly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbSubdomainsWeekly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbSubdomainsWeekly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsWeekly(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbSubdomainsWeekly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -196,38 +276,44 @@ func main() { ## Subdomains Monthly -`GET /v3.2/download/dbupdate/monthly/subdomains` +`GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/subdomains` Subdomains Monthly. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_subdomains_api import DatabasesSubdomainsApi - -# Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesSubdomainsApi(ApiClient(config)) - -data = api.db_subdomains_monthly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbSubdomainsMonthly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbSubdomainsMonthly.gz") +"""Subdomains Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/subdomains + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbSubdomainsMonthly.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesSubdomainsApi(client) + + # db_subdomains_monthly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_subdomains_monthly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbSubdomainsMonthly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -235,20 +321,34 @@ print(f"saved {len(data)} bytes to dbSubdomainsMonthly.gz")
TypeScript ```typescript -// Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) -// Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesSubdomainsApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Subdomains Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbSubdomainsMonthly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesSubdomainsApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesSubdomainsApi(config); -async function main() { - const result = await api.dbSubdomainsMonthly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbSubdomainsMonthly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbSubdomainsMonthly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbSubdomainsMonthly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -257,29 +357,49 @@ main().catch(console.error); ```go // Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsMonthly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbSubdomainsMonthly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbSubdomainsMonthly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsMonthly(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbSubdomainsMonthly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` diff --git a/docs/endpoints/databases-threat-feed.md b/docs/endpoints/databases-threat-feed.md index c54129f..2a4ef8b 100644 --- a/docs/endpoints/databases-threat-feed.md +++ b/docs/endpoints/databases-threat-feed.md @@ -2,40 +2,47 @@ *Section: Databases* -6 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +Daily phishing, malware and spam threat feeds + +6 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Download the daily phishing threat feed (CSV) -`GET /v3.4/download/threat-feed/phishing` +`GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing` **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | Feed date (yyyy-MM-dd); defaults to latest available | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string | | Feed date (yyyy-MM-dd); omit for the full dump of the feed | **Usage**
Python ```python -"""Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_phishing(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("downloadThreatFeedPhishing.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedPhishing.gz") +"""Download the daily phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedPhishing.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_phishing parameters: + # var_date (str, optional, keyword): Feed date (yyyy-MM-dd); omit for the full dump of the feed + data = api.download_threat_feed_phishing(var_date="2026-10-01") # the file's raw bytes + path = "DownloadThreatFeedPhishing.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -43,20 +50,34 @@ print(f"saved {len(data)} bytes to downloadThreatFeedPhishing.gz")
TypeScript ```typescript -// Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) -// Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download the daily phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedPhishing.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedPhishing({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// downloadThreatFeedPhishing({ date? }) +// date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main(): Promise { + const blob = await api.downloadThreatFeedPhishing({ date: "2026-10-01" }); // a Blob with the file's bytes + const file = "DownloadThreatFeedPhishing.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -65,29 +86,49 @@ main().catch(console.error); ```go // Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishing(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedPhishing.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedPhishing.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishing(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedPhishing.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -98,34 +139,38 @@ func main() { ## Download a sample of the phishing threat feed (CSV) -`GET /v3.4/download/threat-feed/phishing/sample` +`GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing/sample` **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Usage**
Python ```python -"""Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_phishing_sample() # bytes -with open("downloadThreatFeedPhishingSample.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedPhishingSample.gz") +"""Download a sample of the phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing/sample + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedPhishingSample.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + # download_threat_feed_phishing_sample takes no parameters. + data = api.download_threat_feed_phishing_sample() # the file's raw bytes + path = "DownloadThreatFeedPhishingSample.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -133,20 +178,33 @@ print(f"saved {len(data)} bytes to downloadThreatFeedPhishingSample.gz")
TypeScript ```typescript -// Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) -// Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download a sample of the phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing/sample +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedPhishingSample.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedPhishingSample({ }); - console.log(result); +// downloadThreatFeedPhishingSample() takes no parameters. +async function main(): Promise { + const blob = await api.downloadThreatFeedPhishingSample(); // a Blob with the file's bytes + const file = "DownloadThreatFeedPhishingSample.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -155,28 +213,48 @@ main().catch(console.error); ```go // Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) + package main import ( - "context" - "fmt" - "os" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishingSample(ctx).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedPhishingSample.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedPhishingSample.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishingSample(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedPhishingSample.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -187,36 +265,41 @@ func main() { ## Download the daily malware threat feed (CSV) -`GET /v3.4/download/threat-feed/malware` +`GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware` **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | Feed date (yyyy-MM-dd); defaults to latest available | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string | | Feed date (yyyy-MM-dd); omit for the full dump of the feed | **Usage**
Python ```python -"""Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_malware(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("downloadThreatFeedMalware.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedMalware.gz") +"""Download the daily malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedMalware.py +""" +import os + +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_malware parameters: + # var_date (str, optional, keyword): Feed date (yyyy-MM-dd); omit for the full dump of the feed + data = api.download_threat_feed_malware(var_date="2026-10-01") # the file's raw bytes + path = "DownloadThreatFeedMalware.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -224,20 +307,34 @@ print(f"saved {len(data)} bytes to downloadThreatFeedMalware.gz")
TypeScript ```typescript -// Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) -// Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download the daily malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedMalware.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedMalware({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// downloadThreatFeedMalware({ date? }) +// date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main(): Promise { + const blob = await api.downloadThreatFeedMalware({ date: "2026-10-01" }); // a Blob with the file's bytes + const file = "DownloadThreatFeedMalware.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -246,29 +343,49 @@ main().catch(console.error); ```go // Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalware(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedMalware.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedMalware.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalware(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedMalware.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -279,34 +396,38 @@ func main() { ## Download a sample of the malware threat feed (CSV) -`GET /v3.4/download/threat-feed/malware/sample` +`GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware/sample` **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Usage**
Python ```python -"""Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_malware_sample() # bytes -with open("downloadThreatFeedMalwareSample.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedMalwareSample.gz") +"""Download a sample of the malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware/sample +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedMalwareSample.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_malware_sample takes no parameters. + data = api.download_threat_feed_malware_sample() # the file's raw bytes + path = "DownloadThreatFeedMalwareSample.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -314,20 +435,33 @@ print(f"saved {len(data)} bytes to downloadThreatFeedMalwareSample.gz")
TypeScript ```typescript -// Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) -// Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download a sample of the malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware/sample +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedMalwareSample.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedMalwareSample({ }); - console.log(result); +// downloadThreatFeedMalwareSample() takes no parameters. +async function main(): Promise { + const blob = await api.downloadThreatFeedMalwareSample(); // a Blob with the file's bytes + const file = "DownloadThreatFeedMalwareSample.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -336,28 +470,48 @@ main().catch(console.error); ```go // Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) + package main import ( - "context" - "fmt" - "os" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalwareSample(ctx).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedMalwareSample.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedMalwareSample.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalwareSample(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedMalwareSample.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -368,36 +522,41 @@ func main() { ## Download the daily spam threat feed (CSV) -`GET /v3.4/download/threat-feed/spam` +`GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam` **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | Feed date (yyyy-MM-dd); defaults to latest available | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string | | Feed date (yyyy-MM-dd); omit for the full dump of the feed | **Usage**
Python ```python -"""Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_spam(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("downloadThreatFeedSpam.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedSpam.gz") +"""Download the daily spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedSpam.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + # download_threat_feed_spam parameters: + # var_date (str, optional, keyword): Feed date (yyyy-MM-dd); omit for the full dump of the feed + data = api.download_threat_feed_spam(var_date="2026-10-01") # the file's raw bytes + path = "DownloadThreatFeedSpam.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -405,20 +564,34 @@ print(f"saved {len(data)} bytes to downloadThreatFeedSpam.gz")
TypeScript ```typescript -// Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) -// Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download the daily spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedSpam.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedSpam({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// downloadThreatFeedSpam({ date? }) +// date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main(): Promise { + const blob = await api.downloadThreatFeedSpam({ date: "2026-10-01" }); // a Blob with the file's bytes + const file = "DownloadThreatFeedSpam.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -427,29 +600,49 @@ main().catch(console.error); ```go // Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpam(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedSpam.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedSpam.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpam(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedSpam.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -460,34 +653,38 @@ func main() { ## Download a sample of the spam threat feed (CSV) -`GET /v3.4/download/threat-feed/spam/sample` +`GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam/sample` **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. **Usage**
Python ```python -"""Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_spam_sample() # bytes -with open("downloadThreatFeedSpamSample.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedSpamSample.gz") +"""Download a sample of the spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam/sample + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedSpamSample.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_spam_sample takes no parameters. + data = api.download_threat_feed_spam_sample() # the file's raw bytes + path = "DownloadThreatFeedSpamSample.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -495,20 +692,33 @@ print(f"saved {len(data)} bytes to downloadThreatFeedSpamSample.gz")
TypeScript ```typescript -// Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) -// Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download a sample of the spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam/sample +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedSpamSample.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedSpamSample({ }); - console.log(result); +// downloadThreatFeedSpamSample() takes no parameters. +async function main(): Promise { + const blob = await api.downloadThreatFeedSpamSample(); // a Blob with the file's bytes + const file = "DownloadThreatFeedSpamSample.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -517,28 +727,48 @@ main().catch(console.error); ```go // Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) + package main import ( - "context" - "fmt" - "os" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpamSample(ctx).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedSpamSample.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedSpamSample.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpamSample(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedSpamSample.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` diff --git a/docs/endpoints/databases-whois.md b/docs/endpoints/databases-whois.md index 39ce5bd..baa97ad 100644 --- a/docs/endpoints/databases-whois.md +++ b/docs/endpoints/databases-whois.md @@ -4,42 +4,48 @@ WHOIS database snapshots -3 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +3 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## WHOIS Database Daily -`GET /v3.3/download/dbupdate/daily/domains/whois` +`GET https://files.whoisfreaks.com/v3.3/download/dbupdate/daily/domains/whois` WHOIS Database Daily. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_whois_api import DatabasesWHOISApi - -# Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesWHOISApi(ApiClient(config)) - -data = api.db_whois_daily(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbWhoisDaily.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbWhoisDaily.gz") +"""WHOIS Database Daily: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/daily/domains/whois +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbWhoisDaily.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesWHOISApi(client) + + # db_whois_daily parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_whois_daily(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbWhoisDaily.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -47,20 +53,34 @@ print(f"saved {len(data)} bytes to dbWhoisDaily.gz")
TypeScript ```typescript -// Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) -// Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// WHOIS Database Daily: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/daily/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbWhoisDaily.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesWHOISApi(config); -async function main() { - const result = await api.dbWhoisDaily({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbWhoisDaily({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbWhoisDaily({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbWhoisDaily.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -69,29 +89,48 @@ main().catch(console.error); ```go // Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesWHOISAPI.DbWhoisDaily(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbWhoisDaily.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbWhoisDaily.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesWHOISAPI.DbWhoisDaily(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbWhoisDaily.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -102,38 +141,44 @@ func main() { ## WHOIS Database Weekly -`GET /v3.3/download/dbupdate/weekly/domains/whois` +`GET https://files.whoisfreaks.com/v3.3/download/dbupdate/weekly/domains/whois` WHOIS Database Weekly. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_whois_api import DatabasesWHOISApi - -# Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesWHOISApi(ApiClient(config)) - -data = api.db_whois_weekly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbWhoisWeekly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbWhoisWeekly.gz") +"""WHOIS Database Weekly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/weekly/domains/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbWhoisWeekly.py +""" +import os +from datetime import date + +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesWHOISApi(client) + + # db_whois_weekly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_whois_weekly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbWhoisWeekly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -141,20 +186,34 @@ print(f"saved {len(data)} bytes to dbWhoisWeekly.gz")
TypeScript ```typescript -// Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) -// Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// WHOIS Database Weekly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/weekly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbWhoisWeekly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesWHOISApi(config); -async function main() { - const result = await api.dbWhoisWeekly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbWhoisWeekly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbWhoisWeekly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbWhoisWeekly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -163,29 +222,48 @@ main().catch(console.error); ```go // Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesWHOISAPI.DbWhoisWeekly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbWhoisWeekly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbWhoisWeekly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesWHOISAPI.DbWhoisWeekly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbWhoisWeekly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -196,38 +274,44 @@ func main() { ## WHOIS Database Monthly -`GET /v3.3/download/dbupdate/monthly/domains/whois` +`GET https://files.whoisfreaks.com/v3.3/download/dbupdate/monthly/domains/whois` WHOIS Database Monthly. Returns the file/snapshot described by this operation. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `date` | query | no | string | yyyy-MM-dd; omit for latest | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `date` | query | no | string (date) | | yyyy-MM-dd; omit for latest | **Usage**
Python ```python -"""Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_whois_api import DatabasesWHOISApi - -# Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesWHOISApi(ApiClient(config)) - -data = api.db_whois_monthly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbWhoisMonthly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbWhoisMonthly.gz") +"""WHOIS Database Monthly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/monthly/domains/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbWhoisMonthly.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesWHOISApi(client) + + # db_whois_monthly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_whois_monthly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbWhoisMonthly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ```
@@ -235,20 +319,34 @@ print(f"saved {len(data)} bytes to dbWhoisMonthly.gz")
TypeScript ```typescript -// Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) -// Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// WHOIS Database Monthly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/monthly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbWhoisMonthly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesWHOISApi(config); -async function main() { - const result = await api.dbWhoisMonthly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbWhoisMonthly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbWhoisMonthly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbWhoisMonthly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -257,29 +355,48 @@ main().catch(console.error); ```go // Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesWHOISAPI.DbWhoisMonthly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbWhoisMonthly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbWhoisMonthly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesWHOISAPI.DbWhoisMonthly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbWhoisMonthly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` diff --git a/docs/endpoints/databases.md b/docs/endpoints/databases.md index 81137a5..7cdfafe 100644 --- a/docs/endpoints/databases.md +++ b/docs/endpoints/databases.md @@ -1,8 +1,8 @@ # Databases -Bulk data feeds and downloadable database snapshots for large-scale processing — newly registered, expiring/dropped, and full WHOIS/DNS/IP datasets. +Bulk data feeds and downloadable database snapshots for large-scale processing: newly registered, expiring/dropped, and full WHOIS/DNS/IP datasets. -**37 endpoints** across **10 categories**. All requests require your API key — see [Authentication](../authentication.md). +**37 endpoints** across **10 categories**. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Categories @@ -10,103 +10,105 @@ Bulk data feeds and downloadable database snapshots for large-scale processing Newly registered domain downloads -7 endpoint(s): +7 endpoints: -- **Newly Registered gTLD (CSV)** — `GET /v3.1/download/domainer/gtld` -- **Newly Registered ccTLD (CSV)** — `GET /v3.1/download/domainer/cctld` -- **Newly Registered gTLD Cleaned WHOIS (CSV)** — `GET /v3.1/download/domainer/gtld/cleaned` -- **Newly Registered ccTLD Cleaned WHOIS (CSV)** — `GET /v3.1/download/domainer/cctld/cleaned` -- **Newly Registered gTLD (JSON)** — `GET /v3.1/domains/newly/gtld` -- **Newly Registered ccTLD (JSON)** — `GET /v3.1/domains/newly/cctld` -- **Newly Registered With DNS** — `GET /v3.1/download/domainer/newly/dns` +- **Newly Registered gTLD (CSV)**: `GET /v3.1/download/domainer/gtld` +- **Newly Registered ccTLD (CSV)**: `GET /v3.1/download/domainer/cctld` +- **Newly Registered gTLD Cleaned WHOIS (CSV)**: `GET /v3.1/download/domainer/gtld/cleaned` +- **Newly Registered ccTLD Cleaned WHOIS (CSV)**: `GET /v3.1/download/domainer/cctld/cleaned` +- **Newly Registered gTLD (JSON)**: `GET /v3.1/domains/newly/gtld` +- **Newly Registered ccTLD (JSON)**: `GET /v3.1/domains/newly/cctld` +- **Newly Registered With DNS**: `GET /v3.1/download/domainer/newly/dns` ### [Databases - Expiring & Dropped](databases-expiring-dropped.md) Expiring and dropped domain downloads -5 endpoint(s): +5 endpoints: -- **Expiring Domains** — `GET /v3.1/download/domainer/expired` -- **Expiring Cleaned WHOIS** — `GET /v3.1/download/domainer/expired/cleaned` -- **Dropped Domains** — `GET /v3.1/download/domainer/dropped` -- **Dropped Domains (JSON)** — `GET /v3.1/domains/dropped` -- **Dropped With Backlinks** — `GET /v3.3/download/domainer/dropped/backlinks` +- **Expiring Domains**: `GET /v3.1/download/domainer/expired` +- **Expiring Cleaned WHOIS**: `GET /v3.1/download/domainer/expired/cleaned` +- **Dropped Domains**: `GET /v3.1/download/domainer/dropped` +- **Dropped Domains (JSON)**: `GET /v3.1/domains/dropped` +- **Dropped With Backlinks**: `GET /v3.3/download/domainer/dropped/backlinks` ### [Databases - WHOIS](databases-whois.md) WHOIS database snapshots -3 endpoint(s): +3 endpoints: -- **WHOIS Database Daily** — `GET /v3.3/download/dbupdate/daily/domains/whois` -- **WHOIS Database Weekly** — `GET /v3.3/download/dbupdate/weekly/domains/whois` -- **WHOIS Database Monthly** — `GET /v3.3/download/dbupdate/monthly/domains/whois` +- **WHOIS Database Daily**: `GET /v3.3/download/dbupdate/daily/domains/whois` +- **WHOIS Database Weekly**: `GET /v3.3/download/dbupdate/weekly/domains/whois` +- **WHOIS Database Monthly**: `GET /v3.3/download/dbupdate/monthly/domains/whois` ### [Databases - DNS](databases-dns.md) DNS database snapshots -3 endpoint(s): +3 endpoints: -- **DNS Database Daily** — `GET /v3.2/download/dbupdate/daily/dns` -- **DNS Database Weekly** — `GET /v3.2/download/dbupdate/weekly/dns` -- **DNS Database Monthly** — `GET /v3.2/download/dbupdate/monthly/dns` +- **DNS Database Daily**: `GET /v3.2/download/dbupdate/daily/dns` +- **DNS Database Weekly**: `GET /v3.2/download/dbupdate/weekly/dns` +- **DNS Database Monthly**: `GET /v3.2/download/dbupdate/monthly/dns` ### [Databases - Subdomains](databases-subdomains.md) Subdomain database snapshots -3 endpoint(s): +3 endpoints: -- **Subdomains Daily** — `GET /v3.2/download/dbupdate/daily/subdomains` -- **Subdomains Weekly** — `GET /v3.2/download/dbupdate/weekly/subdomains` -- **Subdomains Monthly** — `GET /v3.2/download/dbupdate/monthly/subdomains` +- **Subdomains Daily**: `GET /v3.2/download/dbupdate/daily/subdomains` +- **Subdomains Weekly**: `GET /v3.2/download/dbupdate/weekly/subdomains` +- **Subdomains Monthly**: `GET /v3.2/download/dbupdate/monthly/subdomains` ### [Databases - IP Geolocation](databases-ip-geolocation.md) IP geolocation database snapshots -4 endpoint(s): +4 endpoints: -- **IP to Country Snapshot Status** — `GET /v3.3/status/snapshot/ip/country` -- **IP to Country Snapshot** — `GET /v3.3/download/snapshot/ip/country` -- **IP to City Snapshot Status** — `GET /v3.3/status/snapshot/ip/city` -- **IP to City Snapshot** — `GET /v3.3/download/snapshot/ip/city` +- **IP to Country Snapshot Status**: `GET /v3.3/status/snapshot/ip/country` +- **IP to Country Snapshot**: `GET /v3.3/download/snapshot/ip/country` +- **IP to City Snapshot Status**: `GET /v3.3/status/snapshot/ip/city` +- **IP to City Snapshot**: `GET /v3.3/download/snapshot/ip/city` ### [Databases - ASN WHOIS](databases-asn-whois.md) ASN WHOIS database snapshots -2 endpoint(s): +2 endpoints: -- **ASN WHOIS Snapshot** — `GET /v3.3/download/snapshot/asn/whois` -- **ASN WHOIS Snapshot Status** — `GET /v3.3/status/snapshot/asn/whois` +- **ASN WHOIS Snapshot**: `GET /v3.3/download/snapshot/asn/whois` +- **ASN WHOIS Snapshot Status**: `GET /v3.3/status/snapshot/asn/whois` ### [Databases - IP WHOIS](databases-ip-whois.md) IP WHOIS database snapshots -2 endpoint(s): +2 endpoints: -- **IP WHOIS Snapshot** — `GET /v3.3/download/snapshot/ip/whois` -- **IP WHOIS Snapshot Status** — `GET /v3.3/status/snapshot/ip/whois` +- **IP WHOIS Snapshot**: `GET /v3.3/download/snapshot/ip/whois` +- **IP WHOIS Snapshot Status**: `GET /v3.3/status/snapshot/ip/whois` ### [Databases - IP Security](databases-ip-security.md) IP security database snapshots -2 endpoint(s): +2 endpoints: -- **IP Security Snapshot** — `GET /v3.3/download/snapshot/ip/security` -- **IP Security Snapshot Status** — `GET /v3.3/status/snapshot/ip/security` +- **IP Security Snapshot**: `GET /v3.3/download/snapshot/ip/security` +- **IP Security Snapshot Status**: `GET /v3.3/status/snapshot/ip/security` ### [Databases - Threat Feed](databases-threat-feed.md) -6 endpoint(s): +Daily phishing, malware and spam threat feeds -- **Download the daily phishing threat feed (CSV)** — `GET /v3.4/download/threat-feed/phishing` -- **Download a sample of the phishing threat feed (CSV)** — `GET /v3.4/download/threat-feed/phishing/sample` -- **Download the daily malware threat feed (CSV)** — `GET /v3.4/download/threat-feed/malware` -- **Download a sample of the malware threat feed (CSV)** — `GET /v3.4/download/threat-feed/malware/sample` -- **Download the daily spam threat feed (CSV)** — `GET /v3.4/download/threat-feed/spam` -- **Download a sample of the spam threat feed (CSV)** — `GET /v3.4/download/threat-feed/spam/sample` +6 endpoints: + +- **Download the daily phishing threat feed (CSV)**: `GET /v3.4/download/threat-feed/phishing` +- **Download a sample of the phishing threat feed (CSV)**: `GET /v3.4/download/threat-feed/phishing/sample` +- **Download the daily malware threat feed (CSV)**: `GET /v3.4/download/threat-feed/malware` +- **Download a sample of the malware threat feed (CSV)**: `GET /v3.4/download/threat-feed/malware/sample` +- **Download the daily spam threat feed (CSV)**: `GET /v3.4/download/threat-feed/spam` +- **Download a sample of the spam threat feed (CSV)**: `GET /v3.4/download/threat-feed/spam/sample` diff --git a/docs/endpoints/dns.md b/docs/endpoints/dns.md index ab74524..3dc912a 100644 --- a/docs/endpoints/dns.md +++ b/docs/endpoints/dns.md @@ -4,22 +4,22 @@ DNS lookup APIs (live, historical, reverse, bulk) -4 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +4 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Live DNS Lookup -`GET /v2.0/dns/live` +`GET https://api.whoisfreaks.com/v2.0/dns/live` Real-time DNS record lookup. 1 credit per query. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `domainName` | query | no | string | | -| `ipAddress` | query | no | string | Use for PTR lookups | -| `type` | query | yes | string | all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `domainName` | query | no | string | | | +| `ipAddress` | query | no | string | | Use for PTR lookups | +| `type` | query | yes | string | `all` | all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`DnsResponse`) @@ -37,9 +37,13 @@ Real-time DNS record lookup. 1 credit per query. | Field | Type | Description | |-------|------|-------------| -| `type` | string | | +| `type` | integer | Numeric DNS record type: 1 A, 2 NS, 5 CNAME, 6 SOA, 12 PTR, 15 MX, 16 TXT, 28 AAAA, 99 SPF. | +| `dnsType` | string | Record type name, e.g. A, MX, TXT | | `name` | string | | | `ttl` | integer | | +| `rawText` | string | The record in zone-file format | +| `rRsetType` | integer | | +| `singleName` | string | Target host for NS, CNAME and PTR records | | `address` | string | | | `priority` | integer | | | `exchange` | string | | @@ -47,7 +51,7 @@ Real-time DNS record lookup. 1 credit per query. | `strings` | array | | | `host` | string | | | `admin` | string | | -| `serial` | integer | | +| `serial` | integer | SOA serial; values above 2^31 are common, so it is 64-bit | | `refresh` | integer | | | `retry` | integer | | | `expire` | integer | | @@ -61,22 +65,29 @@ Real-time DNS record lookup. 1 credit per query.
Python ```python -"""Runnable example: Live DNS Lookup (GET /v2.0/dns/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi - -# Parameters for dnsLive (GET /v2.0/dns/live): -# - domainName (string, required) -# - ipAddress (string, required): Use for PTR lookups -# - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) - -result = api.dns_live(domain_name="example.com", ip_address="8.8.8.8", var_type="value") -print(result) +"""Live DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/live +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsLive.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + + # dns_live parameters: + # type (str, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME; default "all" + # domain_name (str, optional, keyword) + # ip_address (str, optional, keyword): Use for PTR lookups + # format (str, optional, keyword): one of json, xml; default "json" + result = api.dns_live("A,MX,TXT", domain_name="whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -84,23 +95,33 @@ print(result)
TypeScript ```typescript -// Runnable example: Live DNS Lookup (GET /v2.0/dns/live) -// Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups -// - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME -// - format (string (one of: json, xml), optional) -import { Configuration, DNSApi } from "whoisfreaks"; +// Live DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsLive.ts +import { Configuration, DNSApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsLive({ domainName: "example.com", ipAddress: "8.8.8.8", type: "value", format: undefined }); - console.log(result); +// dnsLive({ type, domainName?, ipAddress?, format? }) +// type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME; default "all" +// domainName (string, optional) +// ipAddress (string, optional): Use for PTR lookups +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.dnsLive({ type: "A,MX,TXT", domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -109,30 +130,38 @@ main().catch(console.error); ```go // Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsLive(ctx).DomainName("example.com").IpAddress("8.8.8.8").Type("value").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DNSAPI.DnsLive(ctx). + DomainName("whoisfreaks.com").Type_("A,MX,TXT").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -143,27 +172,27 @@ func main() { ## Historical DNS Lookup -`GET /v2.0/dns/historical` +`GET https://api.whoisfreaks.com/v2.0/dns/historical` All historical DNS records. 2 credits per page (100 records/page). **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `domainName` | query | yes | string | | -| `type` | query | yes | string | | -| `page` | query | no | integer | | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `domainName` | query | yes | string | | | +| `type` | query | yes | string | `all` | | +| `page` | query | no | integer | `1` | | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`HistoricalDnsResponse`) | Field | Type | Description | |-------|------|-------------| | `totalPages` | integer | | -| `currenPage` | integer | | +| `currentPage` | integer | | | `totalRecords` | integer | | -| `historicalDns` | array | | +| `historicalDnsRecords` | array | |
DnsResponse object @@ -185,22 +214,29 @@ All historical DNS records. 2 credits per page (100 records/page).
Python ```python -"""Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi - -# Parameters for dnsHistorical (GET /v2.0/dns/historical): -# - domainName (string, required) -# - type (string, required) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) - -result = api.dns_historical(domain_name="example.com", var_type="value") -print(result) +"""Historical DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/historical + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsHistorical.py +""" +import json +import os + +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + + # dns_historical parameters: + # domain_name (str, required) + # type (str, required): default "all" + # page (int, optional, keyword): default 1 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.dns_historical("whoisfreaks.com", "A,MX,TXT", page=1) + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -208,23 +244,33 @@ print(result)
TypeScript ```typescript -// Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) -// Parameters for dnsHistorical (GET /v2.0/dns/historical): -// - domainName (string, required) -// - type (string, required) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, DNSApi } from "whoisfreaks"; +// Historical DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/historical +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsHistorical.ts +import { Configuration, DNSApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsHistorical({ domainName: "example.com", type: "value", page: undefined, format: undefined }); - console.log(result); +// dnsHistorical({ domainName, type, page?, format? }) +// domainName (string, required) +// type (string, required): default "all" +// page (number, optional): default 1 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.dnsHistorical({ domainName: "whoisfreaks.com", type: "A,MX,TXT", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -233,30 +279,38 @@ main().catch(console.error); ```go // Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) // - page (integer, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsHistorical(ctx).DomainName("example.com").Type("value").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DNSAPI.DnsHistorical(ctx). + DomainName("whoisfreaks.com").Type_("A,MX,TXT").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -267,19 +321,19 @@ func main() { ## Reverse DNS Lookup -`GET /v2.1/dns/reverse` +`GET https://api.whoisfreaks.com/v2.1/dns/reverse` Search domains by IP or DNS value. 5 credits per page. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `value` | query | yes | string | IP, CIDR, or record value | -| `type` | query | yes | string | (one of: a, mx, cname, ns, aaaa, txt, soa) | -| `exact` | query | no | boolean | | -| `page` | query | no | integer | | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `value` | query | yes | string | | IP, CIDR, or record value | +| `type` | query | yes | string | | (one of: a, mx, cname, ns, aaaa, txt, soa) | +| `exact` | query | no | boolean | `true` | | +| `page` | query | no | integer | `1` | | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`ReverseDnsResponse`) @@ -310,23 +364,30 @@ Search domains by IP or DNS value. 5 credits per page.
Python ```python -"""Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi - -# Parameters for dnsReverse (GET /v2.1/dns/reverse): -# - value (string, required): IP, CIDR, or record value -# - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) -# - exact (boolean, optional) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) - -result = api.dns_reverse(value="value", var_type="a", exact=True) -print(result) - +"""Reverse DNS Lookup: GET https://api.whoisfreaks.com/v2.1/dns/reverse + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsReverse.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + + # dns_reverse parameters: + # value (str, required): IP, CIDR, or record value + # type (str, required): one of a, mx, cname, ns, aaaa, txt, soa + # exact (bool, optional, keyword): default True + # page (int, optional, keyword): default 1 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.dns_reverse("8.8.8.8", "a", page=1) + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -334,24 +395,34 @@ print(result)
TypeScript ```typescript -// Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) -// Parameters for dnsReverse (GET /v2.1/dns/reverse): -// - value (string, required): IP, CIDR, or record value -// - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, DNSApi } from "whoisfreaks"; +// Reverse DNS Lookup: GET https://api.whoisfreaks.com/v2.1/dns/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsReverse.ts +import { Configuration, DNSApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsReverse({ value: "value", type: "a", exact: true, page: undefined, format: undefined }); - console.log(result); +// dnsReverse({ value, type, exact?, page?, format? }) +// value (string, required): IP, CIDR, or record value +// type ("a" | "mx" | "cname" | "ns" | "aaaa" | "txt" | "soa", required) +// exact (boolean, optional): default true +// page (number, optional): default 1 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.dnsReverse({ value: "8.8.8.8", type: "a", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -360,31 +431,38 @@ main().catch(console.error); ```go // Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) // - exact (boolean, optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsReverse(ctx).Value("value").Type("a").Exact(true).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DNSAPI.DnsReverse(ctx).Value("8.8.8.8").Type_("a").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -395,16 +473,25 @@ func main() { ## Bulk DNS Lookup -`POST /v2.0/dns/bulk/live` +`POST https://api.whoisfreaks.com/v2.0/dns/bulk/live` Up to 100 domains + 100 IPs in one request. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `type` | query | yes | string | | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `type` | query | yes | string | `all` | | +| `format` | query | no | string | `json` | (one of: json, xml) | + +**Request body** (`application/json`, model `DnsBulkRequest`) + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `domainNames` | array | no | | +| `ipAddresses` | array | no | | + +Example: `{"domainNames": ["whoisfreaks.com", "example.com"]}` **Response** (`BulkDnsResponse`) @@ -432,23 +519,29 @@ Up to 100 domains + 100 IPs in one request.
Python ```python -"""Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi -from whoisfreaks.models.dns_bulk_request import DnsBulkRequest - -# Parameters for dnsBulk (POST /v2.0/dns/bulk/live): -# - type (string, required) -# - format (string (one of: json, xml), optional) -# - body: DnsBulkRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) - -dns_bulk_request = DnsBulkRequest() # populate fields as needed -result = api.dns_bulk(var_type="value", dns_bulk_request=dns_bulk_request) -print(result) +"""Bulk DNS Lookup: POST https://api.whoisfreaks.com/v2.0/dns/bulk/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsBulk.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + # dns_bulk parameters: + # type (str, required): default "all" + # dns_bulk_request (DnsBulkRequest, required): request body + # format (str, optional, keyword): one of json, xml; default "json" + body = whoisfreaks.DnsBulkRequest(domain_names=["whoisfreaks.com", "example.com"]) + result = api.dns_bulk("A,MX,TXT", body) + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -456,22 +549,33 @@ print(result)
TypeScript ```typescript -// Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) -// Parameters for dnsBulk (POST /v2.0/dns/bulk/live): -// - type (string, required) -// - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object -import { Configuration, DNSApi } from "whoisfreaks"; +// Bulk DNS Lookup: POST https://api.whoisfreaks.com/v2.0/dns/bulk/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsBulk.ts +import { Configuration, DNSApi, ResponseError, type DnsBulkRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsBulk({ type: "value", dnsBulkRequest: {}, format: undefined }); - console.log(result); +// dnsBulk({ type, dnsBulkRequest, format? }) +// type (string, required): default "all" +// dnsBulkRequest (DnsBulkRequest, required): request body +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const body: DnsBulkRequest = { domainNames: ["whoisfreaks.com", "example.com"] }; + const result = await api.dnsBulk({ type: "A,MX,TXT", dnsBulkRequest: body }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -480,29 +584,38 @@ main().catch(console.error); ```go // Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsBulk(ctx).Type("value").DnsBulkRequest(*wf.NewDnsBulkRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewDnsBulkRequest() + body.SetDomainNames([]string{"whoisfreaks.com", "example.com"}) + result, _, err := client.DNSAPI.DnsBulk(ctx).Type_("A,MX,TXT").DnsBulkRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/domain-availability.md b/docs/endpoints/domain-availability.md index 26c3103..c423ba3 100644 --- a/docs/endpoints/domain-availability.md +++ b/docs/endpoints/domain-availability.md @@ -4,22 +4,22 @@ Check domain availability -2 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +2 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Domain Availability Check with Suggestions -`GET /v2.0/domain/availability` +`GET https://api.whoisfreaks.com/v2.0/domain/availability` Check availability of a single domain and optionally get suggestions across multiple TLDs. 1 credit per domain checked. sug=false checks only the queried domain; sug=true returns up to `count` (max 100) TLD suggestions. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `domain` | query | yes | string | The domain name to check | -| `sug` | query | no | boolean | Whether to return TLD suggestions alongside the queried domain. | -| `count` | query | no | integer | Number of TLD suggestions to return when sug=true. Maximum is 100. | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `domain` | query | yes | string | | The domain name to check | +| `sug` | query | no | boolean | `false` | Whether to return TLD suggestions alongside the queried domain. | +| `count` | query | no | integer | `5` | Number of TLD suggestions to return when sug=true. Maximum is 100. | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`DomainAvailabilityResponse`) @@ -46,22 +46,29 @@ Check availability of a single domain and optionally get suggestions across mult
Python ```python -"""Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.domain_availability_api import DomainAvailabilityApi - -# Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): -# - domain (string, required): The domain name to check -# - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. -# - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DomainAvailabilityApi(ApiClient(config)) - -result = api.domain_availability_v2(domain="example.com") -print(result) +"""Domain Availability Check with Suggestions: GET https://api.whoisfreaks.com/v2.0/domain/availability +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DomainAvailabilityV2.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DomainAvailabilityApi(client) + + # domain_availability_v2 parameters: + # domain (str, required): The domain name to check + # sug (bool, optional, keyword): Whether to return TLD suggestions alongside the queried domain; default False + # count (int, optional, keyword): Number of TLD suggestions to return when sug=true. Maximum is 100; default 5 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.domain_availability_v2("google.com", sug=True, count=5) + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -69,23 +76,33 @@ print(result)
TypeScript ```typescript -// Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) -// Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): -// - domain (string, required): The domain name to check -// - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. -// - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. -// - format (string (one of: json, xml), optional) -import { Configuration, DomainAvailabilityApi } from "whoisfreaks"; +// Domain Availability Check with Suggestions: GET https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DomainAvailabilityV2.ts +import { Configuration, DomainAvailabilityApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DomainAvailabilityApi(config); -async function main() { - const result = await api.domainAvailabilityV2({ domain: "example.com", sug: undefined, count: undefined, format: undefined }); - console.log(result); +// domainAvailabilityV2({ domain, sug?, count?, format? }) +// domain (string, required): The domain name to check +// sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain; default false +// count (number, optional): Number of TLD suggestions to return when sug=true. Maximum is 100; default 5 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.domainAvailabilityV2({ domain: "google.com", sug: true, count: 5 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -94,30 +111,38 @@ main().catch(console.error); ```go // Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. // - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DomainAvailabilityAPI.DomainAvailabilityV2(ctx).Domain("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DomainAvailabilityAPI.DomainAvailabilityV2(ctx). + Domain("google.com").Sug(true).Count(5).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -128,16 +153,25 @@ func main() { ## Bulk Domain Availability Check -`POST /v2.0/domain/availability` +`POST https://api.whoisfreaks.com/v2.0/domain/availability` Two bulk modes. Mode 1: POST domainNames array. Mode 2: POST tld array plus domain query param. Max 100 domains per request. 1 credit per domain checked. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `domain` | query | no | string | Required for TLD-mode bulk check (base domain). | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `domain` | query | no | string | | Required for TLD-mode bulk check (base domain). | +| `format` | query | no | string | `json` | (one of: json, xml) | + +**Request body** (`application/json`, model `BulkDomainAvailabilityRequest`) + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `domainNames` | array | no | Mode 1: list of full domain names. Cannot be used with tld. | +| `tld` | array | no | Mode 2: TLDs to check against the domain query param. Cannot be used with domainNames. | + +Example: `{"domainNames": ["whoisfreaks.com", "example.com"]}` **Response** (`BulkDomainAvailabilityResponse`) @@ -161,23 +195,29 @@ Two bulk modes. Mode 1: POST domainNames array. Mode 2: POST tld array plus doma
Python ```python -"""Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.domain_availability_api import DomainAvailabilityApi -from whoisfreaks.models.bulk_domain_availability_request import BulkDomainAvailabilityRequest - -# Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): -# - domain (string, optional): Required for TLD-mode bulk check (base domain). -# - format (string (one of: json, xml), optional) -# - body: BulkDomainAvailabilityRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DomainAvailabilityApi(ApiClient(config)) - -bulk_domain_availability_request = BulkDomainAvailabilityRequest() # populate fields as needed -result = api.bulk_domain_availability_v2(bulk_domain_availability_request=bulk_domain_availability_request) -print(result) +"""Bulk Domain Availability Check: POST https://api.whoisfreaks.com/v2.0/domain/availability + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkDomainAvailabilityV2.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DomainAvailabilityApi(client) + # bulk_domain_availability_v2 parameters: + # bulk_domain_availability_request (BulkDomainAvailabilityRequest, required): request body + # domain (str, optional, keyword): Required for TLD-mode bulk check (base domain) + # format (str, optional, keyword): one of json, xml; default "json" + body = whoisfreaks.BulkDomainAvailabilityRequest(domain_names=["whoisfreaks.com", "example.com"]) + result = api.bulk_domain_availability_v2(body) + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -185,22 +225,33 @@ print(result)
TypeScript ```typescript -// Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) -// Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): -// - domain (string, optional): Required for TLD-mode bulk check (base domain). -// - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object -import { Configuration, DomainAvailabilityApi } from "whoisfreaks"; +// Bulk Domain Availability Check: POST https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkDomainAvailabilityV2.ts +import { Configuration, DomainAvailabilityApi, ResponseError, type BulkDomainAvailabilityRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DomainAvailabilityApi(config); -async function main() { - const result = await api.bulkDomainAvailabilityV2({ bulkDomainAvailabilityRequest: {}, domain: undefined, format: undefined }); - console.log(result); +// bulkDomainAvailabilityV2({ bulkDomainAvailabilityRequest, domain?, format? }) +// bulkDomainAvailabilityRequest (BulkDomainAvailabilityRequest, required): request body +// domain (string, optional): Required for TLD-mode bulk check (base domain) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const body: BulkDomainAvailabilityRequest = { domainNames: ["whoisfreaks.com", "example.com"] }; + const result = await api.bulkDomainAvailabilityV2({ bulkDomainAvailabilityRequest: body }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -209,29 +260,39 @@ main().catch(console.error); ```go // Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DomainAvailabilityAPI.BulkDomainAvailabilityV2(ctx).BulkDomainAvailabilityRequest(*wf.NewBulkDomainAvailabilityRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkDomainAvailabilityRequest() + body.SetDomainNames([]string{"whoisfreaks.com", "example.com"}) + result, _, err := client.DomainAvailabilityAPI.BulkDomainAvailabilityV2(ctx). + BulkDomainAvailabilityRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/domain-reputation.md b/docs/endpoints/domain-reputation.md index 6c44373..83fa932 100644 --- a/docs/endpoints/domain-reputation.md +++ b/docs/endpoints/domain-reputation.md @@ -4,20 +4,20 @@ Real-time domain threat assessment and trust scoring -1 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +1 endpoint. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Domain Reputation Lookup -`GET /v1/domain/security` +`GET https://api.whoisfreaks.com/v1/domain/security` Real-time domain threat assessment. Returns risk verdict, trust score, DGA analysis, threat intelligence matches, and security signals. 1 credit. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `domainName` | query | yes | string | The domain name to assess | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `domainName` | query | yes | string | | The domain name to assess | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`DomainReputationResponse`) @@ -108,20 +108,27 @@ Real-time domain threat assessment. Returns risk verdict, trust score, DGA analy
Python ```python -"""Runnable example: Domain Reputation Lookup (GET /v1/domain/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.domain_reputation_api import DomainReputationApi +"""Domain Reputation Lookup: GET https://api.whoisfreaks.com/v1/domain/security -# Parameters for domainReputation (GET /v1/domain/security): -# - domainName (string, required): The domain name to assess -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DomainReputationApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DomainReputation.py +""" +import json +import os -result = api.domain_reputation(domain_name="example.com") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DomainReputationApi(client) + + # domain_reputation parameters: + # domain_name (str, required): The domain name to assess + # format (str, optional, keyword): one of json, xml; default "json" + result = api.domain_reputation("amazon.com") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -129,21 +136,31 @@ print(result)
TypeScript ```typescript -// Runnable example: Domain Reputation Lookup (GET /v1/domain/security) -// Parameters for domainReputation (GET /v1/domain/security): -// - domainName (string, required): The domain name to assess -// - format (string (one of: json, xml), optional) -import { Configuration, DomainReputationApi } from "whoisfreaks"; +// Domain Reputation Lookup: GET https://api.whoisfreaks.com/v1/domain/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DomainReputation.ts +import { Configuration, DomainReputationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DomainReputationApi(config); -async function main() { - const result = await api.domainReputation({ domainName: "example.com", format: undefined }); - console.log(result); +// domainReputation({ domainName, format? }) +// domainName (string, required): The domain name to assess +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.domainReputation({ domainName: "amazon.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -152,28 +169,36 @@ main().catch(console.error); ```go // Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DomainReputationAPI.DomainReputation(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DomainReputationAPI.DomainReputation(ctx). + DomainName("amazon.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/geolocation.md b/docs/endpoints/geolocation.md index a539266..ce33450 100644 --- a/docs/endpoints/geolocation.md +++ b/docs/endpoints/geolocation.md @@ -4,19 +4,19 @@ IP geolocation lookup -2 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +2 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## IP Geolocation Lookup -`GET /v1.0/geolocation` +`GET https://api.whoisfreaks.com/v1.0/geolocation` Get location, ASN, currency for an IP. 1 credit. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `ip` | query | yes | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `ip` | query | yes | string | | | **Response** (`GeolocationResponse`) @@ -91,19 +91,26 @@ Get location, ASN, currency for an IP. 1 credit.
Python ```python -"""Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.geolocation_api import GeolocationApi +"""IP Geolocation Lookup: GET https://api.whoisfreaks.com/v1.0/geolocation -# Parameters for geolocation (GET /v1.0/geolocation): -# - ip (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = GeolocationApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python Geolocation.py +""" +import json +import os -result = api.geolocation(ip="8.8.8.8") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.GeolocationApi(client) + + # geolocation parameters: + # ip (str, required) + result = api.geolocation("8.8.8.8") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -111,20 +118,30 @@ print(result)
TypeScript ```typescript -// Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) -// Parameters for geolocation (GET /v1.0/geolocation): -// - ip (string, required) -import { Configuration, GeolocationApi } from "whoisfreaks"; +// IP Geolocation Lookup: GET https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx Geolocation.ts +import { Configuration, GeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new GeolocationApi(config); -async function main() { +// geolocation({ ip }) +// ip (string, required) +async function main(): Promise { const result = await api.geolocation({ ip: "8.8.8.8" }); - console.log(result); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -133,27 +150,34 @@ main().catch(console.error); ```go // Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.GeolocationAPI.Geolocation(ctx).Ip("8.8.8.8").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.GeolocationAPI.Geolocation(ctx).Ip("8.8.8.8").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -164,16 +188,23 @@ func main() { ## Bulk IP Geolocation -`POST /v1.0/geolocation` +`POST https://api.whoisfreaks.com/v1.0/geolocation` Up to 100 IPs. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. -**Response** (`GeolocationResponse`) +**Request body** (`application/json`, model `BulkGeolocationRequest`) + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `ips` | array | yes | Up to 100 items. | + +Example: `{"ips": ["8.8.8.8", "1.1.1.1"]}` + +**Response** (array of `GeolocationResponse`) | Field | Type | Description | |-------|------|-------------| @@ -246,21 +277,27 @@ Up to 100 IPs.
Python ```python -"""Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.geolocation_api import GeolocationApi -from whoisfreaks.models.bulk_geolocation_request import BulkGeolocationRequest +"""Bulk IP Geolocation: POST https://api.whoisfreaks.com/v1.0/geolocation + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkGeolocation.py +""" +import json +import os + +import whoisfreaks -# Parameters for bulkGeolocation (POST /v1.0/geolocation): -# - body: BulkGeolocationRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = GeolocationApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -bulk_geolocation_request = BulkGeolocationRequest() # populate fields as needed -result = api.bulk_geolocation(bulk_geolocation_request=bulk_geolocation_request) -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.GeolocationApi(client) + # bulk_geolocation parameters: + # bulk_geolocation_request (BulkGeolocationRequest, required): request body + body = whoisfreaks.BulkGeolocationRequest(ips=["8.8.8.8", "1.1.1.1"]) + results = api.bulk_geolocation(body) + print(json.dumps([item.to_dict() for item in results], indent=2)) ```
@@ -268,20 +305,31 @@ print(result)
TypeScript ```typescript -// Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) -// Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object -import { Configuration, GeolocationApi } from "whoisfreaks"; +// Bulk IP Geolocation: POST https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkGeolocation.ts +import { Configuration, GeolocationApi, ResponseError, type BulkGeolocationRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new GeolocationApi(config); -async function main() { - const result = await api.bulkGeolocation({ bulkGeolocationRequest: {} }); - console.log(result); +// bulkGeolocation({ bulkGeolocationRequest }) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main(): Promise { + const body: BulkGeolocationRequest = { ips: ["8.8.8.8", "1.1.1.1"] }; + const results = await api.bulkGeolocation({ bulkGeolocationRequest: body }); + console.log(JSON.stringify(results, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -290,27 +338,36 @@ main().catch(console.error); ```go // Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.GeolocationAPI.BulkGeolocation(ctx).BulkGeolocationRequest(*wf.NewBulkGeolocationRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkGeolocationRequest([]string{"8.8.8.8", "1.1.1.1"}) + result, _, err := client.GeolocationAPI.BulkGeolocation(ctx). + BulkGeolocationRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/ip-reputation.md b/docs/endpoints/ip-reputation.md index 861f579..94ff776 100644 --- a/docs/endpoints/ip-reputation.md +++ b/docs/endpoints/ip-reputation.md @@ -4,19 +4,19 @@ IP threat intelligence -2 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +2 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## IP Reputation Lookup -`GET /v1.0/security` +`GET https://api.whoisfreaks.com/v1.0/security` -Threat intel for IP — VPN, proxy, Tor, bots. 1 credit. +Threat intel for IP: VPN, proxy, Tor, bots. 1 credit. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `ip` | query | yes | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `ip` | query | yes | string | | | **Response** (`IpReputationResponse`) @@ -111,19 +111,26 @@ Threat intel for IP — VPN, proxy, Tor, bots. 1 credit.
Python ```python -"""Runnable example: IP Reputation Lookup (GET /v1.0/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ip_reputation_api import IPReputationApi +"""IP Reputation Lookup: GET https://api.whoisfreaks.com/v1.0/security -# Parameters for ipReputation (GET /v1.0/security): -# - ip (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = IPReputationApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python IpReputation.py +""" +import json +import os -result = api.ip_reputation(ip="8.8.8.8") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.IPReputationApi(client) + + # ip_reputation parameters: + # ip (str, required) + result = api.ip_reputation("8.8.8.8") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -131,20 +138,30 @@ print(result)
TypeScript ```typescript -// Runnable example: IP Reputation Lookup (GET /v1.0/security) -// Parameters for ipReputation (GET /v1.0/security): -// - ip (string, required) -import { Configuration, IPReputationApi } from "whoisfreaks"; +// IP Reputation Lookup: GET https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx IpReputation.ts +import { Configuration, IPReputationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new IPReputationApi(config); -async function main() { +// ipReputation({ ip }) +// ip (string, required) +async function main(): Promise { const result = await api.ipReputation({ ip: "8.8.8.8" }); - console.log(result); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -153,27 +170,34 @@ main().catch(console.error); ```go // Runnable example: IP Reputation Lookup (GET /v1.0/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.IPReputationAPI.IpReputation(ctx).Ip("8.8.8.8").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.IPReputationAPI.IpReputation(ctx).Ip("8.8.8.8").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -184,16 +208,23 @@ func main() { ## Bulk IP Reputation -`POST /v1.0/security` +`POST https://api.whoisfreaks.com/v1.0/security` Up to 100 IPs. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| +None. The API key is set once on the client. -**Response** (`IpReputationResponse`) +**Request body** (`application/json`, model `BulkGeolocationRequest`) + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `ips` | array | yes | Up to 100 items. | + +Example: `{"ips": ["8.8.8.8", "1.1.1.1"]}` + +**Response** (array of `IpReputationResponse`) | Field | Type | Description | |-------|------|-------------| @@ -286,21 +317,27 @@ Up to 100 IPs.
Python ```python -"""Runnable example: Bulk IP Reputation (POST /v1.0/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ip_reputation_api import IPReputationApi -from whoisfreaks.models.bulk_ip_reputation_request import BulkIpReputationRequest +"""Bulk IP Reputation: POST https://api.whoisfreaks.com/v1.0/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkIpReputation.py +""" +import json +import os + +import whoisfreaks -# Parameters for bulkIpReputation (POST /v1.0/security): -# - body: BulkIpReputationRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = IPReputationApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -bulk_ip_reputation_request = BulkIpReputationRequest() # populate fields as needed -result = api.bulk_ip_reputation(bulk_ip_reputation_request=bulk_ip_reputation_request) -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.IPReputationApi(client) + # bulk_ip_reputation parameters: + # bulk_geolocation_request (BulkGeolocationRequest, required): request body + body = whoisfreaks.BulkGeolocationRequest(ips=["8.8.8.8", "1.1.1.1"]) + results = api.bulk_ip_reputation(body) + print(json.dumps([item.to_dict() for item in results], indent=2)) ```
@@ -308,20 +345,31 @@ print(result)
TypeScript ```typescript -// Runnable example: Bulk IP Reputation (POST /v1.0/security) -// Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object -import { Configuration, IPReputationApi } from "whoisfreaks"; +// Bulk IP Reputation: POST https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkIpReputation.ts +import { Configuration, IPReputationApi, ResponseError, type BulkGeolocationRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new IPReputationApi(config); -async function main() { - const result = await api.bulkIpReputation({ bulkIpReputationRequest: {} }); - console.log(result); +// bulkIpReputation({ bulkGeolocationRequest }) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main(): Promise { + const body: BulkGeolocationRequest = { ips: ["8.8.8.8", "1.1.1.1"] }; + const results = await api.bulkIpReputation({ bulkGeolocationRequest: body }); + console.log(JSON.stringify(results, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -330,27 +378,36 @@ main().catch(console.error); ```go // Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.IPReputationAPI.BulkIpReputation(ctx).BulkIpReputationRequest(*wf.NewBulkIpReputationRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkGeolocationRequest([]string{"8.8.8.8", "1.1.1.1"}) + result, _, err := client.IPReputationAPI.BulkIpReputation(ctx). + BulkGeolocationRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/ip-whois.md b/docs/endpoints/ip-whois.md index 7d83c4d..d8927ba 100644 --- a/docs/endpoints/ip-whois.md +++ b/docs/endpoints/ip-whois.md @@ -4,20 +4,20 @@ IP address WHOIS -1 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +1 endpoint. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## IP WHOIS Lookup -`GET /v1.0/ip-whois` +`GET https://api.whoisfreaks.com/v1.0/ip-whois` WHOIS for an IP address. 1 credit. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `ip` | query | yes | string | | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `ip` | query | yes | string | | | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`IpWhoisResponse`) @@ -204,20 +204,27 @@ WHOIS for an IP address. 1 credit.
Python ```python -"""Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ipwhois_api import IPWHOISApi +"""IP WHOIS Lookup: GET https://api.whoisfreaks.com/v1.0/ip-whois -# Parameters for ipWhois (GET /v1.0/ip-whois): -# - ip (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = IPWHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python IpWhois.py +""" +import json +import os -result = api.ip_whois(ip="8.8.8.8") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.IPWHOISApi(client) + + # ip_whois parameters: + # ip (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.ip_whois("8.8.8.8") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -225,21 +232,31 @@ print(result)
TypeScript ```typescript -// Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) -// Parameters for ipWhois (GET /v1.0/ip-whois): -// - ip (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, IPWHOISApi } from "whoisfreaks"; +// IP WHOIS Lookup: GET https://api.whoisfreaks.com/v1.0/ip-whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx IpWhois.ts +import { Configuration, IPWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new IPWHOISApi(config); -async function main() { - const result = await api.ipWhois({ ip: "8.8.8.8", format: undefined }); - console.log(result); +// ipWhois({ ip, format? }) +// ip (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.ipWhois({ ip: "8.8.8.8" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -248,28 +265,35 @@ main().catch(console.error); ```go // Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.IPWHOISAPI.IpWhois(ctx).Ip("8.8.8.8").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.IPWHOISAPI.IpWhois(ctx).Ip("8.8.8.8").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/ssl.md b/docs/endpoints/ssl.md index c01a2e1..8c46064 100644 --- a/docs/endpoints/ssl.md +++ b/docs/endpoints/ssl.md @@ -4,22 +4,22 @@ SSL certificate lookup -1 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +1 endpoint. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## SSL Certificate Lookup -`GET /v1.0/ssl/live` +`GET https://api.whoisfreaks.com/v1.0/ssl/live` Real-time SSL cert with optional chain. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `domainName` | query | yes | string | | -| `chain` | query | no | boolean | | -| `sslRaw` | query | no | boolean | | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `domainName` | query | yes | string | | | +| `chain` | query | no | boolean | `false` | | +| `sslRaw` | query | no | boolean | `false` | | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`SslResponse`) @@ -54,22 +54,29 @@ Real-time SSL cert with optional chain.
Python ```python -"""Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ssl_api import SSLApi - -# Parameters for sslLookup (GET /v1.0/ssl/live): -# - domainName (string, required) -# - chain (boolean, optional) -# - sslRaw (boolean, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = SSLApi(ApiClient(config)) - -result = api.ssl_lookup(domain_name="example.com") -print(result) +"""SSL Certificate Lookup: GET https://api.whoisfreaks.com/v1.0/ssl/live +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python SslLookup.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.SSLApi(client) + + # ssl_lookup parameters: + # domain_name (str, required) + # chain (bool, optional, keyword): default False + # ssl_raw (bool, optional, keyword): default False + # format (str, optional, keyword): one of json, xml; default "json" + result = api.ssl_lookup("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -77,23 +84,33 @@ print(result)
TypeScript ```typescript -// Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) -// Parameters for sslLookup (GET /v1.0/ssl/live): -// - domainName (string, required) -// - chain (boolean, optional) -// - sslRaw (boolean, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, SSLApi } from "whoisfreaks"; +// SSL Certificate Lookup: GET https://api.whoisfreaks.com/v1.0/ssl/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx SslLookup.ts +import { Configuration, SSLApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new SSLApi(config); -async function main() { - const result = await api.sslLookup({ domainName: "example.com", chain: undefined, sslRaw: undefined, format: undefined }); - console.log(result); +// sslLookup({ domainName, chain?, sslRaw?, format? }) +// domainName (string, required) +// chain (boolean, optional): default false +// sslRaw (boolean, optional): default false +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.sslLookup({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -102,30 +119,37 @@ main().catch(console.error); ```go // Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) // - sslRaw (boolean, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.SSLAPI.SslLookup(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.SSLAPI.SslLookup(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/subdomains.md b/docs/endpoints/subdomains.md index 71bb33d..020220e 100644 --- a/docs/endpoints/subdomains.md +++ b/docs/endpoints/subdomains.md @@ -4,24 +4,24 @@ Subdomain enumeration -1 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +1 endpoint. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Subdomains Lookup -`GET /v1.0/subdomains` +`GET https://api.whoisfreaks.com/v1.0/subdomains` All subdomains including nested. 2 credits per query. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `domain` | query | yes | string | | -| `after` | query | no | string | | -| `before` | query | no | string | | -| `status` | query | no | string | (one of: active, inactive) | -| `page` | query | no | integer | | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `domain` | query | yes | string | | | +| `after` | query | no | string (date) | | | +| `before` | query | no | string (date) | | | +| `status` | query | no | string | | (one of: active, inactive) | +| `page` | query | no | integer | `1` | | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`SubdomainsResponse`) @@ -53,25 +53,31 @@ All subdomains including nested. 2 credits per query.
Python ```python -"""Runnable example: Subdomains Lookup (GET /v1.0/subdomains).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.subdomains_api import SubdomainsApi - -# Parameters for subdomains (GET /v1.0/subdomains): -# - domain (string, required) -# - after (string, optional) -# - before (string, optional) -# - status (string (one of: active, inactive), optional) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = SubdomainsApi(ApiClient(config)) - -result = api.subdomains(domain="example.com", after="2000-01-01", before=str(date.today())) -print(result) - +"""Subdomains Lookup: GET https://api.whoisfreaks.com/v1.0/subdomains + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python Subdomains.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.SubdomainsApi(client) + + # subdomains parameters: + # domain (str, required) + # after (datetime.date, optional, keyword) + # before (datetime.date, optional, keyword) + # status (str, optional, keyword): one of active, inactive + # page (int, optional, keyword): default 1 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.subdomains("whoisfreaks.com", page=1) + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -79,25 +85,35 @@ print(result)
TypeScript ```typescript -// Runnable example: Subdomains Lookup (GET /v1.0/subdomains) -// Parameters for subdomains (GET /v1.0/subdomains): -// - domain (string, required) -// - after (string, optional) -// - before (string, optional) -// - status (string (one of: active, inactive), optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, SubdomainsApi } from "whoisfreaks"; +// Subdomains Lookup: GET https://api.whoisfreaks.com/v1.0/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx Subdomains.ts +import { Configuration, SubdomainsApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new SubdomainsApi(config); -async function main() { - const result = await api.subdomains({ domain: "example.com", after: "2000-01-01", before: new Date().toISOString().slice(0,10), status: undefined, page: undefined, format: undefined }); - console.log(result); +// subdomains({ domain, after?, before?, status?, page?, format? }) +// domain (string, required) +// after (Date, optional) +// before (Date, optional) +// status ("active" | "inactive", optional) +// page (number, optional): default 1 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.subdomains({ domain: "whoisfreaks.com", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -106,6 +122,7 @@ main().catch(console.error); ```go // Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -113,26 +130,31 @@ main().catch(console.error); // - status (string (one of: active, inactive), optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.SubdomainsAPI.Subdomains(ctx).Domain("example.com").After("2000-01-01").Before(time.Now().Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.SubdomainsAPI.Subdomains(ctx).Domain("whoisfreaks.com").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/typosquatting.md b/docs/endpoints/typosquatting.md index 1db858f..f1b4950 100644 --- a/docs/endpoints/typosquatting.md +++ b/docs/endpoints/typosquatting.md @@ -4,21 +4,21 @@ Detect typo variants of brand domains -1 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +1 endpoint. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Typosquatting Lookup -`GET /v3.0/domain/typos` +`GET https://api.whoisfreaks.com/v3.0/domain/typos` Find typo variants of a brand. 5 credits per page. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `keyword` | query | no | string | | -| `pattern` | query | no | string | | -| `pageToken` | query | no | string | | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `keyword` | query | no | string | | | +| `pattern` | query | no | string | | | +| `pageToken` | query | no | string | | | **Response** (`TyposquattingResponse`) @@ -50,21 +50,28 @@ Find typo variants of a brand. 5 credits per page.
Python ```python -"""Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.typosquatting_api import TyposquattingApi +"""Typosquatting Lookup: GET https://api.whoisfreaks.com/v3.0/domain/typos -# Parameters for typosquatting (GET /v3.0/domain/typos): -# - keyword (string, optional) -# - pattern (string, optional) -# - pageToken (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = TyposquattingApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python Typosquatting.py +""" +import json +import os -result = api.typosquatting() -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.TyposquattingApi(client) + + # typosquatting parameters: + # keyword (str, optional, keyword) + # pattern (str, optional, keyword) + # page_token (str, optional, keyword) + result = api.typosquatting(keyword="whoisfreaks") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -72,22 +79,32 @@ print(result)
TypeScript ```typescript -// Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) -// Parameters for typosquatting (GET /v3.0/domain/typos): -// - keyword (string, optional) -// - pattern (string, optional) -// - pageToken (string, optional) -import { Configuration, TyposquattingApi } from "whoisfreaks"; +// Typosquatting Lookup: GET https://api.whoisfreaks.com/v3.0/domain/typos +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx Typosquatting.ts +import { Configuration, TyposquattingApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new TyposquattingApi(config); -async function main() { - const result = await api.typosquatting({ keyword: undefined, pattern: undefined, pageToken: undefined }); - console.log(result); +// typosquatting({ keyword?, pattern?, pageToken? }) +// keyword (string, optional) +// pattern (string, optional) +// pageToken (string, optional) +async function main(): Promise { + const result = await api.typosquatting({ keyword: "whoisfreaks" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -96,29 +113,36 @@ main().catch(console.error); ```go // Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) // - pageToken (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.TyposquattingAPI.Typosquatting(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.TyposquattingAPI.Typosquatting(ctx).Keyword("whoisfreaks").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/endpoints/whois.md b/docs/endpoints/whois.md index 7bb005f..dcdb8c4 100644 --- a/docs/endpoints/whois.md +++ b/docs/endpoints/whois.md @@ -4,20 +4,20 @@ WHOIS lookup APIs (live, historical, reverse, bulk) -4 endpoint(s). All requests require your API key — see [Authentication](../authentication.md). +4 endpoints. Requests need your API key unless noted otherwise. See [Authentication](../authentication.md). ## Live WHOIS Lookup -`GET /v2.0/whois/live` +`GET https://api.whoisfreaks.com/v2.0/whois/live` Real-time WHOIS lookup from authoritative servers. Cost 1 credit. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `domainName` | query | yes | string | | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `domainName` | query | yes | string | | | +| `format` | query | no | string | `json` | (one of: json, xml) | **Response** (`WhoisResponse`) @@ -125,7 +125,7 @@ Real-time WHOIS lookup from authoritative servers. Cost 1 credit. | `domain_registrar` | RegistrarInformation | | | `name_servers` | array | | | `domain_status` | array | | -| `whois_raw_domain` | string | | +| `whois_raw_registery` | string | Raw registry WHOIS text (field name spelled as the API returns it) |
@@ -135,20 +135,27 @@ Real-time WHOIS lookup from authoritative servers. Cost 1 credit.
Python ```python -"""Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi +"""Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisLive.py +""" +import json +import os -# Parameters for whoisLive (GET /v2.0/whois/live): -# - domainName (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +import whoisfreaks -result = api.whois_live(domain_name="example.com") -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + + # whois_live parameters: + # domain_name (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.whois_live("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -156,21 +163,31 @@ print(result)
TypeScript ```typescript -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) -// Parameters for whoisLive (GET /v2.0/whois/live): -// - domainName (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; +// Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisLive.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisLive({ domainName: "example.com", format: undefined }); - console.log(result); +// whoisLive({ domainName, format? }) +// domainName (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.whoisLive({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -179,28 +196,35 @@ main().catch(console.error); ```go // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -211,15 +235,23 @@ func main() { ## Bulk WHOIS Lookup -`POST /v2.0/bulkwhois/live` +`POST https://api.whoisfreaks.com/v2.0/bulkwhois/live` Up to 100 domains in one request. 1 credit per successful domain. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `format` | query | no | string | `json` | (one of: json, xml) | + +**Request body** (`application/json`, model `BulkWhoisRequest`) + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `domainNames` | array | yes | Up to 100 items. | + +Example: `{"domainNames": ["whoisfreaks.com", "jfreaks.com"]}` **Response** (`BulkWhoisResponse`) @@ -234,6 +266,26 @@ Up to 100 domains in one request. 1 credit per successful domain. | `status` | boolean | | | `domain_name` | string | | | `error` | string | | +| `query_time` | string | | +| `whois_server` | string | | +| `domain_registered` | string | | +| `secure_dns` | boolean | | +| `domain_handle` | string | | +| `create_date` | string | | +| `update_date` | string | | +| `expiry_date` | string | | +| `domain_registrar` | RegistrarInformation | | +| `reseller_contact` | ResellerContact | | +| `registrant_contact` | PersonalInformation | | +| `administrative_contact` | PersonalInformation | | +| `technical_contact` | PersonalInformation | | +| `billing_contact` | PersonalInformation | | +| `eligibility_info` | EligibilityInfo | | +| `abuse_contact` | RegistrarInformation | | +| `name_servers` | array | | +| `domain_status` | array | | +| `whois_raw_domain` | string | | +| `registry_data` | RegistryData | | @@ -243,22 +295,28 @@ Up to 100 domains in one request. 1 credit per successful domain.
Python ```python -"""Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi -from whoisfreaks.models.bulk_whois_request import BulkWhoisRequest - -# Parameters for bulkWhois (POST /v2.0/bulkwhois/live): -# - format (string (one of: json, xml), optional) -# - body: BulkWhoisRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) - -bulk_whois_request = BulkWhoisRequest() # populate fields as needed -result = api.bulk_whois(bulk_whois_request=bulk_whois_request) -print(result) +"""Bulk WHOIS Lookup: POST https://api.whoisfreaks.com/v2.0/bulkwhois/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkWhois.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + + # bulk_whois parameters: + # bulk_whois_request (BulkWhoisRequest, required): request body + # format (str, optional, keyword): one of json, xml; default "json" + body = whoisfreaks.BulkWhoisRequest(domain_names=["whoisfreaks.com", "jfreaks.com"]) + result = api.bulk_whois(body) + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -266,21 +324,32 @@ print(result)
TypeScript ```typescript -// Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) -// Parameters for bulkWhois (POST /v2.0/bulkwhois/live): -// - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object -import { Configuration, WHOISApi } from "whoisfreaks"; +// Bulk WHOIS Lookup: POST https://api.whoisfreaks.com/v2.0/bulkwhois/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkWhois.ts +import { Configuration, WHOISApi, ResponseError, type BulkWhoisRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.bulkWhois({ bulkWhoisRequest: {}, format: undefined }); - console.log(result); +// bulkWhois({ bulkWhoisRequest, format? }) +// bulkWhoisRequest (BulkWhoisRequest, required): request body +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const body: BulkWhoisRequest = { domainNames: ["whoisfreaks.com", "jfreaks.com"] }; + const result = await api.bulkWhois({ bulkWhoisRequest: body }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -289,28 +358,36 @@ main().catch(console.error); ```go // Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.BulkWhois(ctx).BulkWhoisRequest(*wf.NewBulkWhoisRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkWhoisRequest([]string{"whoisfreaks.com", "jfreaks.com"}) + result, _, err := client.WHOISAPI.BulkWhois(ctx).BulkWhoisRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -321,15 +398,16 @@ func main() { ## Historical WHOIS records for a domain -`GET /v2.0/whois/history` +`GET https://api.whoisfreaks.com/v2.0/whois/history` + +Every WHOIS record captured for the domain since 1986, in one response (no pagination). Cost 2 credits. **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `domainName` | query | yes | string | Domain to fetch historical WHOIS records for | -| `page` | query | no | integer | Page number | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `domainName` | query | yes | string | | Domain to fetch historical WHOIS records for | +| `format` | query | no | string | | (one of: json, xml) | **Response** (`WhoisHistoricalResponse`) @@ -376,21 +454,27 @@ func main() {
Python ```python -"""Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi +"""Historical WHOIS records for a domain: GET https://api.whoisfreaks.com/v2.0/whois/history + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisHistory.py +""" +import json +import os -# Parameters for whoisHistory (GET /v2.0/whois/history): -# - domainName (string, required): Domain to fetch historical WHOIS records for -# - page (integer, optional): Page number -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +import whoisfreaks -result = api.whois_history(domain_name="example.com") -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + + # whois_history parameters: + # domain_name (str, required): Domain to fetch historical WHOIS records for + # format (str, optional, keyword): one of json, xml + result = api.whois_history("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -398,22 +482,31 @@ print(result)
TypeScript ```typescript -// Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) -// Parameters for whoisHistory (GET /v2.0/whois/history): -// - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; +// Historical WHOIS records for a domain: GET https://api.whoisfreaks.com/v2.0/whois/history +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisHistory.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisHistory({ domainName: "example.com", page: undefined, format: undefined }); - console.log(result); +// whoisHistory({ domainName, format? }) +// domainName (string, required): Domain to fetch historical WHOIS records for +// format ("json" | "xml", optional) +async function main(): Promise { + const result = await api.whoisHistory({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -422,29 +515,35 @@ main().catch(console.error); ```go // Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisHistory(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisHistory(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -455,23 +554,23 @@ func main() { ## Reverse WHOIS lookup by keyword -`GET /v2.0/whois/reverse` +`GET https://api.whoisfreaks.com/v2.0/whois/reverse` **Parameters** -| Parameter | In | Required | Type | Description | -|-----------|----|----------|------|-------------| -| `keyword` | query | yes | string | Keyword to search across WHOIS records | -| `page` | query | no | integer | Page number | -| `format` | query | no | string | (one of: json, xml) | +| Parameter | In | Required | Type | Default | Description | +|-----------|----|----------|------|---------|-------------| +| `keyword` | query | yes | string | | Keyword to search across WHOIS records | +| `page` | query | no | integer | | Page number | +| `format` | query | no | string | | (one of: json, xml) | **Response** (`ReverseWhoisResponse`) | Field | Type | Description | |-------|------|-------------| -| `Total_Result` | integer | | -| `Total_Pages` | integer | | -| `Current_Page` | integer | | +| `total_Result` | integer | | +| `total_Pages` | integer | | +| `current_Page` | integer | | | `whois_domains_historical` | array | |
WhoisHistoricalItem object @@ -510,21 +609,28 @@ func main() {
Python ```python -"""Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi +"""Reverse WHOIS lookup by keyword: GET https://api.whoisfreaks.com/v2.0/whois/reverse + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisReverse.py +""" +import json +import os + +import whoisfreaks -# Parameters for whoisReverse (GET /v2.0/whois/reverse): -# - keyword (string, required): Keyword to search across WHOIS records -# - page (integer, optional): Page number -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.whois_reverse(keyword="value") -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + # whois_reverse parameters: + # keyword (str, required): Keyword to search across WHOIS records + # page (int, optional, keyword): Page number + # format (str, optional, keyword): one of json, xml + result = api.whois_reverse("whoisfreaks", page=1) + print(json.dumps(result.to_dict(), indent=2)) ```
@@ -532,22 +638,32 @@ print(result)
TypeScript ```typescript -// Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) -// Parameters for whoisReverse (GET /v2.0/whois/reverse): -// - keyword (string, required): Keyword to search across WHOIS records -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; +// Reverse WHOIS lookup by keyword: GET https://api.whoisfreaks.com/v2.0/whois/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisReverse.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisReverse({ keyword: "value", page: undefined, format: undefined }); - console.log(result); +// whoisReverse({ keyword, page?, format? }) +// keyword (string, required): Keyword to search across WHOIS records +// page (number, optional): Page number +// format ("json" | "xml", optional) +async function main(): Promise { + const result = await api.whoisReverse({ keyword: "whoisfreaks", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ```
@@ -556,29 +672,36 @@ main().catch(console.error); ```go // Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisReverse(ctx).Keyword("value").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisReverse(ctx).Keyword("whoisfreaks").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` diff --git a/docs/languages/csharp.md b/docs/languages/csharp.md index 1258c2c..38e946e 100644 --- a/docs/languages/csharp.md +++ b/docs/languages/csharp.md @@ -2,7 +2,7 @@ ## About -The official **WhoisFreaks C# / .NET SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from C# / .NET with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to NuGet. +The official **WhoisFreaks C# / .NET SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from C# / .NET with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to NuGet. **Keywords:** c# / .net whois api, c# / .net whois sdk, whoisfreaks c# / .net, c# / .net domain lookup, c# / .net dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api @@ -17,7 +17,7 @@ dotnet add package WhoisFreaks ## Build from Source -Prefer to build the SDK yourself instead of installing from NuGet? Clone the monorepo and build the C# / .NET package locally: +Prefer to build the SDK yourself instead of installing from NuGet? Clone the C# / .NET SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-csharp @@ -29,10 +29,12 @@ dotnet build # or: dotnet pack -c Release A complete walkthrough from an empty directory to a running program: +You need the .NET 8 SDK or later. Create a console app and add the package: + ```bash -mkdir whoisfreaks-test && cd whoisfreaks-test -dotnet new console -dotnet add package WhoisFreaks +dotnet new console -o whoisfreaks-test +cd whoisfreaks-test +dotnet add package WhoisFreaks --version 0.23.0 ``` Replace `Program.cs` with: @@ -41,43 +43,51 @@ Replace `Program.cs` with: using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; -config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once -var api = new WHOISApi(config); +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call -var result = api.WhoisLive("example.com"); -Console.WriteLine(result); +var whois = new WHOISApi(config); +WhoisResponse record = whois.WhoisLive("whoisfreaks.com"); +Console.WriteLine($"{record.DomainName} expires {record.ExpiryDate}"); +Console.WriteLine(record.ToJson()); ``` -Run it: +Set your API key and run it: ```bash +export WHOISFREAKS_API_KEY="your_api_key" dotnet run ``` +To run one of the [runnable examples](../../examples/csharp/README.md), use it as `Program.cs` and run `dotnet run` again. + ## Configure See [Authentication](../authentication.md) for how to obtain a key. Minimal setup: ```csharp // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class WhoisLive { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.WhoisLive("example.com", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +WhoisResponse result = api.WhoisLive("whoisfreaks.com"); +Console.WriteLine(result.ToJson()); ``` @@ -93,22 +103,23 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, ```csharp // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class WhoisLive { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.WhoisLive("example.com", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +WhoisResponse result = api.WhoisLive("whoisfreaks.com"); +Console.WriteLine(result.ToJson()); ``` @@ -118,23 +129,25 @@ class WhoisLive { ```csharp // Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class BulkWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.BulkWhois(new BulkWhoisRequest(), null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +var body = new BulkWhoisRequest(domainNames: new List { "whoisfreaks.com", "jfreaks.com" }); +BulkWhoisResponse result = api.BulkWhois(body); +Console.WriteLine(result.ToJson()); ``` @@ -144,23 +157,23 @@ class BulkWhois { ```csharp // Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class WhoisHistory { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.WhoisHistory("example.com", null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +WhoisHistoricalResponse result = api.WhoisHistory("whoisfreaks.com"); +Console.WriteLine(result.ToJson()); ``` @@ -170,6 +183,7 @@ class WhoisHistory { ```csharp // Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number @@ -177,16 +191,16 @@ class WhoisHistory { using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class WhoisReverse { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.WhoisReverse("value", null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +ReverseWhoisResponse result = api.WhoisReverse("whoisfreaks", page: 1); +Console.WriteLine(result.ToJson()); ``` @@ -198,24 +212,25 @@ class WhoisReverse { ```csharp // Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DnsLive { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DNSApi(config); - var result = api.DnsLive("example.com", "8.8.8.8", "value", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DNSApi(config); + +DnsResponse result = api.DnsLive("A,MX,TXT", domainName: "whoisfreaks.com"); +Console.WriteLine(result.ToJson()); ``` @@ -225,6 +240,7 @@ class DnsLive { ```csharp // Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) @@ -233,16 +249,16 @@ class DnsLive { using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DnsHistorical { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DNSApi(config); - var result = api.DnsHistorical("example.com", "value", null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DNSApi(config); + +HistoricalDnsResponse result = api.DnsHistorical("whoisfreaks.com", "A,MX,TXT", page: 1); +Console.WriteLine(result.ToJson()); ``` @@ -252,6 +268,7 @@ class DnsHistorical { ```csharp // Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) @@ -261,16 +278,16 @@ class DnsHistorical { using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DnsReverse { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DNSApi(config); - var result = api.DnsReverse("value", "a", true, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DNSApi(config); + +ReverseDnsResponse result = api.DnsReverse("8.8.8.8", "a", page: 1); +Console.WriteLine(result.ToJson()); ``` @@ -280,24 +297,26 @@ class DnsReverse { ```csharp // Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class DnsBulk { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DNSApi(config); - var result = api.DnsBulk("value", new DnsBulkRequest(), null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DNSApi(config); + +var body = new DnsBulkRequest(domainNames: new List { "whoisfreaks.com", "example.com" }); +BulkDnsResponse result = api.DnsBulk("A,MX,TXT", body); +Console.WriteLine(result.ToJson()); ``` @@ -309,6 +328,7 @@ class DnsBulk { ```csharp // Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. @@ -317,16 +337,16 @@ class DnsBulk { using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DomainAvailabilityV2 { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DomainAvailabilityApi(config); - var result = api.DomainAvailabilityV2("example.com", null, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DomainAvailabilityApi(config); + +DomainAvailabilityResponse result = api.DomainAvailabilityV2("google.com", sug: true, count: 5); +Console.WriteLine(result.ToJson()); ``` @@ -336,24 +356,26 @@ class DomainAvailabilityV2 { ```csharp // Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class BulkDomainAvailabilityV2 { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DomainAvailabilityApi(config); - var result = api.BulkDomainAvailabilityV2(new BulkDomainAvailabilityRequest(), null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DomainAvailabilityApi(config); + +var body = new BulkDomainAvailabilityRequest(domainNames: new List { "whoisfreaks.com", "example.com" }); +BulkDomainAvailabilityResponse result = api.BulkDomainAvailabilityV2(body); +Console.WriteLine(result.ToJson()); ``` @@ -365,6 +387,7 @@ class BulkDomainAvailabilityV2 { ```csharp // Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) @@ -372,16 +395,16 @@ class BulkDomainAvailabilityV2 { using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class Typosquatting { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new TyposquattingApi(config); - var result = api.Typosquatting(null, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new TyposquattingApi(config); + +TyposquattingResponse result = api.Typosquatting(keyword: "whoisfreaks"); +Console.WriteLine(result.ToJson()); ``` @@ -393,6 +416,7 @@ class Typosquatting { ```csharp // Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) @@ -401,16 +425,16 @@ class Typosquatting { using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class SslLookup { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new SSLApi(config); - var result = api.SslLookup("example.com", null, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new SSLApi(config); + +SslResponse result = api.SslLookup("whoisfreaks.com"); +Console.WriteLine(result.ToJson()); ``` @@ -422,21 +446,22 @@ class SslLookup { ```csharp // Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class Geolocation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new GeolocationApi(config); - var result = api.Geolocation("8.8.8.8"); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new GeolocationApi(config); + +GeolocationResponse result = api.Geolocation("8.8.8.8"); +Console.WriteLine(result.ToJson()); ``` @@ -446,21 +471,26 @@ class Geolocation { ```csharp // Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class BulkGeolocation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new GeolocationApi(config); - var result = api.BulkGeolocation(new BulkGeolocationRequest()); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new GeolocationApi(config); + +var body = new BulkGeolocationRequest(ips: new List { "8.8.8.8", "1.1.1.1" }); +List result = api.BulkGeolocation(body); +foreach (var item in result) +{ + Console.WriteLine(item.ToJson()); } ``` @@ -473,6 +503,7 @@ class BulkGeolocation { ```csharp // Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -483,16 +514,16 @@ class BulkGeolocation { using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class Subdomains { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new SubdomainsApi(config); - var result = api.Subdomains("example.com", "2000-01-01", DateTime.UtcNow.ToString("yyyy-MM-dd"), null, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new SubdomainsApi(config); + +SubdomainsResponse result = api.Subdomains("whoisfreaks.com", page: 1); +Console.WriteLine(result.ToJson()); ``` @@ -504,21 +535,22 @@ class Subdomains { ```csharp // Runnable example: IP Reputation Lookup (GET /v1.0/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class IpReputation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new IPReputationApi(config); - var result = api.IpReputation("8.8.8.8"); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new IPReputationApi(config); + +IpReputationResponse result = api.IpReputation("8.8.8.8"); +Console.WriteLine(result.ToJson()); ``` @@ -528,21 +560,26 @@ class IpReputation { ```csharp // Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class BulkIpReputation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new IPReputationApi(config); - var result = api.BulkIpReputation(new BulkIpReputationRequest()); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new IPReputationApi(config); + +var body = new BulkGeolocationRequest(ips: new List { "8.8.8.8", "1.1.1.1" }); +List result = api.BulkIpReputation(body); +foreach (var item in result) +{ + Console.WriteLine(item.ToJson()); } ``` @@ -555,22 +592,23 @@ class BulkIpReputation { ```csharp // Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DomainReputation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DomainReputationApi(config); - var result = api.DomainReputation("example.com", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DomainReputationApi(config); + +DomainReputationResponse result = api.DomainReputation("amazon.com"); +Console.WriteLine(result.ToJson()); ``` @@ -582,22 +620,23 @@ class DomainReputation { ```csharp // Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class AsnWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new ASNWHOISApi(config); - var result = api.AsnWhois("AS15169", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new ASNWHOISApi(config); + +AsnWhoisResponse result = api.AsnWhois("as15169"); +Console.WriteLine(result.ToJson()); ``` @@ -609,22 +648,23 @@ class AsnWhois { ```csharp // Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class IpWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new IPWHOISApi(config); - var result = api.IpWhois("8.8.8.8", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new IPWHOISApi(config); + +IpWhoisResponse result = api.IpWhois("8.8.8.8"); +Console.WriteLine(result.ToJson()); ``` @@ -636,21 +676,22 @@ class IpWhois { ```csharp // Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; -class RotateApiKey { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new AccountApi(config); - var result = api.RotateApiKey(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new AccountApi(config); + +string newKey = api.RotateApiKey(); +// The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY. +Console.WriteLine($"New API key: {newKey}"); ``` @@ -660,21 +701,22 @@ class RotateApiKey { ```csharp // Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class AccountUsage { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new AccountApi(config); - var result = api.AccountUsage(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new AccountApi(config); + +AccountUsageResponse result = api.AccountUsage(); +Console.WriteLine(result.ToJson()); ``` @@ -684,21 +726,20 @@ class AccountUsage { ```csharp // Runnable example: Database File Status (Public) (GET /v3.4/status) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DatabaseFileStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new AccountApi(config); - var result = api.DatabaseFileStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +// Public endpoint: no API key needed. +var api = new AccountApi(config); + +DatabaseFileStatus result = api.DatabaseFileStatus(); +Console.WriteLine(result.ToJson()); ``` @@ -710,23 +751,31 @@ class DatabaseFileStatus { ```csharp // Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyGtld { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyGtld(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyGtld(true, date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyGtld.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -736,23 +785,31 @@ class DbNewlyGtld { ```csharp // Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyCctld { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyCctld(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyCctld(true, date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyCctld.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -762,21 +819,29 @@ class DbNewlyCctld { ```csharp // Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyGtldCleaned { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyGtldCleaned(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyGtldCleaned(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyGtldCleaned.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -786,21 +851,29 @@ class DbNewlyGtldCleaned { ```csharp // Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyCctldCleaned { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyCctldCleaned(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyCctldCleaned(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyCctldCleaned.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -810,21 +883,25 @@ class DbNewlyCctldCleaned { ```csharp // Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyGtldJson { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyGtldJson(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +List result = api.DbNewlyGtldJson(date: new DateOnly(2026, 10, 1)); +foreach (var item in result) +{ + Console.WriteLine(item); } ``` @@ -835,21 +912,25 @@ class DbNewlyGtldJson { ```csharp // Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyCctldJson { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyCctldJson(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +List result = api.DbNewlyCctldJson(date: new DateOnly(2026, 10, 1)); +foreach (var item in result) +{ + Console.WriteLine(item); } ``` @@ -860,21 +941,29 @@ class DbNewlyCctldJson { ```csharp // Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyDns { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyDns(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyDns(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyDns.json"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -886,22 +975,30 @@ class DbNewlyDns { ```csharp // Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbExpired { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbExpired(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +FileParameter download = api.DbExpired(true, date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbExpired.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -911,21 +1008,29 @@ class DbExpired { ```csharp // Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbExpiredCleaned { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbExpiredCleaned(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +FileParameter download = api.DbExpiredCleaned(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbExpiredCleaned.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -935,22 +1040,30 @@ class DbExpiredCleaned { ```csharp // Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDropped { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbDropped(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +FileParameter download = api.DbDropped(true, date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDropped.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -960,21 +1073,25 @@ class DbDropped { ```csharp // Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDroppedJson { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbDroppedJson(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +List result = api.DbDroppedJson(date: new DateOnly(2026, 10, 1)); +foreach (var item in result) +{ + Console.WriteLine(item); } ``` @@ -985,22 +1102,30 @@ class DbDroppedJson { ```csharp // Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDroppedBacklinks { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbDroppedBacklinks(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +FileParameter download = api.DbDroppedBacklinks(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDroppedBacklinks.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1012,21 +1137,29 @@ class DbDroppedBacklinks { ```csharp // Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbWhoisDaily { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesWHOISApi(config); - var result = api.DbWhoisDaily(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesWHOISApi(config); + +FileParameter download = api.DbWhoisDaily(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbWhoisDaily.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1036,21 +1169,29 @@ class DbWhoisDaily { ```csharp // Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbWhoisWeekly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesWHOISApi(config); - var result = api.DbWhoisWeekly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesWHOISApi(config); + +FileParameter download = api.DbWhoisWeekly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbWhoisWeekly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1060,21 +1201,29 @@ class DbWhoisWeekly { ```csharp // Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbWhoisMonthly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesWHOISApi(config); - var result = api.DbWhoisMonthly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesWHOISApi(config); + +FileParameter download = api.DbWhoisMonthly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbWhoisMonthly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1086,21 +1235,29 @@ class DbWhoisMonthly { ```csharp // Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDnsDaily { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesDNSApi(config); - var result = api.DbDnsDaily(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesDNSApi(config); + +FileParameter download = api.DbDnsDaily(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDnsDaily.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1110,21 +1267,29 @@ class DbDnsDaily { ```csharp // Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDnsWeekly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesDNSApi(config); - var result = api.DbDnsWeekly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesDNSApi(config); + +FileParameter download = api.DbDnsWeekly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDnsWeekly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1134,21 +1299,29 @@ class DbDnsWeekly { ```csharp // Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDnsMonthly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesDNSApi(config); - var result = api.DbDnsMonthly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesDNSApi(config); + +FileParameter download = api.DbDnsMonthly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDnsMonthly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1160,21 +1333,29 @@ class DbDnsMonthly { ```csharp // Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbSubdomainsDaily { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesSubdomainsApi(config); - var result = api.DbSubdomainsDaily(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesSubdomainsApi(config); + +FileParameter download = api.DbSubdomainsDaily(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbSubdomainsDaily.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1184,21 +1365,29 @@ class DbSubdomainsDaily { ```csharp // Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbSubdomainsWeekly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesSubdomainsApi(config); - var result = api.DbSubdomainsWeekly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesSubdomainsApi(config); + +FileParameter download = api.DbSubdomainsWeekly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbSubdomainsWeekly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1208,21 +1397,29 @@ class DbSubdomainsWeekly { ```csharp // Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbSubdomainsMonthly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesSubdomainsApi(config); - var result = api.DbSubdomainsMonthly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesSubdomainsApi(config); + +FileParameter download = api.DbSubdomainsMonthly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbSubdomainsMonthly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1234,21 +1431,22 @@ class DbSubdomainsMonthly { ```csharp // Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbIpCountryStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPGeolocationApi(config); - var result = api.DbIpCountryStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPGeolocationApi(config); + +SnapshotStatus result = api.DbIpCountryStatus(); +Console.WriteLine(result.ToJson()); ``` @@ -1258,21 +1456,29 @@ class DbIpCountryStatus { ```csharp // Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbIpCountry { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPGeolocationApi(config); - var result = api.DbIpCountry(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPGeolocationApi(config); + +FileParameter download = api.DbIpCountry(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbIpCountry.zip"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1282,21 +1488,22 @@ class DbIpCountry { ```csharp // Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbIpCityStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPGeolocationApi(config); - var result = api.DbIpCityStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPGeolocationApi(config); + +SnapshotStatus result = api.DbIpCityStatus(); +Console.WriteLine(result.ToJson()); ``` @@ -1306,21 +1513,29 @@ class DbIpCityStatus { ```csharp // Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbIpCity { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPGeolocationApi(config); - var result = api.DbIpCity(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPGeolocationApi(config); + +FileParameter download = api.DbIpCity(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbIpCity.zip"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1332,21 +1547,29 @@ class DbIpCity { ```csharp // Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbAsnWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesASNWHOISApi(config); - var result = api.DbAsnWhois(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesASNWHOISApi(config); + +FileParameter download = api.DbAsnWhois(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbAsnWhois.json.gz"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1356,21 +1579,22 @@ class DbAsnWhois { ```csharp // Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbAsnWhoisStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesASNWHOISApi(config); - var result = api.DbAsnWhoisStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesASNWHOISApi(config); + +SnapshotStatus result = api.DbAsnWhoisStatus(); +Console.WriteLine(result.ToJson()); ``` @@ -1382,21 +1606,29 @@ class DbAsnWhoisStatus { ```csharp // Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbIpWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPWHOISApi(config); - var result = api.DbIpWhois(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPWHOISApi(config); + +FileParameter download = api.DbIpWhois(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbIpWhois.json.gz"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1406,21 +1638,22 @@ class DbIpWhois { ```csharp // Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbIpWhoisStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPWHOISApi(config); - var result = api.DbIpWhoisStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPWHOISApi(config); + +SnapshotStatus result = api.DbIpWhoisStatus(); +Console.WriteLine(result.ToJson()); ``` @@ -1432,21 +1665,29 @@ class DbIpWhoisStatus { ```csharp // Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbIpSecurity { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPSecurityApi(config); - var result = api.DbIpSecurity(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPSecurityApi(config); + +FileParameter download = api.DbIpSecurity(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbIpSecurity.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1456,21 +1697,22 @@ class DbIpSecurity { ```csharp // Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbIpSecurityStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPSecurityApi(config); - var result = api.DbIpSecurityStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPSecurityApi(config); + +SnapshotStatus result = api.DbIpSecurityStatus(); +Console.WriteLine(result.ToJson()); ``` @@ -1482,21 +1724,29 @@ class DbIpSecurityStatus { ```csharp // Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedPhishing { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedPhishing(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedPhishing(date: "2026-10-01"); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedPhishing.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1506,21 +1756,29 @@ class DownloadThreatFeedPhishing { ```csharp // Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedPhishingSample { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedPhishingSample(); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedPhishingSample(); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedPhishingSample.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1530,21 +1788,29 @@ class DownloadThreatFeedPhishingSample { ```csharp // Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedMalware { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedMalware(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedMalware(date: "2026-10-01"); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedMalware.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1554,21 +1820,29 @@ class DownloadThreatFeedMalware { ```csharp // Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedMalwareSample { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedMalwareSample(); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedMalwareSample(); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedMalwareSample.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1578,21 +1852,29 @@ class DownloadThreatFeedMalwareSample { ```csharp // Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedSpam { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedSpam(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedSpam(date: "2026-10-01"); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedSpam.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` @@ -1602,20 +1884,28 @@ class DownloadThreatFeedSpam { ```csharp // Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedSpamSample { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedSpamSample(); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedSpamSample(); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedSpamSample.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); ``` diff --git a/docs/languages/go.md b/docs/languages/go.md index 52f21b6..0941b3b 100644 --- a/docs/languages/go.md +++ b/docs/languages/go.md @@ -2,7 +2,7 @@ ## About -The official **WhoisFreaks Go SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Go with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Go modules. +The official **WhoisFreaks Go SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Go with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Go modules. **Keywords:** go whois api, go whois sdk, whoisfreaks go, go domain lookup, go dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api @@ -17,7 +17,7 @@ go get github.com/WhoisFreaks/whoisfreaks-go ## Build from Source -Prefer to build the SDK yourself instead of installing from Go modules? Clone the monorepo and build the Go package locally: +Prefer to build the SDK yourself instead of installing from Go modules? Clone the Go SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-go @@ -29,74 +29,87 @@ go build ./... # or import the module path directly A complete walkthrough from an empty directory to a running program: +You need Go 1.18 or later. Create a module and add the SDK: + ```bash mkdir whoisfreaks-test && cd whoisfreaks-test -go mod init whoisfreaks-test # creates go.mod (required) -go get github.com/WhoisFreaks/whoisfreaks-go +go mod init whoisfreaks-test +go get github.com/WhoisFreaks/whoisfreaks-go@v0.23.0 ``` -> **Note:** `go get` only works inside a module. If you see *'go.mod file not found'*, run `go mod init ` first (as above). - Create `main.go`: ```go package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + record, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + fmt.Println(record.GetDomainName(), "expires", record.GetExpiryDate()) } ``` -Run it: +Set your API key, tidy the module and run it: ```bash +export WHOISFREAKS_API_KEY="your_api_key" go mod tidy -go run main.go +go run . ``` +To run one of the [runnable examples](../../examples/go/README.md), save it as `main.go` in this module and run `go run .` again. + ## Configure See [Authentication](../authentication.md) for how to obtain a key. Minimal setup: ```go // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -113,28 +126,35 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, ```go // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -145,28 +165,36 @@ func main() { ```go // Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.BulkWhois(ctx).BulkWhoisRequest(*wf.NewBulkWhoisRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkWhoisRequest([]string{"whoisfreaks.com", "jfreaks.com"}) + result, _, err := client.WHOISAPI.BulkWhois(ctx).BulkWhoisRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -177,29 +205,35 @@ func main() { ```go // Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisHistory(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisHistory(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -210,29 +244,36 @@ func main() { ```go // Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisReverse(ctx).Keyword("value").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisReverse(ctx).Keyword("whoisfreaks").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -245,30 +286,38 @@ func main() { ```go // Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsLive(ctx).DomainName("example.com").IpAddress("8.8.8.8").Type("value").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DNSAPI.DnsLive(ctx). + DomainName("whoisfreaks.com").Type_("A,MX,TXT").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -279,30 +328,38 @@ func main() { ```go // Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) // - page (integer, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsHistorical(ctx).DomainName("example.com").Type("value").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DNSAPI.DnsHistorical(ctx). + DomainName("whoisfreaks.com").Type_("A,MX,TXT").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -313,31 +370,38 @@ func main() { ```go // Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) // - exact (boolean, optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsReverse(ctx).Value("value").Type("a").Exact(true).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DNSAPI.DnsReverse(ctx).Value("8.8.8.8").Type_("a").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -348,29 +412,38 @@ func main() { ```go // Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsBulk(ctx).Type("value").DnsBulkRequest(*wf.NewDnsBulkRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewDnsBulkRequest() + body.SetDomainNames([]string{"whoisfreaks.com", "example.com"}) + result, _, err := client.DNSAPI.DnsBulk(ctx).Type_("A,MX,TXT").DnsBulkRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -383,30 +456,38 @@ func main() { ```go // Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. // - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DomainAvailabilityAPI.DomainAvailabilityV2(ctx).Domain("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DomainAvailabilityAPI.DomainAvailabilityV2(ctx). + Domain("google.com").Sug(true).Count(5).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -417,29 +498,39 @@ func main() { ```go // Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DomainAvailabilityAPI.BulkDomainAvailabilityV2(ctx).BulkDomainAvailabilityRequest(*wf.NewBulkDomainAvailabilityRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkDomainAvailabilityRequest() + body.SetDomainNames([]string{"whoisfreaks.com", "example.com"}) + result, _, err := client.DomainAvailabilityAPI.BulkDomainAvailabilityV2(ctx). + BulkDomainAvailabilityRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -452,29 +543,36 @@ func main() { ```go // Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) // - pageToken (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.TyposquattingAPI.Typosquatting(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.TyposquattingAPI.Typosquatting(ctx).Keyword("whoisfreaks").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -487,30 +585,37 @@ func main() { ```go // Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) // - sslRaw (boolean, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.SSLAPI.SslLookup(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.SSLAPI.SslLookup(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -523,27 +628,34 @@ func main() { ```go // Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.GeolocationAPI.Geolocation(ctx).Ip("8.8.8.8").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.GeolocationAPI.Geolocation(ctx).Ip("8.8.8.8").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -554,27 +666,36 @@ func main() { ```go // Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.GeolocationAPI.BulkGeolocation(ctx).BulkGeolocationRequest(*wf.NewBulkGeolocationRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkGeolocationRequest([]string{"8.8.8.8", "1.1.1.1"}) + result, _, err := client.GeolocationAPI.BulkGeolocation(ctx). + BulkGeolocationRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -587,6 +708,7 @@ func main() { ```go // Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -594,26 +716,31 @@ func main() { // - status (string (one of: active, inactive), optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.SubdomainsAPI.Subdomains(ctx).Domain("example.com").After("2000-01-01").Before(time.Now().Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.SubdomainsAPI.Subdomains(ctx).Domain("whoisfreaks.com").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -626,27 +753,34 @@ func main() { ```go // Runnable example: IP Reputation Lookup (GET /v1.0/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.IPReputationAPI.IpReputation(ctx).Ip("8.8.8.8").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.IPReputationAPI.IpReputation(ctx).Ip("8.8.8.8").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -657,27 +791,36 @@ func main() { ```go // Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.IPReputationAPI.BulkIpReputation(ctx).BulkIpReputationRequest(*wf.NewBulkIpReputationRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkGeolocationRequest([]string{"8.8.8.8", "1.1.1.1"}) + result, _, err := client.IPReputationAPI.BulkIpReputation(ctx). + BulkGeolocationRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -690,28 +833,36 @@ func main() { ```go // Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DomainReputationAPI.DomainReputation(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DomainReputationAPI.DomainReputation(ctx). + DomainName("amazon.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -724,28 +875,35 @@ func main() { ```go // Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.ASNWHOISAPI.AsnWhois(ctx).Asn("AS15169").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.ASNWHOISAPI.AsnWhois(ctx).Asn("as15169").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -758,28 +916,35 @@ func main() { ```go // Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.IPWHOISAPI.IpWhois(ctx).Ip("8.8.8.8").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.IPWHOISAPI.IpWhois(ctx).Ip("8.8.8.8").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -792,27 +957,33 @@ func main() { ```go // Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.AccountAPI.RotateApiKey(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + newKey, _, err := client.AccountAPI.RotateApiKey(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY. + fmt.Println("New API key:", newKey) } ``` @@ -823,27 +994,34 @@ func main() { ```go // Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.AccountAPI.AccountUsage(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.AccountAPI.AccountUsage(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -854,27 +1032,32 @@ func main() { ```go // Runnable example: Database File Status (Public) (GET /v3.4/status) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.AccountAPI.DatabaseFileStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Public endpoint: no API key needed. + ctx := context.Background() + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.AccountAPI.DatabaseFileStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -887,31 +1070,51 @@ func main() { ```go // Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtld(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyGtld.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyGtld.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtld(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyGtld.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -922,31 +1125,51 @@ func main() { ```go // Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctld(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyCctld.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyCctld.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctld(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyCctld.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -957,29 +1180,49 @@ func main() { ```go // Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldCleaned(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyGtldCleaned.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyGtldCleaned.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldCleaned(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyGtldCleaned.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -990,29 +1233,49 @@ func main() { ```go // Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldCleaned(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyCctldCleaned.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyCctldCleaned.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldCleaned(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyCctldCleaned.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1023,29 +1286,36 @@ func main() { ```go // Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldJson(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldJson(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -1056,29 +1326,36 @@ func main() { ```go // Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldJson(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldJson(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -1089,29 +1366,48 @@ func main() { ```go // Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyDns(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyDns.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyDns.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyDns(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyDns.json") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1124,30 +1420,50 @@ func main() { ```go // Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbExpired(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbExpired.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbExpired.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbExpired(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbExpired.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1158,29 +1474,49 @@ func main() { ```go // Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbExpiredCleaned(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbExpiredCleaned.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbExpiredCleaned.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbExpiredCleaned(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbExpiredCleaned.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1191,30 +1527,50 @@ func main() { ```go // Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbDropped(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDropped.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDropped.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbDropped(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDropped.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1225,29 +1581,36 @@ func main() { ```go // Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedJson(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedJson(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -1258,30 +1621,50 @@ func main() { ```go // Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedBacklinks(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDroppedBacklinks.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDroppedBacklinks.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedBacklinks(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDroppedBacklinks.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1294,29 +1677,48 @@ func main() { ```go // Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesWHOISAPI.DbWhoisDaily(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbWhoisDaily.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbWhoisDaily.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesWHOISAPI.DbWhoisDaily(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbWhoisDaily.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1327,29 +1729,48 @@ func main() { ```go // Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesWHOISAPI.DbWhoisWeekly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbWhoisWeekly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbWhoisWeekly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesWHOISAPI.DbWhoisWeekly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbWhoisWeekly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1360,29 +1781,48 @@ func main() { ```go // Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesWHOISAPI.DbWhoisMonthly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbWhoisMonthly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbWhoisMonthly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesWHOISAPI.DbWhoisMonthly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbWhoisMonthly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1395,29 +1835,48 @@ func main() { ```go // Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesDNSAPI.DbDnsDaily(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDnsDaily.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDnsDaily.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesDNSAPI.DbDnsDaily(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDnsDaily.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1428,29 +1887,48 @@ func main() { ```go // Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesDNSAPI.DbDnsWeekly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDnsWeekly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDnsWeekly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesDNSAPI.DbDnsWeekly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDnsWeekly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1461,29 +1939,48 @@ func main() { ```go // Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesDNSAPI.DbDnsMonthly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDnsMonthly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDnsMonthly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesDNSAPI.DbDnsMonthly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDnsMonthly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1496,29 +1993,49 @@ func main() { ```go // Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsDaily(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbSubdomainsDaily.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbSubdomainsDaily.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsDaily(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbSubdomainsDaily.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1529,29 +2046,49 @@ func main() { ```go // Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsWeekly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbSubdomainsWeekly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbSubdomainsWeekly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsWeekly(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbSubdomainsWeekly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1562,29 +2099,49 @@ func main() { ```go // Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsMonthly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbSubdomainsMonthly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbSubdomainsMonthly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsMonthly(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbSubdomainsMonthly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1597,27 +2154,34 @@ func main() { ```go // Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPGeolocationAPI.DbIpCountryStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPGeolocationAPI.DbIpCountryStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -1628,29 +2192,48 @@ func main() { ```go // Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPGeolocationAPI.DbIpCountry(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpCountry.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpCountry.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPGeolocationAPI.DbIpCountry(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpCountry.zip") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1661,27 +2244,34 @@ func main() { ```go // Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPGeolocationAPI.DbIpCityStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPGeolocationAPI.DbIpCityStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -1692,29 +2282,48 @@ func main() { ```go // Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPGeolocationAPI.DbIpCity(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpCity.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpCity.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPGeolocationAPI.DbIpCity(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpCity.zip") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1727,29 +2336,48 @@ func main() { ```go // Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesASNWHOISAPI.DbAsnWhois(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbAsnWhois.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbAsnWhois.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesASNWHOISAPI.DbAsnWhois(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbAsnWhois.json.gz") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1760,27 +2388,34 @@ func main() { ```go // Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesASNWHOISAPI.DbAsnWhoisStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesASNWHOISAPI.DbAsnWhoisStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -1793,29 +2428,48 @@ func main() { ```go // Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPWHOISAPI.DbIpWhois(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpWhois.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpWhois.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPWHOISAPI.DbIpWhois(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpWhois.json.gz") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1826,27 +2480,34 @@ func main() { ```go // Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPWHOISAPI.DbIpWhoisStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPWHOISAPI.DbIpWhoisStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -1859,29 +2520,48 @@ func main() { ```go // Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPSecurityAPI.DbIpSecurity(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpSecurity.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpSecurity.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPSecurityAPI.DbIpSecurity(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpSecurity.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1892,27 +2572,34 @@ func main() { ```go // Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPSecurityAPI.DbIpSecurityStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPSecurityAPI.DbIpSecurityStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } ``` @@ -1925,29 +2612,49 @@ func main() { ```go // Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishing(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedPhishing.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedPhishing.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishing(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedPhishing.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1958,28 +2665,48 @@ func main() { ```go // Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) + package main import ( - "context" - "fmt" - "os" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishingSample(ctx).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedPhishingSample.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedPhishingSample.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishingSample(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedPhishingSample.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -1990,29 +2717,49 @@ func main() { ```go // Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalware(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedMalware.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedMalware.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalware(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedMalware.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -2023,28 +2770,48 @@ func main() { ```go // Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) + package main import ( - "context" - "fmt" - "os" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalwareSample(ctx).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedMalwareSample.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedMalwareSample.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalwareSample(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedMalwareSample.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -2055,29 +2822,49 @@ func main() { ```go // Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpam(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedSpam.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedSpam.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpam(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedSpam.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` @@ -2088,28 +2875,48 @@ func main() { ```go // Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) + package main import ( - "context" - "fmt" - "os" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpamSample(ctx).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedSpamSample.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedSpamSample.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpamSample(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedSpamSample.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } ``` diff --git a/docs/languages/java.md b/docs/languages/java.md index 75584f0..af3aef0 100644 --- a/docs/languages/java.md +++ b/docs/languages/java.md @@ -2,7 +2,7 @@ ## About -The official **WhoisFreaks Java SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Java with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Maven Central. +The official **WhoisFreaks Java SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Java with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Maven Central. **Keywords:** java whois api, java whois sdk, whoisfreaks java, java domain lookup, java dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api @@ -15,13 +15,13 @@ The official **WhoisFreaks Java SDK** — a complete client for WHOIS, DNS, SSL, com.whoisfreaks whoisfreaks - LATEST + 0.23.0 ``` ## Build from Source -Prefer to build the SDK yourself instead of installing from Maven Central? Clone the monorepo and build the Java package locally: +Prefer to build the SDK yourself instead of installing from Maven Central? Clone the Java SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-java @@ -33,37 +33,83 @@ mvn clean install # builds + installs to local ~/.m2 A complete walkthrough from an empty directory to a running program: -Create a Maven project and add the dependency to `pom.xml`: +You need JDK 8 or later and Maven. Create the project directory: -```xml - - com.whoisfreaks - whoisfreaks - LATEST - +```bash +mkdir -p whoisfreaks-test/src/main/java && cd whoisfreaks-test ``` -`src/main/java/Main.java`: +Create `pom.xml`. The `exec.mainClass` property picks the class that `mvn exec:java` runs: + +```xml + + + 4.0.0 + com.example + whoisfreaks-test + 1.0-SNAPSHOT + + + 1.8 + 1.8 + UTF-8 + Main + + + + + com.whoisfreaks + whoisfreaks + 0.23.0 + + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.5.0 + + + + +``` + +Create `src/main/java/Main.java`: ```java import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.WhoisResponse; public class Main { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once - WhoisApi api = new WhoisApi(client); - var result = api.whoisLive("example.com"); - System.out.println(result); + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call + + WhoisApi whois = new WhoisApi(client); + // whoisLive(domainName, format); null format returns JSON + WhoisResponse record = whois.whoisLive("whoisfreaks.com", null); + System.out.println(record.getDomainName() + " expires " + record.getExpiryDate()); + System.out.println(record); } } ``` -Build and run with `mvn compile exec:java -Dexec.mainClass=Main` (or your IDE). +Set your API key and run it: + +```bash +export WHOISFREAKS_API_KEY="your_api_key" +mvn -q compile exec:java +``` + +To run one of the [runnable examples](../../examples/java/README.md), copy it into `src/main/java` and pass its class name, for example `mvn -q compile exec:java -Dexec.mainClass=WhoisLive`. ## Configure @@ -71,21 +117,25 @@ See [Authentication](../authentication.md) for how to obtain a key. Minimal setu ```java // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=WhoisLive // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.WhoisResponse; public class WhoisLive { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.whoisLive("example.com", null); + + // whoisLive(domainName, format); null leaves an optional parameter unset + WhoisResponse result = api.whoisLive("whoisfreaks.com", null); System.out.println(result); } } @@ -104,21 +154,25 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, ```java // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=WhoisLive // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.WhoisResponse; public class WhoisLive { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.whoisLive("example.com", null); + + // whoisLive(domainName, format); null leaves an optional parameter unset + WhoisResponse result = api.whoisLive("whoisfreaks.com", null); System.out.println(result); } } @@ -131,22 +185,30 @@ public class WhoisLive { ```java // Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=BulkWhois // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.model.BulkWhoisRequest; +import com.whoisfreaks.client.model.BulkWhoisResponse; + +import java.util.Arrays; public class BulkWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.bulkWhois(new BulkWhoisRequest(), null); + + BulkWhoisRequest body = new BulkWhoisRequest() + .domainNames(Arrays.asList("whoisfreaks.com", "jfreaks.com")); + // bulkWhois(bulkWhoisRequest, format); null leaves an optional parameter unset + BulkWhoisResponse result = api.bulkWhois(body, null); System.out.println(result); } } @@ -159,22 +221,25 @@ public class BulkWhois { ```java // Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=WhoisHistory // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.WhoisHistoricalResponse; public class WhoisHistory { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.whoisHistory("example.com", null, null); + + // whoisHistory(domainName, format); null leaves an optional parameter unset + WhoisHistoricalResponse result = api.whoisHistory("whoisfreaks.com", null); System.out.println(result); } } @@ -187,22 +252,26 @@ public class WhoisHistory { ```java // Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=WhoisReverse // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.ReverseWhoisResponse; public class WhoisReverse { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.whoisReverse("value", null, null); + + // whoisReverse(keyword, page, format); null leaves an optional parameter unset + ReverseWhoisResponse result = api.whoisReverse("whoisfreaks", 1, null); System.out.println(result); } } @@ -217,23 +286,27 @@ public class WhoisReverse { ```java // Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DnsLive // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.DnsResponse; public class DnsLive { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DnsApi api = new DnsApi(client); - var result = api.dnsLive("example.com", "8.8.8.8", "value", null); + + // dnsLive(type, domainName, ipAddress, format); null leaves an optional parameter unset + DnsResponse result = api.dnsLive("A,MX,TXT", "whoisfreaks.com", null, null); System.out.println(result); } } @@ -246,6 +319,7 @@ public class DnsLive { ```java // Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DnsHistorical // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) @@ -253,16 +327,19 @@ public class DnsLive { // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.HistoricalDnsResponse; public class DnsHistorical { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DnsApi api = new DnsApi(client); - var result = api.dnsHistorical("example.com", "value", null, null); + + // dnsHistorical(domainName, type, page, format); null leaves an optional parameter unset + HistoricalDnsResponse result = api.dnsHistorical("whoisfreaks.com", "A,MX,TXT", 1, null); System.out.println(result); } } @@ -275,6 +352,7 @@ public class DnsHistorical { ```java // Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DnsReverse // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) @@ -283,16 +361,19 @@ public class DnsHistorical { // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.ReverseDnsResponse; public class DnsReverse { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DnsApi api = new DnsApi(client); - var result = api.dnsReverse("value", "a", true, null, null); + + // dnsReverse(value, type, exact, page, format); null leaves an optional parameter unset + ReverseDnsResponse result = api.dnsReverse("8.8.8.8", "a", null, 1, null); System.out.println(result); } } @@ -305,23 +386,31 @@ public class DnsReverse { ```java // Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DnsBulk // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.BulkDnsResponse; import com.whoisfreaks.client.model.DnsBulkRequest; +import java.util.Arrays; + public class DnsBulk { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DnsApi api = new DnsApi(client); - var result = api.dnsBulk("value", new DnsBulkRequest(), null); + + DnsBulkRequest body = new DnsBulkRequest() + .domainNames(Arrays.asList("whoisfreaks.com", "example.com")); + // dnsBulk(type, dnsBulkRequest, format); null leaves an optional parameter unset + BulkDnsResponse result = api.dnsBulk("A,MX,TXT", body, null); System.out.println(result); } } @@ -336,6 +425,7 @@ public class DnsBulk { ```java // Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DomainAvailabilityV2 // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. @@ -343,16 +433,19 @@ public class DnsBulk { // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DomainAvailabilityApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.DomainAvailabilityResponse; public class DomainAvailabilityV2 { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DomainAvailabilityApi api = new DomainAvailabilityApi(client); - var result = api.domainAvailabilityV2("example.com", null, null, null); + + // domainAvailabilityV2(domain, sug, count, format); null leaves an optional parameter unset + DomainAvailabilityResponse result = api.domainAvailabilityV2("google.com", true, 5, null); System.out.println(result); } } @@ -365,23 +458,31 @@ public class DomainAvailabilityV2 { ```java // Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=BulkDomainAvailabilityV2 // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DomainAvailabilityApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.model.BulkDomainAvailabilityRequest; +import com.whoisfreaks.client.model.BulkDomainAvailabilityResponse; + +import java.util.Arrays; public class BulkDomainAvailabilityV2 { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DomainAvailabilityApi api = new DomainAvailabilityApi(client); - var result = api.bulkDomainAvailabilityV2(new BulkDomainAvailabilityRequest(), null, null); + + BulkDomainAvailabilityRequest body = new BulkDomainAvailabilityRequest() + .domainNames(Arrays.asList("whoisfreaks.com", "example.com")); + // bulkDomainAvailabilityV2(bulkDomainAvailabilityRequest, domain, format); null leaves an optional parameter unset + BulkDomainAvailabilityResponse result = api.bulkDomainAvailabilityV2(body, null, null); System.out.println(result); } } @@ -396,22 +497,26 @@ public class BulkDomainAvailabilityV2 { ```java // Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=Typosquatting // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) // - pageToken (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.TyposquattingApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.TyposquattingResponse; public class Typosquatting { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call TyposquattingApi api = new TyposquattingApi(client); - var result = api.typosquatting(null, null, null); + + // typosquatting(keyword, pattern, pageToken); null leaves an optional parameter unset + TyposquattingResponse result = api.typosquatting("whoisfreaks", null, null); System.out.println(result); } } @@ -426,6 +531,7 @@ public class Typosquatting { ```java // Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=SslLookup // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) @@ -433,16 +539,19 @@ public class Typosquatting { // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.SslApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SslResponse; public class SslLookup { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call SslApi api = new SslApi(client); - var result = api.sslLookup("example.com", null, null, null); + + // sslLookup(domainName, chain, sslRaw, format); null leaves an optional parameter unset + SslResponse result = api.sslLookup("whoisfreaks.com", null, null, null); System.out.println(result); } } @@ -457,20 +566,23 @@ public class SslLookup { ```java // Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=Geolocation // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.GeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.GeolocationResponse; public class Geolocation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call GeolocationApi api = new GeolocationApi(client); - var result = api.geolocation("8.8.8.8"); + + GeolocationResponse result = api.geolocation("8.8.8.8"); System.out.println(result); } } @@ -483,21 +595,29 @@ public class Geolocation { ```java // Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=BulkGeolocation // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.GeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.model.BulkGeolocationRequest; +import com.whoisfreaks.client.model.GeolocationResponse; + +import java.util.Arrays; +import java.util.List; public class BulkGeolocation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call GeolocationApi api = new GeolocationApi(client); - var result = api.bulkGeolocation(new BulkGeolocationRequest()); + + BulkGeolocationRequest body = new BulkGeolocationRequest() + .ips(Arrays.asList("8.8.8.8", "1.1.1.1")); + List result = api.bulkGeolocation(body); System.out.println(result); } } @@ -512,6 +632,7 @@ public class BulkGeolocation { ```java // Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=Subdomains // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -521,16 +642,19 @@ public class BulkGeolocation { // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.SubdomainsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SubdomainsResponse; public class Subdomains { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call SubdomainsApi api = new SubdomainsApi(client); - var result = api.subdomains("example.com", "2000-01-01", java.time.LocalDate.now().toString(), null, null, null); + + // subdomains(domain, after, before, status, page, format); null leaves an optional parameter unset + SubdomainsResponse result = api.subdomains("whoisfreaks.com", null, null, null, 1, null); System.out.println(result); } } @@ -545,20 +669,23 @@ public class Subdomains { ```java // Runnable example: IP Reputation Lookup (GET /v1.0/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=IpReputation // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.IpReputationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.IpReputationResponse; public class IpReputation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call IpReputationApi api = new IpReputationApi(client); - var result = api.ipReputation("8.8.8.8"); + + IpReputationResponse result = api.ipReputation("8.8.8.8"); System.out.println(result); } } @@ -571,21 +698,29 @@ public class IpReputation { ```java // Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=BulkIpReputation // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.IpReputationApi; -import com.whoisfreaks.client.model.BulkIpReputationRequest; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.BulkGeolocationRequest; +import com.whoisfreaks.client.model.IpReputationResponse; + +import java.util.Arrays; +import java.util.List; public class BulkIpReputation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call IpReputationApi api = new IpReputationApi(client); - var result = api.bulkIpReputation(new BulkIpReputationRequest()); + + BulkGeolocationRequest body = new BulkGeolocationRequest() + .ips(Arrays.asList("8.8.8.8", "1.1.1.1")); + List result = api.bulkIpReputation(body); System.out.println(result); } } @@ -600,21 +735,25 @@ public class BulkIpReputation { ```java // Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DomainReputation // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DomainReputationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.DomainReputationResponse; public class DomainReputation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DomainReputationApi api = new DomainReputationApi(client); - var result = api.domainReputation("example.com", null); + + // domainReputation(domainName, format); null leaves an optional parameter unset + DomainReputationResponse result = api.domainReputation("amazon.com", null); System.out.println(result); } } @@ -629,21 +768,25 @@ public class DomainReputation { ```java // Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=AsnWhois // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.AsnWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.AsnWhoisResponse; public class AsnWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call AsnWhoisApi api = new AsnWhoisApi(client); - var result = api.asnWhois("AS15169", null); + + // asnWhois(asn, format); null leaves an optional parameter unset + AsnWhoisResponse result = api.asnWhois("as15169", null); System.out.println(result); } } @@ -658,21 +801,25 @@ public class AsnWhois { ```java // Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=IpWhois // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.IpWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.IpWhoisResponse; public class IpWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call IpWhoisApi api = new IpWhoisApi(client); - var result = api.ipWhois("8.8.8.8", null); + + // ipWhois(ip, format); null leaves an optional parameter unset + IpWhoisResponse result = api.ipWhois("8.8.8.8", null); System.out.println(result); } } @@ -687,21 +834,24 @@ public class IpWhois { ```java // Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=RotateApiKey // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.AccountApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; public class RotateApiKey { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call AccountApi api = new AccountApi(client); - var result = api.rotateApiKey(); - System.out.println(result); + + String newKey = api.rotateApiKey(); + // The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY. + System.out.println("New API key: " + newKey); } } @@ -713,20 +863,23 @@ public class RotateApiKey { ```java // Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=AccountUsage // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.AccountApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.AccountUsageResponse; public class AccountUsage { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call AccountApi api = new AccountApi(client); - var result = api.accountUsage(); + + AccountUsageResponse result = api.accountUsage(); System.out.println(result); } } @@ -739,20 +892,20 @@ public class AccountUsage { ```java // Runnable example: Database File Status (Public) (GET /v3.4/status) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DatabaseFileStatus // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.AccountApi; public class DatabaseFileStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + // Public endpoint: no API key needed. AccountApi api = new AccountApi(client); - var result = api.databaseFileStatus(); + + com.whoisfreaks.client.model.DatabaseFileStatus result = api.databaseFileStatus(); System.out.println(result); } } @@ -767,23 +920,36 @@ public class DatabaseFileStatus { ```java // Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyGtld // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyGtld { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyGtld(false, java.time.LocalDate.now().minusDays(1).toString(), null); - System.out.println(result); + + // dbNewlyGtld(whois, date, tlds); null leaves an optional parameter unset + File download = api.dbNewlyGtld(true, LocalDate.of(2026, 10, 1), null); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyGtld.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -795,23 +961,36 @@ public class DbNewlyGtld { ```java // Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyCctld // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyCctld { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyCctld(false, java.time.LocalDate.now().minusDays(1).toString(), null); - System.out.println(result); + + // dbNewlyCctld(whois, date, tlds); null leaves an optional parameter unset + File download = api.dbNewlyCctld(true, LocalDate.of(2026, 10, 1), null); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyCctld.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -823,21 +1002,33 @@ public class DbNewlyCctld { ```java // Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyGtldCleaned // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyGtldCleaned { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyGtldCleaned(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbNewlyGtldCleaned(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyGtldCleaned.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -849,21 +1040,33 @@ public class DbNewlyGtldCleaned { ```java // Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyCctldCleaned // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyCctldCleaned { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyCctldCleaned(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbNewlyCctldCleaned(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyCctldCleaned.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -875,21 +1078,27 @@ public class DbNewlyCctldCleaned { ```java // Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyGtldJson // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.time.LocalDate; +import java.util.List; public class DbNewlyGtldJson { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyGtldJson(java.time.LocalDate.now().minusDays(1).toString(), null); + + // dbNewlyGtldJson(date, tlds); null leaves an optional parameter unset + List result = api.dbNewlyGtldJson(LocalDate.of(2026, 10, 1), null); System.out.println(result); } } @@ -902,21 +1111,27 @@ public class DbNewlyGtldJson { ```java // Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyCctldJson // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.time.LocalDate; +import java.util.List; public class DbNewlyCctldJson { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyCctldJson(java.time.LocalDate.now().minusDays(1).toString(), null); + + // dbNewlyCctldJson(date, tlds); null leaves an optional parameter unset + List result = api.dbNewlyCctldJson(LocalDate.of(2026, 10, 1), null); System.out.println(result); } } @@ -929,21 +1144,33 @@ public class DbNewlyCctldJson { ```java // Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyDns // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyDns { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyDns(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbNewlyDns(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyDns.json"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -957,22 +1184,34 @@ public class DbNewlyDns { ```java // Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbExpired // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbExpired { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbExpired(false, java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbExpired(true, LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbExpired.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -984,21 +1223,33 @@ public class DbExpired { ```java // Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbExpiredCleaned // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbExpiredCleaned { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbExpiredCleaned(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbExpiredCleaned(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbExpiredCleaned.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1010,22 +1261,34 @@ public class DbExpiredCleaned { ```java // Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDropped // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDropped { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbDropped(false, java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbDropped(true, LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDropped.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1037,21 +1300,27 @@ public class DbDropped { ```java // Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDroppedJson // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.time.LocalDate; +import java.util.List; public class DbDroppedJson { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbDroppedJson(java.time.LocalDate.now().minusDays(1).toString(), null); + + // dbDroppedJson(date, tlds); null leaves an optional parameter unset + List result = api.dbDroppedJson(LocalDate.of(2026, 10, 1), null); System.out.println(result); } } @@ -1064,22 +1333,35 @@ public class DbDroppedJson { ```java // Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDroppedBacklinks // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDroppedBacklinks { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbDroppedBacklinks(false, java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + // dbDroppedBacklinks(whois, date); null leaves an optional parameter unset + File download = api.dbDroppedBacklinks(null, LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDroppedBacklinks.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1093,21 +1375,33 @@ public class DbDroppedBacklinks { ```java // Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbWhoisDaily // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbWhoisDaily { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesWhoisApi api = new DatabasesWhoisApi(client); - var result = api.dbWhoisDaily(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbWhoisDaily(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbWhoisDaily.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1119,21 +1413,33 @@ public class DbWhoisDaily { ```java // Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbWhoisWeekly // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbWhoisWeekly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesWhoisApi api = new DatabasesWhoisApi(client); - var result = api.dbWhoisWeekly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbWhoisWeekly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbWhoisWeekly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1145,21 +1451,33 @@ public class DbWhoisWeekly { ```java // Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbWhoisMonthly // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbWhoisMonthly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesWhoisApi api = new DatabasesWhoisApi(client); - var result = api.dbWhoisMonthly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbWhoisMonthly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbWhoisMonthly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1173,21 +1491,33 @@ public class DbWhoisMonthly { ```java // Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDnsDaily // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesDnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDnsDaily { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesDnsApi api = new DatabasesDnsApi(client); - var result = api.dbDnsDaily(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbDnsDaily(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDnsDaily.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1199,21 +1529,33 @@ public class DbDnsDaily { ```java // Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDnsWeekly // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesDnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDnsWeekly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesDnsApi api = new DatabasesDnsApi(client); - var result = api.dbDnsWeekly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbDnsWeekly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDnsWeekly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1225,21 +1567,33 @@ public class DbDnsWeekly { ```java // Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDnsMonthly // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesDnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDnsMonthly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesDnsApi api = new DatabasesDnsApi(client); - var result = api.dbDnsMonthly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbDnsMonthly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDnsMonthly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1253,21 +1607,33 @@ public class DbDnsMonthly { ```java // Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbSubdomainsDaily // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesSubdomainsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbSubdomainsDaily { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesSubdomainsApi api = new DatabasesSubdomainsApi(client); - var result = api.dbSubdomainsDaily(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbSubdomainsDaily(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbSubdomainsDaily.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1279,21 +1645,33 @@ public class DbSubdomainsDaily { ```java // Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbSubdomainsWeekly // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesSubdomainsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbSubdomainsWeekly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesSubdomainsApi api = new DatabasesSubdomainsApi(client); - var result = api.dbSubdomainsWeekly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbSubdomainsWeekly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbSubdomainsWeekly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1305,21 +1683,33 @@ public class DbSubdomainsWeekly { ```java // Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbSubdomainsMonthly // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesSubdomainsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbSubdomainsMonthly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesSubdomainsApi api = new DatabasesSubdomainsApi(client); - var result = api.dbSubdomainsMonthly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbSubdomainsMonthly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbSubdomainsMonthly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1333,20 +1723,23 @@ public class DbSubdomainsMonthly { ```java // Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpCountryStatus // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpGeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbIpCountryStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpGeolocationApi api = new DatabasesIpGeolocationApi(client); - var result = api.dbIpCountryStatus(); + + SnapshotStatus result = api.dbIpCountryStatus(); System.out.println(result); } } @@ -1359,21 +1752,33 @@ public class DbIpCountryStatus { ```java // Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpCountry // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpGeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbIpCountry { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpGeolocationApi api = new DatabasesIpGeolocationApi(client); - var result = api.dbIpCountry(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbIpCountry(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbIpCountry.zip"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1385,20 +1790,23 @@ public class DbIpCountry { ```java // Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpCityStatus // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpGeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbIpCityStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpGeolocationApi api = new DatabasesIpGeolocationApi(client); - var result = api.dbIpCityStatus(); + + SnapshotStatus result = api.dbIpCityStatus(); System.out.println(result); } } @@ -1411,21 +1819,33 @@ public class DbIpCityStatus { ```java // Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpCity // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpGeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbIpCity { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpGeolocationApi api = new DatabasesIpGeolocationApi(client); - var result = api.dbIpCity(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbIpCity(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbIpCity.zip"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1439,21 +1859,33 @@ public class DbIpCity { ```java // Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbAsnWhois // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesAsnWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbAsnWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesAsnWhoisApi api = new DatabasesAsnWhoisApi(client); - var result = api.dbAsnWhois(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbAsnWhois(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbAsnWhois.json.gz"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1465,20 +1897,23 @@ public class DbAsnWhois { ```java // Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbAsnWhoisStatus // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesAsnWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbAsnWhoisStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesAsnWhoisApi api = new DatabasesAsnWhoisApi(client); - var result = api.dbAsnWhoisStatus(); + + SnapshotStatus result = api.dbAsnWhoisStatus(); System.out.println(result); } } @@ -1493,21 +1928,33 @@ public class DbAsnWhoisStatus { ```java // Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpWhois // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbIpWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpWhoisApi api = new DatabasesIpWhoisApi(client); - var result = api.dbIpWhois(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbIpWhois(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbIpWhois.json.gz"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1519,20 +1966,23 @@ public class DbIpWhois { ```java // Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpWhoisStatus // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbIpWhoisStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpWhoisApi api = new DatabasesIpWhoisApi(client); - var result = api.dbIpWhoisStatus(); + + SnapshotStatus result = api.dbIpWhoisStatus(); System.out.println(result); } } @@ -1547,21 +1997,33 @@ public class DbIpWhoisStatus { ```java // Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpSecurity // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpSecurityApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbIpSecurity { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpSecurityApi api = new DatabasesIpSecurityApi(client); - var result = api.dbIpSecurity(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbIpSecurity(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbIpSecurity.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1573,20 +2035,23 @@ public class DbIpSecurity { ```java // Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpSecurityStatus // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpSecurityApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbIpSecurityStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpSecurityApi api = new DatabasesIpSecurityApi(client); - var result = api.dbIpSecurityStatus(); + + SnapshotStatus result = api.dbIpSecurityStatus(); System.out.println(result); } } @@ -1601,21 +2066,32 @@ public class DbIpSecurityStatus { ```java // Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedPhishing // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedPhishing { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedPhishing(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.downloadThreatFeedPhishing("2026-10-01"); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedPhishing.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1627,21 +2103,32 @@ public class DownloadThreatFeedPhishing { ```java // Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedPhishingSample // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedPhishingSample { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedPhishingSample(); - System.out.println(result); + + File download = api.downloadThreatFeedPhishingSample(); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedPhishingSample.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1653,21 +2140,32 @@ public class DownloadThreatFeedPhishingSample { ```java // Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedMalware // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedMalware { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedMalware(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.downloadThreatFeedMalware("2026-10-01"); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedMalware.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1679,21 +2177,32 @@ public class DownloadThreatFeedMalware { ```java // Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedMalwareSample // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedMalwareSample { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedMalwareSample(); - System.out.println(result); + + File download = api.downloadThreatFeedMalwareSample(); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedMalwareSample.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1705,21 +2214,32 @@ public class DownloadThreatFeedMalwareSample { ```java // Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedSpam // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedSpam { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedSpam(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.downloadThreatFeedSpam("2026-10-01"); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedSpam.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } @@ -1731,21 +2251,32 @@ public class DownloadThreatFeedSpam { ```java // Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedSpamSample // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedSpamSample { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedSpamSample(); - System.out.println(result); + + File download = api.downloadThreatFeedSpamSample(); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedSpamSample.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/docs/languages/javascript.md b/docs/languages/javascript.md index 6f18c09..67d98fc 100644 --- a/docs/languages/javascript.md +++ b/docs/languages/javascript.md @@ -2,7 +2,7 @@ ## About -The official **WhoisFreaks JavaScript SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from JavaScript with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to npm. +The official **WhoisFreaks JavaScript SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from JavaScript with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to npm. **Keywords:** javascript whois api, javascript whois sdk, whoisfreaks javascript, javascript domain lookup, javascript dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api @@ -17,7 +17,7 @@ npm install whoisfreaks-js ## Build from Source -Prefer to build the SDK yourself instead of installing from npm? Clone the monorepo and build the JavaScript package locally: +Prefer to build the SDK yourself instead of installing from npm? Clone the JavaScript SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-javascript @@ -30,31 +30,41 @@ npm run build A complete walkthrough from an empty directory to a running program: +1. Create a project and install the SDK (Node.js 18 or later): + ```bash mkdir whoisfreaks-test && cd whoisfreaks-test npm init -y npm install whoisfreaks-js ``` -Create `main.js`: +2. Create `main.js`: -```js -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +```javascript +const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.whoisLive("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +async function main() { + const record = await api.whoisLive("whoisfreaks.com"); + console.log("Domain: ", record.domain_name); + console.log("Created:", record.create_date); + console.log("Expires:", record.expiry_date); +} + +main().catch((err) => { + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` -Run it: +3. Set your API key and run it: ```bash +export WHOISFREAKS_API_KEY="your_api_key" # PowerShell: $env:WHOISFREAKS_API_KEY="your_api_key" node main.js ``` @@ -63,23 +73,28 @@ node main.js See [Authentication](../authentication.md) for how to obtain a key. Minimal setup: ```javascript -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) -// Parameters for whoisLive (GET /v2.0/whois/live): -// - domainName (string, required) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live +// Run: WHOISFREAKS_API_KEY=your_api_key node WhoisLive.js +const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.whoisLive("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// whoisLive(domainName, opts) +// domainName (string, required) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.whoisLive("whoisfreaks.com"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ## Endpoints @@ -93,23 +108,28 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, `GET /v2.0/whois/live` ```javascript -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) -// Parameters for whoisLive (GET /v2.0/whois/live): -// - domainName (string, required) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live +// Run: WHOISFREAKS_API_KEY=your_api_key node WhoisLive.js +const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.whoisLive("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// whoisLive(domainName, opts) +// domainName (string, required) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.whoisLive("whoisfreaks.com"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Bulk WHOIS Lookup @@ -117,23 +137,29 @@ api.whoisLive("example.com") `POST /v2.0/bulkwhois/live` ```javascript -// Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) -// Parameters for bulkWhois (POST /v2.0/bulkwhois/live): -// - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Bulk WHOIS Lookup: POST https://api.whoisfreaks.com/v2.0/bulkwhois/live +// Run: WHOISFREAKS_API_KEY=your_api_key node BulkWhois.js +const { ApiClient, WHOISApi, BulkWhoisRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.bulkWhois({}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// bulkWhois(bulkWhoisRequest, opts) +// bulkWhoisRequest (BulkWhoisRequest, required): request body +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const body = BulkWhoisRequest.constructFromObject({ domainNames: ["whoisfreaks.com", "jfreaks.com"] }); + const result = await api.bulkWhois(body); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Historical WHOIS records for a domain @@ -141,24 +167,28 @@ api.bulkWhois({}) `GET /v2.0/whois/history` ```javascript -// Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) -// Parameters for whoisHistory (GET /v2.0/whois/history): -// - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Historical WHOIS records for a domain: GET https://api.whoisfreaks.com/v2.0/whois/history +// Run: WHOISFREAKS_API_KEY=your_api_key node WhoisHistory.js +const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.whoisHistory("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// whoisHistory(domainName, opts) +// domainName (string, required): Domain to fetch historical WHOIS records for +// opts.format (string, optional): one of json, xml +async function main() { + const result = await api.whoisHistory("whoisfreaks.com"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Reverse WHOIS lookup by keyword @@ -166,24 +196,29 @@ api.whoisHistory("example.com") `GET /v2.0/whois/reverse` ```javascript -// Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) -// Parameters for whoisReverse (GET /v2.0/whois/reverse): -// - keyword (string, required): Keyword to search across WHOIS records -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Reverse WHOIS lookup by keyword: GET https://api.whoisfreaks.com/v2.0/whois/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key node WhoisReverse.js +const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.whoisReverse("value") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// whoisReverse(keyword, opts) +// keyword (string, required): Keyword to search across WHOIS records +// opts.page (number, optional): Page number +// opts.format (string, optional): one of json, xml +async function main() { + const result = await api.whoisReverse("whoisfreaks", { page: 1 }); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### DNS @@ -193,25 +228,30 @@ api.whoisReverse("value") `GET /v2.0/dns/live` ```javascript -// Runnable example: Live DNS Lookup (GET /v2.0/dns/live) -// Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups -// - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DNSApi } = pkg; -// or: const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Live DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/live +// Run: WHOISFREAKS_API_KEY=your_api_key node DnsLive.js +const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DNSApi(client); -api.dnsLive("example.com", "8.8.8.8", "value") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dnsLive(type, opts) +// type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME; default "all" +// opts.domainName (string, optional) +// opts.ipAddress (string, optional): Use for PTR lookups +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.dnsLive("A,MX,TXT", { domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Historical DNS Lookup @@ -219,25 +259,30 @@ api.dnsLive("example.com", "8.8.8.8", "value") `GET /v2.0/dns/historical` ```javascript -// Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) -// Parameters for dnsHistorical (GET /v2.0/dns/historical): -// - domainName (string, required) -// - type (string, required) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DNSApi } = pkg; -// or: const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Historical DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/historical +// Run: WHOISFREAKS_API_KEY=your_api_key node DnsHistorical.js +const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DNSApi(client); -api.dnsHistorical("example.com", "value") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dnsHistorical(domainName, type, opts) +// domainName (string, required) +// type (string, required): default "all" +// opts.page (number, optional): default 1 +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.dnsHistorical("whoisfreaks.com", "A,MX,TXT", { page: 1 }); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Reverse DNS Lookup @@ -245,26 +290,31 @@ api.dnsHistorical("example.com", "value") `GET /v2.1/dns/reverse` ```javascript -// Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) -// Parameters for dnsReverse (GET /v2.1/dns/reverse): -// - value (string, required): IP, CIDR, or record value -// - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DNSApi } = pkg; -// or: const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Reverse DNS Lookup: GET https://api.whoisfreaks.com/v2.1/dns/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key node DnsReverse.js +const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DNSApi(client); -api.dnsReverse("value", "a", true) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dnsReverse(value, type, opts) +// value (string, required): IP, CIDR, or record value +// type (string, required): one of a, mx, cname, ns, aaaa, txt, soa +// opts.exact (boolean, optional): default true +// opts.page (number, optional): default 1 +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.dnsReverse("8.8.8.8", "a", { page: 1 }); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Bulk DNS Lookup @@ -272,24 +322,30 @@ api.dnsReverse("value", "a", true) `POST /v2.0/dns/bulk/live` ```javascript -// Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) -// Parameters for dnsBulk (POST /v2.0/dns/bulk/live): -// - type (string, required) -// - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DNSApi } = pkg; -// or: const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Bulk DNS Lookup: POST https://api.whoisfreaks.com/v2.0/dns/bulk/live +// Run: WHOISFREAKS_API_KEY=your_api_key node DnsBulk.js +const { ApiClient, DNSApi, DnsBulkRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DNSApi(client); -api.dnsBulk("value", {}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dnsBulk(type, dnsBulkRequest, opts) +// type (string, required): default "all" +// dnsBulkRequest (DnsBulkRequest, required): request body +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const body = DnsBulkRequest.constructFromObject({ domainNames: ["whoisfreaks.com", "example.com"] }); + const result = await api.dnsBulk("A,MX,TXT", body); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Domain Availability @@ -299,25 +355,30 @@ api.dnsBulk("value", {}) `GET /v2.0/domain/availability` ```javascript -// Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) -// Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): -// - domain (string, required): The domain name to check -// - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. -// - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DomainAvailabilityApi } = pkg; -// or: const { ApiClient, DomainAvailabilityApi } = require("whoisfreaks-js"); +// Domain Availability Check with Suggestions: GET https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key node DomainAvailabilityV2.js +const { ApiClient, DomainAvailabilityApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DomainAvailabilityApi(client); -api.domainAvailabilityV2("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// domainAvailabilityV2(domain, opts) +// domain (string, required): The domain name to check +// opts.sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain; default false +// opts.count (number, optional): Number of TLD suggestions to return when sug=true. Maximum is 100; default 5 +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.domainAvailabilityV2("google.com", { sug: true, count: 5 }); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Bulk Domain Availability Check @@ -325,24 +386,30 @@ api.domainAvailabilityV2("example.com") `POST /v2.0/domain/availability` ```javascript -// Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) -// Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): -// - domain (string, optional): Required for TLD-mode bulk check (base domain). -// - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DomainAvailabilityApi } = pkg; -// or: const { ApiClient, DomainAvailabilityApi } = require("whoisfreaks-js"); +// Bulk Domain Availability Check: POST https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key node BulkDomainAvailabilityV2.js +const { ApiClient, DomainAvailabilityApi, BulkDomainAvailabilityRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DomainAvailabilityApi(client); -api.bulkDomainAvailabilityV2({}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// bulkDomainAvailabilityV2(bulkDomainAvailabilityRequest, opts) +// bulkDomainAvailabilityRequest (BulkDomainAvailabilityRequest, required): request body +// opts.domain (string, optional): Required for TLD-mode bulk check (base domain) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const body = BulkDomainAvailabilityRequest.constructFromObject({ domainNames: ["whoisfreaks.com", "example.com"] }); + const result = await api.bulkDomainAvailabilityV2(body); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Typosquatting @@ -352,24 +419,29 @@ api.bulkDomainAvailabilityV2({}) `GET /v3.0/domain/typos` ```javascript -// Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) -// Parameters for typosquatting (GET /v3.0/domain/typos): -// - keyword (string, optional) -// - pattern (string, optional) -// - pageToken (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, TyposquattingApi } = pkg; -// or: const { ApiClient, TyposquattingApi } = require("whoisfreaks-js"); +// Typosquatting Lookup: GET https://api.whoisfreaks.com/v3.0/domain/typos +// Run: WHOISFREAKS_API_KEY=your_api_key node Typosquatting.js +const { ApiClient, TyposquattingApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new TyposquattingApi(client); -api.typosquatting() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// typosquatting(opts) +// opts.keyword (string, optional) +// opts.pattern (string, optional) +// opts.pageToken (string, optional) +async function main() { + const result = await api.typosquatting({ keyword: "whoisfreaks" }); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### SSL @@ -379,25 +451,30 @@ api.typosquatting() `GET /v1.0/ssl/live` ```javascript -// Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) -// Parameters for sslLookup (GET /v1.0/ssl/live): -// - domainName (string, required) -// - chain (boolean, optional) -// - sslRaw (boolean, optional) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, SSLApi } = pkg; -// or: const { ApiClient, SSLApi } = require("whoisfreaks-js"); +// SSL Certificate Lookup: GET https://api.whoisfreaks.com/v1.0/ssl/live +// Run: WHOISFREAKS_API_KEY=your_api_key node SslLookup.js +const { ApiClient, SSLApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new SSLApi(client); -api.sslLookup("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// sslLookup(domainName, opts) +// domainName (string, required) +// opts.chain (boolean, optional): default false +// opts.sslRaw (boolean, optional): default false +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.sslLookup("whoisfreaks.com"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Geolocation @@ -407,22 +484,27 @@ api.sslLookup("example.com") `GET /v1.0/geolocation` ```javascript -// Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) -// Parameters for geolocation (GET /v1.0/geolocation): -// - ip (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, GeolocationApi } = pkg; -// or: const { ApiClient, GeolocationApi } = require("whoisfreaks-js"); +// IP Geolocation Lookup: GET https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key node Geolocation.js +const { ApiClient, GeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new GeolocationApi(client); -api.geolocation("8.8.8.8") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// geolocation(ip) +// ip (string, required) +async function main() { + const result = await api.geolocation("8.8.8.8"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Bulk IP Geolocation @@ -430,22 +512,28 @@ api.geolocation("8.8.8.8") `POST /v1.0/geolocation` ```javascript -// Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) -// Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, GeolocationApi } = pkg; -// or: const { ApiClient, GeolocationApi } = require("whoisfreaks-js"); +// Bulk IP Geolocation: POST https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key node BulkGeolocation.js +const { ApiClient, GeolocationApi, BulkGeolocationRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new GeolocationApi(client); -api.bulkGeolocation({}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// bulkGeolocation(bulkGeolocationRequest) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main() { + const body = BulkGeolocationRequest.constructFromObject({ ips: ["8.8.8.8", "1.1.1.1"] }); + const results = await api.bulkGeolocation(body); + console.log(JSON.stringify(results, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Subdomains @@ -455,27 +543,32 @@ api.bulkGeolocation({}) `GET /v1.0/subdomains` ```javascript -// Runnable example: Subdomains Lookup (GET /v1.0/subdomains) -// Parameters for subdomains (GET /v1.0/subdomains): -// - domain (string, required) -// - after (string, optional) -// - before (string, optional) -// - status (string (one of: active, inactive), optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, SubdomainsApi } = pkg; -// or: const { ApiClient, SubdomainsApi } = require("whoisfreaks-js"); +// Subdomains Lookup: GET https://api.whoisfreaks.com/v1.0/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key node Subdomains.js +const { ApiClient, SubdomainsApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new SubdomainsApi(client); -api.subdomains("example.com", "2000-01-01", new Date().toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); - +// subdomains(domain, opts) +// domain (string, required) +// opts.after (string, "yyyy-MM-dd", optional) +// opts.before (string, "yyyy-MM-dd", optional) +// opts.status (string, optional): one of active, inactive +// opts.page (number, optional): default 1 +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.subdomains("whoisfreaks.com", { page: 1 }); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### IP Reputation @@ -485,22 +578,27 @@ api.subdomains("example.com", "2000-01-01", new Date().toISOString().slice(0,10) `GET /v1.0/security` ```javascript -// Runnable example: IP Reputation Lookup (GET /v1.0/security) -// Parameters for ipReputation (GET /v1.0/security): -// - ip (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, IPReputationApi } = pkg; -// or: const { ApiClient, IPReputationApi } = require("whoisfreaks-js"); +// IP Reputation Lookup: GET https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key node IpReputation.js +const { ApiClient, IPReputationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new IPReputationApi(client); -api.ipReputation("8.8.8.8") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// ipReputation(ip) +// ip (string, required) +async function main() { + const result = await api.ipReputation("8.8.8.8"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Bulk IP Reputation @@ -508,22 +606,28 @@ api.ipReputation("8.8.8.8") `POST /v1.0/security` ```javascript -// Runnable example: Bulk IP Reputation (POST /v1.0/security) -// Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, IPReputationApi } = pkg; -// or: const { ApiClient, IPReputationApi } = require("whoisfreaks-js"); +// Bulk IP Reputation: POST https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key node BulkIpReputation.js +const { ApiClient, IPReputationApi, BulkGeolocationRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new IPReputationApi(client); -api.bulkIpReputation({}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// bulkIpReputation(bulkGeolocationRequest) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main() { + const body = BulkGeolocationRequest.constructFromObject({ ips: ["8.8.8.8", "1.1.1.1"] }); + const results = await api.bulkIpReputation(body); + console.log(JSON.stringify(results, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Domain Reputation @@ -533,23 +637,28 @@ api.bulkIpReputation({}) `GET /v1/domain/security` ```javascript -// Runnable example: Domain Reputation Lookup (GET /v1/domain/security) -// Parameters for domainReputation (GET /v1/domain/security): -// - domainName (string, required): The domain name to assess -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DomainReputationApi } = pkg; -// or: const { ApiClient, DomainReputationApi } = require("whoisfreaks-js"); +// Domain Reputation Lookup: GET https://api.whoisfreaks.com/v1/domain/security +// Run: WHOISFREAKS_API_KEY=your_api_key node DomainReputation.js +const { ApiClient, DomainReputationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DomainReputationApi(client); -api.domainReputation("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// domainReputation(domainName, opts) +// domainName (string, required): The domain name to assess +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.domainReputation("amazon.com"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### ASN WHOIS @@ -559,23 +668,28 @@ api.domainReputation("example.com") `GET /v2.0/asn-whois` ```javascript -// Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) -// Parameters for asnWhois (GET /v2.0/asn-whois): -// - asn (string, required) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, ASNWHOISApi } = pkg; -// or: const { ApiClient, ASNWHOISApi } = require("whoisfreaks-js"); +// ASN WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/asn-whois +// Run: WHOISFREAKS_API_KEY=your_api_key node AsnWhois.js +const { ApiClient, ASNWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new ASNWHOISApi(client); -api.asnWhois("AS15169") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// asnWhois(asn, opts) +// asn (string, required) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.asnWhois("as15169"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### IP WHOIS @@ -585,23 +699,28 @@ api.asnWhois("AS15169") `GET /v1.0/ip-whois` ```javascript -// Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) -// Parameters for ipWhois (GET /v1.0/ip-whois): -// - ip (string, required) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, IPWHOISApi } = pkg; -// or: const { ApiClient, IPWHOISApi } = require("whoisfreaks-js"); +// IP WHOIS Lookup: GET https://api.whoisfreaks.com/v1.0/ip-whois +// Run: WHOISFREAKS_API_KEY=your_api_key node IpWhois.js +const { ApiClient, IPWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new IPWHOISApi(client); -api.ipWhois("8.8.8.8") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// ipWhois(ip, opts) +// ip (string, required) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.ipWhois("8.8.8.8"); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Account @@ -611,22 +730,26 @@ api.ipWhois("8.8.8.8") `GET /v1.0/api-key/rotate` ```javascript -// Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) -// Parameters for rotateApiKey (GET /v1.0/api-key/rotate): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, AccountApi } = pkg; -// or: const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Rotate API Key: GET https://api.whoisfreaks.com/v1.0/api-key/rotate +// Run: WHOISFREAKS_API_KEY=your_api_key node RotateApiKey.js +const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new AccountApi(client); -api.rotateApiKey() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// rotateApiKey() takes no parameters. +async function main() { + const newKey = await api.rotateApiKey(); // use this key from now on + console.log("New API key:", newKey); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Account Usage @@ -634,22 +757,26 @@ api.rotateApiKey() `GET /v1.0/whoisapi/usage` ```javascript -// Runnable example: Account Usage (GET /v1.0/whoisapi/usage) -// Parameters for accountUsage (GET /v1.0/whoisapi/usage): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, AccountApi } = pkg; -// or: const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Account Usage: GET https://api.whoisfreaks.com/v1.0/whoisapi/usage +// Run: WHOISFREAKS_API_KEY=your_api_key node AccountUsage.js +const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new AccountApi(client); -api.accountUsage() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// accountUsage() takes no parameters. +async function main() { + const result = await api.accountUsage(); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Database File Status (Public) @@ -657,22 +784,24 @@ api.accountUsage() `GET /v3.4/status` ```javascript -// Runnable example: Database File Status (Public) (GET /v3.4/status) -// Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, AccountApi } = pkg; -// or: const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Database File Status (Public): GET https://files.whoisfreaks.com/v3.4/status +// Run (public endpoint, no API key needed): node DatabaseFileStatus.js +const { AccountApi } = require("whoisfreaks-js"); -const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once -const api = new AccountApi(client); +// Public endpoint: no API key needed. +const api = new AccountApi(); -api.databaseFileStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// databaseFileStatus() takes no parameters. +async function main() { + const result = await api.databaseFileStatus(); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - Newly Registered @@ -682,24 +811,33 @@ api.databaseFileStatus() `GET /v3.1/download/domainer/gtld` ```javascript -// Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) -// Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered gTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyGtld.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyGtld(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyGtld(whois, opts) +// whois (boolean, required) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const data = await api.dbNewlyGtld(true, { date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyGtld.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Newly Registered ccTLD (CSV) @@ -707,24 +845,33 @@ api.dbNewlyGtld(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/download/domainer/cctld` ```javascript -// Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) -// Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered ccTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyCctld.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyCctld(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyCctld(whois, opts) +// whois (boolean, required) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const data = await api.dbNewlyCctld(true, { date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyCctld.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Newly Registered gTLD Cleaned WHOIS (CSV) @@ -732,22 +879,31 @@ api.dbNewlyCctld(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/download/domainer/gtld/cleaned` ```javascript -// Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) -// Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered gTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyGtldCleaned.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyGtldCleaned(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyGtldCleaned(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbNewlyGtldCleaned({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyGtldCleaned.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Newly Registered ccTLD Cleaned WHOIS (CSV) @@ -755,22 +911,31 @@ api.dbNewlyGtldCleaned(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/download/domainer/cctld/cleaned` ```javascript -// Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) -// Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered ccTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyCctldCleaned.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyCctldCleaned(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyCctldCleaned(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbNewlyCctldCleaned({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyCctldCleaned.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Newly Registered gTLD (JSON) @@ -778,23 +943,29 @@ api.dbNewlyCctldCleaned(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/domains/newly/gtld` ```javascript -// Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) -// Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered gTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyGtldJson.js +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyGtldJson(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyGtldJson(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const domains = await api.dbNewlyGtldJson({ date: "2026-10-01" }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Newly Registered ccTLD (JSON) @@ -802,23 +973,29 @@ api.dbNewlyGtldJson(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/domains/newly/cctld` ```javascript -// Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) -// Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered ccTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyCctldJson.js +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyCctldJson(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyCctldJson(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const domains = await api.dbNewlyCctldJson({ date: "2026-10-01" }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Newly Registered With DNS @@ -826,22 +1003,31 @@ api.dbNewlyCctldJson(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/download/domainer/newly/dns` ```javascript -// Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) -// Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered With DNS: GET https://files.whoisfreaks.com/v3.1/download/domainer/newly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyDns.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyDns(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyDns(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbNewlyDns({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyDns.json"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - Expiring & Dropped @@ -851,23 +1037,32 @@ api.dbNewlyDns(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/download/domainer/expired` ```javascript -// Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) -// Parameters for dbExpired (GET /v3.1/download/domainer/expired): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Expiring Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired +// Run: WHOISFREAKS_API_KEY=your_api_key node DbExpired.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbExpired(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbExpired(whois, opts) +// whois (boolean, required) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbExpired(true, { date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbExpired.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Expiring Cleaned WHOIS @@ -875,22 +1070,31 @@ api.dbExpired(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/download/domainer/expired/cleaned` ```javascript -// Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) -// Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Expiring Cleaned WHOIS: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key node DbExpiredCleaned.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbExpiredCleaned(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbExpiredCleaned(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbExpiredCleaned({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbExpiredCleaned.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Dropped Domains @@ -898,23 +1102,32 @@ api.dbExpiredCleaned(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/download/domainer/dropped` ```javascript -// Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) -// Parameters for dbDropped (GET /v3.1/download/domainer/dropped): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Dropped Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDropped.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbDropped(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDropped(whois, opts) +// whois (boolean, required) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDropped(true, { date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDropped.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Dropped Domains (JSON) @@ -922,23 +1135,29 @@ api.dbDropped(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.1/domains/dropped` ```javascript -// Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) -// Parameters for dbDroppedJson (GET /v3.1/domains/dropped): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Dropped Domains (JSON): GET https://files.whoisfreaks.com/v3.1/domains/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDroppedJson.js +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbDroppedJson(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDroppedJson(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const domains = await api.dbDroppedJson({ date: "2026-10-01" }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Dropped With Backlinks @@ -946,23 +1165,32 @@ api.dbDroppedJson(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.3/download/domainer/dropped/backlinks` ```javascript -// Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) -// Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): -// - whois (boolean, optional) -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Dropped With Backlinks: GET https://files.whoisfreaks.com/v3.3/download/domainer/dropped/backlinks +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDroppedBacklinks.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbDroppedBacklinks(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDroppedBacklinks(opts) +// opts.whois (boolean, optional) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDroppedBacklinks({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDroppedBacklinks.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - WHOIS @@ -972,22 +1200,31 @@ api.dbDroppedBacklinks(false, new Date(Date.now()-86400000).toISOString().slice( `GET /v3.3/download/dbupdate/daily/domains/whois` ```javascript -// Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) -// Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesWHOISApi } = pkg; -// or: const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// WHOIS Database Daily: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/daily/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbWhoisDaily.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesWHOISApi(client); -api.dbWhoisDaily(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbWhoisDaily(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbWhoisDaily({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbWhoisDaily.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### WHOIS Database Weekly @@ -995,22 +1232,31 @@ api.dbWhoisDaily(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.3/download/dbupdate/weekly/domains/whois` ```javascript -// Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) -// Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesWHOISApi } = pkg; -// or: const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// WHOIS Database Weekly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/weekly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbWhoisWeekly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesWHOISApi(client); -api.dbWhoisWeekly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbWhoisWeekly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbWhoisWeekly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbWhoisWeekly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### WHOIS Database Monthly @@ -1018,22 +1264,31 @@ api.dbWhoisWeekly(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.3/download/dbupdate/monthly/domains/whois` ```javascript -// Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) -// Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesWHOISApi } = pkg; -// or: const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// WHOIS Database Monthly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/monthly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbWhoisMonthly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesWHOISApi(client); -api.dbWhoisMonthly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbWhoisMonthly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbWhoisMonthly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbWhoisMonthly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - DNS @@ -1043,22 +1298,31 @@ api.dbWhoisMonthly(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.2/download/dbupdate/daily/dns` ```javascript -// Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) -// Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesDNSApi } = pkg; -// or: const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// DNS Database Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/dns +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDnsDaily.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesDNSApi(client); -api.dbDnsDaily(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDnsDaily(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDnsDaily({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDnsDaily.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### DNS Database Weekly @@ -1066,22 +1330,31 @@ api.dbDnsDaily(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.2/download/dbupdate/weekly/dns` ```javascript -// Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) -// Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesDNSApi } = pkg; -// or: const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// DNS Database Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDnsWeekly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesDNSApi(client); -api.dbDnsWeekly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDnsWeekly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDnsWeekly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDnsWeekly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### DNS Database Monthly @@ -1089,22 +1362,31 @@ api.dbDnsWeekly(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.2/download/dbupdate/monthly/dns` ```javascript -// Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) -// Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesDNSApi } = pkg; -// or: const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// DNS Database Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDnsMonthly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesDNSApi(client); -api.dbDnsMonthly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDnsMonthly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDnsMonthly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDnsMonthly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - Subdomains @@ -1114,22 +1396,31 @@ api.dbDnsMonthly(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.2/download/dbupdate/daily/subdomains` ```javascript -// Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) -// Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesSubdomainsApi } = pkg; -// or: const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Subdomains Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key node DbSubdomainsDaily.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesSubdomainsApi(client); -api.dbSubdomainsDaily(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbSubdomainsDaily(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbSubdomainsDaily({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbSubdomainsDaily.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Subdomains Weekly @@ -1137,22 +1428,31 @@ api.dbSubdomainsDaily(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.2/download/dbupdate/weekly/subdomains` ```javascript -// Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) -// Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesSubdomainsApi } = pkg; -// or: const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Subdomains Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key node DbSubdomainsWeekly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesSubdomainsApi(client); -api.dbSubdomainsWeekly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbSubdomainsWeekly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbSubdomainsWeekly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbSubdomainsWeekly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Subdomains Monthly @@ -1160,22 +1460,31 @@ api.dbSubdomainsWeekly(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.2/download/dbupdate/monthly/subdomains` ```javascript -// Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) -// Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesSubdomainsApi } = pkg; -// or: const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Subdomains Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key node DbSubdomainsMonthly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesSubdomainsApi(client); -api.dbSubdomainsMonthly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbSubdomainsMonthly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbSubdomainsMonthly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbSubdomainsMonthly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - IP Geolocation @@ -1185,22 +1494,26 @@ api.dbSubdomainsMonthly(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.3/status/snapshot/ip/country` ```javascript -// Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) -// Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPGeolocationApi } = pkg; -// or: const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// IP to Country Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpCountryStatus.js +const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPGeolocationApi(client); -api.dbIpCountryStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpCountryStatus() takes no parameters. +async function main() { + const result = await api.dbIpCountryStatus(); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### IP to Country Snapshot @@ -1208,22 +1521,31 @@ api.dbIpCountryStatus() `GET /v3.3/download/snapshot/ip/country` ```javascript -// Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) -// Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPGeolocationApi } = pkg; -// or: const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// IP to Country Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpCountry.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPGeolocationApi(client); -api.dbIpCountry(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpCountry(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbIpCountry("2026-10-01"); // a Buffer with the file's bytes + const file = "DbIpCountry.zip"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### IP to City Snapshot Status @@ -1231,22 +1553,26 @@ api.dbIpCountry(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.3/status/snapshot/ip/city` ```javascript -// Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) -// Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPGeolocationApi } = pkg; -// or: const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// IP to City Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpCityStatus.js +const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPGeolocationApi(client); -api.dbIpCityStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpCityStatus() takes no parameters. +async function main() { + const result = await api.dbIpCityStatus(); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### IP to City Snapshot @@ -1254,22 +1580,31 @@ api.dbIpCityStatus() `GET /v3.3/download/snapshot/ip/city` ```javascript -// Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) -// Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPGeolocationApi } = pkg; -// or: const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// IP to City Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpCity.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPGeolocationApi(client); -api.dbIpCity(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpCity(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbIpCity("2026-10-01"); // a Buffer with the file's bytes + const file = "DbIpCity.zip"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - ASN WHOIS @@ -1279,22 +1614,31 @@ api.dbIpCity(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.3/download/snapshot/asn/whois` ```javascript -// Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) -// Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesASNWHOISApi } = pkg; -// or: const { ApiClient, DatabasesASNWHOISApi } = require("whoisfreaks-js"); +// ASN WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbAsnWhois.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesASNWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesASNWHOISApi(client); -api.dbAsnWhois(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbAsnWhois(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbAsnWhois("2026-10-01"); // a Buffer with the file's bytes + const file = "DbAsnWhois.json.gz"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### ASN WHOIS Snapshot Status @@ -1302,22 +1646,26 @@ api.dbAsnWhois(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.3/status/snapshot/asn/whois` ```javascript -// Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) -// Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesASNWHOISApi } = pkg; -// or: const { ApiClient, DatabasesASNWHOISApi } = require("whoisfreaks-js"); +// ASN WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbAsnWhoisStatus.js +const { ApiClient, DatabasesASNWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesASNWHOISApi(client); -api.dbAsnWhoisStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbAsnWhoisStatus() takes no parameters. +async function main() { + const result = await api.dbAsnWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - IP WHOIS @@ -1327,22 +1675,31 @@ api.dbAsnWhoisStatus() `GET /v3.3/download/snapshot/ip/whois` ```javascript -// Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) -// Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPWHOISApi } = pkg; -// or: const { ApiClient, DatabasesIPWHOISApi } = require("whoisfreaks-js"); +// IP WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpWhois.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesIPWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPWHOISApi(client); -api.dbIpWhois(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpWhois(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbIpWhois("2026-10-01"); // a Buffer with the file's bytes + const file = "DbIpWhois.json.gz"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### IP WHOIS Snapshot Status @@ -1350,22 +1707,26 @@ api.dbIpWhois(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.3/status/snapshot/ip/whois` ```javascript -// Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) -// Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPWHOISApi } = pkg; -// or: const { ApiClient, DatabasesIPWHOISApi } = require("whoisfreaks-js"); +// IP WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpWhoisStatus.js +const { ApiClient, DatabasesIPWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPWHOISApi(client); -api.dbIpWhoisStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpWhoisStatus() takes no parameters. +async function main() { + const result = await api.dbIpWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - IP Security @@ -1375,22 +1736,31 @@ api.dbIpWhoisStatus() `GET /v3.3/download/snapshot/ip/security` ```javascript -// Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) -// Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPSecurityApi } = pkg; -// or: const { ApiClient, DatabasesIPSecurityApi } = require("whoisfreaks-js"); +// IP Security Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpSecurity.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesIPSecurityApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPSecurityApi(client); -api.dbIpSecurity(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpSecurity(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbIpSecurity("2026-10-01"); // a Buffer with the file's bytes + const file = "DbIpSecurity.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### IP Security Snapshot Status @@ -1398,22 +1768,26 @@ api.dbIpSecurity(new Date(Date.now()-86400000).toISOString().slice(0,10)) `GET /v3.3/status/snapshot/ip/security` ```javascript -// Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) -// Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPSecurityApi } = pkg; -// or: const { ApiClient, DatabasesIPSecurityApi } = require("whoisfreaks-js"); +// IP Security Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpSecurityStatus.js +const { ApiClient, DatabasesIPSecurityApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPSecurityApi(client); -api.dbIpSecurityStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpSecurityStatus() takes no parameters. +async function main() { + const result = await api.dbIpSecurityStatus(); + console.log(JSON.stringify(result, null, 2)); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` ### Databases - Threat Feed @@ -1423,22 +1797,31 @@ api.dbIpSecurityStatus() `GET /v3.4/download/threat-feed/phishing` ```javascript -// Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) -// Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download the daily phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedPhishing.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedPhishing(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedPhishing(opts) +// opts.date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main() { + const data = await api.downloadThreatFeedPhishing({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DownloadThreatFeedPhishing.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Download a sample of the phishing threat feed (CSV) @@ -1446,22 +1829,30 @@ api.downloadThreatFeedPhishing(new Date(Date.now()-86400000).toISOString().slice `GET /v3.4/download/threat-feed/phishing/sample` ```javascript -// Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) -// Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download a sample of the phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing/sample +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedPhishingSample.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedPhishingSample() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedPhishingSample() takes no parameters. +async function main() { + const data = await api.downloadThreatFeedPhishingSample(); // a Buffer with the file's bytes + const file = "DownloadThreatFeedPhishingSample.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Download the daily malware threat feed (CSV) @@ -1469,22 +1860,31 @@ api.downloadThreatFeedPhishingSample() `GET /v3.4/download/threat-feed/malware` ```javascript -// Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) -// Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download the daily malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedMalware.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedMalware(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedMalware(opts) +// opts.date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main() { + const data = await api.downloadThreatFeedMalware({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DownloadThreatFeedMalware.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Download a sample of the malware threat feed (CSV) @@ -1492,22 +1892,30 @@ api.downloadThreatFeedMalware(new Date(Date.now()-86400000).toISOString().slice( `GET /v3.4/download/threat-feed/malware/sample` ```javascript -// Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) -// Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download a sample of the malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware/sample +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedMalwareSample.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedMalwareSample() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedMalwareSample() takes no parameters. +async function main() { + const data = await api.downloadThreatFeedMalwareSample(); // a Buffer with the file's bytes + const file = "DownloadThreatFeedMalwareSample.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Download the daily spam threat feed (CSV) @@ -1515,22 +1923,31 @@ api.downloadThreatFeedMalwareSample() `GET /v3.4/download/threat-feed/spam` ```javascript -// Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) -// Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download the daily spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedSpam.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedSpam(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedSpam(opts) +// opts.date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main() { + const data = await api.downloadThreatFeedSpam({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DownloadThreatFeedSpam.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` #### Download a sample of the spam threat feed (CSV) @@ -1538,20 +1955,28 @@ api.downloadThreatFeedSpam(new Date(Date.now()-86400000).toISOString().slice(0,1 `GET /v3.4/download/threat-feed/spam/sample` ```javascript -// Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) -// Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download a sample of the spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam/sample +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedSpamSample.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedSpamSample() - .then(data => console.log(data)) - .catch(err => console.error(err)); - +// downloadThreatFeedSpamSample() takes no parameters. +async function main() { + const data = await api.downloadThreatFeedSpamSample(); // a Buffer with the file's bytes + const file = "DownloadThreatFeedSpamSample.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); ``` diff --git a/docs/languages/kotlin.md b/docs/languages/kotlin.md index 22a03a9..e971261 100644 --- a/docs/languages/kotlin.md +++ b/docs/languages/kotlin.md @@ -2,22 +2,22 @@ ## About -The official **WhoisFreaks Kotlin SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Kotlin with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Maven Central. +The official **WhoisFreaks Kotlin SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Kotlin with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Maven Central. **Keywords:** kotlin whois api, kotlin whois sdk, whoisfreaks kotlin, kotlin domain lookup, kotlin dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api - **Registry:** Maven Central -- **Package:** `com.whoisfreaks:whoisfreaks` +- **Package:** `com.whoisfreaks:whoisfreaks-kotlin` ## Install ```kotlin -implementation("com.whoisfreaks:whoisfreaks:LATEST") +implementation("com.whoisfreaks:whoisfreaks-kotlin:0.23.0") ``` ## Build from Source -Prefer to build the SDK yourself instead of installing from Maven Central? Clone the monorepo and build the Kotlin package locally: +Prefer to build the SDK yourself instead of installing from Maven Central? Clone the Kotlin SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-kotlin @@ -29,30 +29,62 @@ cd whoisfreaks-kotlin A complete walkthrough from an empty directory to a running program: -In a Gradle project, add to `build.gradle.kts`: +You need JDK 11 or later and [Gradle](https://gradle.org/install/) 8. Create the project directory: + +```bash +mkdir -p whoisfreaks-test/src/main/kotlin && cd whoisfreaks-test +``` + +Create `settings.gradle.kts`: + +```kotlin +rootProject.name = "whoisfreaks-test" +``` + +Create `build.gradle.kts`. The `mainClass` property picks the program that `gradle run` starts: ```kotlin -repositories { mavenCentral() } +plugins { + kotlin("jvm") version "2.0.21" + application +} + +repositories { + mavenCentral() +} + dependencies { - implementation("com.whoisfreaks:whoisfreaks:LATEST") // pin to a real version, e.g. 1.0.0 + implementation("com.whoisfreaks:whoisfreaks-kotlin:0.23.0") +} + +application { + mainClass.set(providers.gradleProperty("mainClass").orElse("MainKt")) } ``` -`src/main/kotlin/Main.kt`: +Create `src/main/kotlin/Main.kt`: ```kotlin -import com.whoisfreaks.client.apis.WhoisApi +import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once - val api = WhoisApi() - val result = api.whoisLive("example.com") - println(result) + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call + + val record = WHOISApi().whoisLive("whoisfreaks.com") + println("${record.domainName} expires ${record.expiryDate}") + println(record) } ``` -Run with `./gradlew run` (with the application plugin) or your IDE. +Set your API key and run it: + +```bash +export WHOISFREAKS_API_KEY="your_api_key" +gradle run +``` + +To run one of the [runnable examples](../../examples/kotlin/README.md), copy it into `src/main/kotlin` and pass its class name (file name plus `Kt`), for example `gradle run -PmainClass=WhoisLiveKt`. ## Configure @@ -60,6 +92,7 @@ See [Authentication](../authentication.md) for how to obtain a key. Minimal setu ```kotlin // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: gradle run -PmainClass=WhoisLiveKt // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) @@ -67,9 +100,10 @@ import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.whoisLive("example.com", null) + + val result = api.whoisLive("whoisfreaks.com") println(result) } @@ -87,6 +121,7 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, ```kotlin // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: gradle run -PmainClass=WhoisLiveKt // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) @@ -94,9 +129,10 @@ import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.whoisLive("example.com", null) + + val result = api.whoisLive("whoisfreaks.com") println(result) } @@ -108,17 +144,20 @@ fun main() { ```kotlin // Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Run it from the Getting Started project: gradle run -PmainClass=BulkWhoisKt // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient import com.whoisfreaks.client.models.BulkWhoisRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.bulkWhois(BulkWhoisRequest(), null) + + val body = BulkWhoisRequest(domainNames = listOf("whoisfreaks.com", "jfreaks.com")) + val result = api.bulkWhois(body) println(result) } @@ -130,17 +169,18 @@ fun main() { ```kotlin // Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Run it from the Getting Started project: gradle run -PmainClass=WhoisHistoryKt // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.whoisHistory("example.com", null, null) + + val result = api.whoisHistory("whoisfreaks.com") println(result) } @@ -152,6 +192,7 @@ fun main() { ```kotlin // Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Run it from the Getting Started project: gradle run -PmainClass=WhoisReverseKt // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number @@ -160,9 +201,10 @@ import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.whoisReverse("value", null, null) + + val result = api.whoisReverse("whoisfreaks", page = 1) println(result) } @@ -176,18 +218,20 @@ fun main() { ```kotlin // Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Run it from the Getting Started project: gradle run -PmainClass=DnsLiveKt // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.apis.DNSApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DNSApi() - val result = api.dnsLive("example.com", "8.8.8.8", "value", null) + + val result = api.dnsLive("A,MX,TXT", domainName = "whoisfreaks.com") println(result) } @@ -199,6 +243,7 @@ fun main() { ```kotlin // Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Run it from the Getting Started project: gradle run -PmainClass=DnsHistoricalKt // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) @@ -208,9 +253,10 @@ import com.whoisfreaks.client.apis.DNSApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DNSApi() - val result = api.dnsHistorical("example.com", "value", null, null) + + val result = api.dnsHistorical("whoisfreaks.com", "A,MX,TXT", page = 1) println(result) } @@ -222,6 +268,7 @@ fun main() { ```kotlin // Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Run it from the Getting Started project: gradle run -PmainClass=DnsReverseKt // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) @@ -232,9 +279,10 @@ import com.whoisfreaks.client.apis.DNSApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DNSApi() - val result = api.dnsReverse("value", "a", true, null, null) + + val result = api.dnsReverse("8.8.8.8", DNSApi.TypeDnsReverse.a, page = 1) println(result) } @@ -246,18 +294,21 @@ fun main() { ```kotlin // Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Run it from the Getting Started project: gradle run -PmainClass=DnsBulkKt // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object import com.whoisfreaks.client.apis.DNSApi import com.whoisfreaks.client.infrastructure.ApiClient import com.whoisfreaks.client.models.DnsBulkRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DNSApi() - val result = api.dnsBulk("value", DnsBulkRequest(), null) + + val body = DnsBulkRequest(domainNames = listOf("whoisfreaks.com", "example.com")) + val result = api.dnsBulk("A,MX,TXT", body) println(result) } @@ -271,6 +322,7 @@ fun main() { ```kotlin // Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Run it from the Getting Started project: gradle run -PmainClass=DomainAvailabilityV2Kt // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. @@ -280,9 +332,10 @@ import com.whoisfreaks.client.apis.DomainAvailabilityApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DomainAvailabilityApi() - val result = api.domainAvailabilityV2("example.com", null, null, null) + + val result = api.domainAvailabilityV2("google.com", sug = true, count = 5) println(result) } @@ -294,18 +347,21 @@ fun main() { ```kotlin // Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Run it from the Getting Started project: gradle run -PmainClass=BulkDomainAvailabilityV2Kt // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object import com.whoisfreaks.client.apis.DomainAvailabilityApi import com.whoisfreaks.client.infrastructure.ApiClient import com.whoisfreaks.client.models.BulkDomainAvailabilityRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DomainAvailabilityApi() - val result = api.bulkDomainAvailabilityV2(BulkDomainAvailabilityRequest(), null, null) + + val body = BulkDomainAvailabilityRequest(domainNames = listOf("whoisfreaks.com", "example.com")) + val result = api.bulkDomainAvailabilityV2(body) println(result) } @@ -319,6 +375,7 @@ fun main() { ```kotlin // Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Run it from the Getting Started project: gradle run -PmainClass=TyposquattingKt // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) @@ -327,9 +384,10 @@ import com.whoisfreaks.client.apis.TyposquattingApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = TyposquattingApi() - val result = api.typosquatting(null, null, null) + + val result = api.typosquatting(keyword = "whoisfreaks") println(result) } @@ -343,6 +401,7 @@ fun main() { ```kotlin // Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// Run it from the Getting Started project: gradle run -PmainClass=SslLookupKt // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) @@ -352,9 +411,10 @@ import com.whoisfreaks.client.apis.SSLApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = SSLApi() - val result = api.sslLookup("example.com", null, null, null) + + val result = api.sslLookup("whoisfreaks.com") println(result) } @@ -368,14 +428,16 @@ fun main() { ```kotlin // Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// Run it from the Getting Started project: gradle run -PmainClass=GeolocationKt // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) import com.whoisfreaks.client.apis.GeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = GeolocationApi() + val result = api.geolocation("8.8.8.8") println(result) } @@ -388,16 +450,19 @@ fun main() { ```kotlin // Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Run it from the Getting Started project: gradle run -PmainClass=BulkGeolocationKt // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object import com.whoisfreaks.client.apis.GeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient import com.whoisfreaks.client.models.BulkGeolocationRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = GeolocationApi() - val result = api.bulkGeolocation(BulkGeolocationRequest()) + + val body = BulkGeolocationRequest(ips = listOf("8.8.8.8", "1.1.1.1")) + val result = api.bulkGeolocation(body) println(result) } @@ -411,6 +476,7 @@ fun main() { ```kotlin // Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Run it from the Getting Started project: gradle run -PmainClass=SubdomainsKt // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -422,9 +488,10 @@ import com.whoisfreaks.client.apis.SubdomainsApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = SubdomainsApi() - val result = api.subdomains("example.com", "2000-01-01", java.time.LocalDate.now().toString(), null, null, null) + + val result = api.subdomains("whoisfreaks.com", page = 1) println(result) } @@ -438,14 +505,16 @@ fun main() { ```kotlin // Runnable example: IP Reputation Lookup (GET /v1.0/security) +// Run it from the Getting Started project: gradle run -PmainClass=IpReputationKt // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) import com.whoisfreaks.client.apis.IPReputationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = IPReputationApi() + val result = api.ipReputation("8.8.8.8") println(result) } @@ -458,16 +527,19 @@ fun main() { ```kotlin // Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Run it from the Getting Started project: gradle run -PmainClass=BulkIpReputationKt // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object import com.whoisfreaks.client.apis.IPReputationApi import com.whoisfreaks.client.infrastructure.ApiClient -import com.whoisfreaks.client.models.BulkIpReputationRequest +import com.whoisfreaks.client.models.BulkGeolocationRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = IPReputationApi() - val result = api.bulkIpReputation(BulkIpReputationRequest()) + + val body = BulkGeolocationRequest(ips = listOf("8.8.8.8", "1.1.1.1")) + val result = api.bulkIpReputation(body) println(result) } @@ -481,6 +553,7 @@ fun main() { ```kotlin // Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Run it from the Getting Started project: gradle run -PmainClass=DomainReputationKt // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) @@ -488,9 +561,10 @@ import com.whoisfreaks.client.apis.DomainReputationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DomainReputationApi() - val result = api.domainReputation("example.com", null) + + val result = api.domainReputation("amazon.com") println(result) } @@ -504,6 +578,7 @@ fun main() { ```kotlin // Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// Run it from the Getting Started project: gradle run -PmainClass=AsnWhoisKt // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) @@ -511,9 +586,10 @@ import com.whoisfreaks.client.apis.ASNWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = ASNWHOISApi() - val result = api.asnWhois("AS15169", null) + + val result = api.asnWhois("as15169") println(result) } @@ -527,6 +603,7 @@ fun main() { ```kotlin // Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// Run it from the Getting Started project: gradle run -PmainClass=IpWhoisKt // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) @@ -534,9 +611,10 @@ import com.whoisfreaks.client.apis.IPWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = IPWHOISApi() - val result = api.ipWhois("8.8.8.8", null) + + val result = api.ipWhois("8.8.8.8") println(result) } @@ -550,16 +628,19 @@ fun main() { ```kotlin // Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Run it from the Getting Started project: gradle run -PmainClass=RotateApiKeyKt // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.AccountApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = AccountApi() - val result = api.rotateApiKey() - println(result) + + val newKey = api.rotateApiKey() + // The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY. + println("New API key: $newKey") } ``` @@ -570,14 +651,16 @@ fun main() { ```kotlin // Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Run it from the Getting Started project: gradle run -PmainClass=AccountUsageKt // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.AccountApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = AccountApi() + val result = api.accountUsage() println(result) } @@ -590,14 +673,15 @@ fun main() { ```kotlin // Runnable example: Database File Status (Public) (GET /v3.4/status) +// Run it from the Getting Started project: gradle run -PmainClass=DatabaseFileStatusKt // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) import com.whoisfreaks.client.apis.AccountApi -import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + // Public endpoint: no API key needed. val api = AccountApi() + val result = api.databaseFileStatus() println(result) } @@ -612,18 +696,24 @@ fun main() { ```kotlin // Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyGtldKt // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyGtld(false, java.time.LocalDate.now().minusDays(1).toString(), null) - println(result) + + val download = api.dbNewlyGtld(true, date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyGtld.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -634,18 +724,24 @@ fun main() { ```kotlin // Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyCctldKt // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyCctld(false, java.time.LocalDate.now().minusDays(1).toString(), null) - println(result) + + val download = api.dbNewlyCctld(true, date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyCctld.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -656,16 +752,22 @@ fun main() { ```kotlin // Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyGtldCleanedKt // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyGtldCleaned(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbNewlyGtldCleaned(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyGtldCleaned.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -676,16 +778,22 @@ fun main() { ```kotlin // Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyCctldCleanedKt // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyCctldCleaned(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbNewlyCctldCleaned(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyCctldCleaned.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -696,16 +804,19 @@ fun main() { ```kotlin // Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyGtldJsonKt // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyGtldJson(java.time.LocalDate.now().minusDays(1).toString(), null) + + val result = api.dbNewlyGtldJson(date = LocalDate.of(2026, 10, 1)) println(result) } @@ -717,16 +828,19 @@ fun main() { ```kotlin // Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyCctldJsonKt // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyCctldJson(java.time.LocalDate.now().minusDays(1).toString(), null) + + val result = api.dbNewlyCctldJson(date = LocalDate.of(2026, 10, 1)) println(result) } @@ -738,16 +852,22 @@ fun main() { ```kotlin // Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyDnsKt // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyDns(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbNewlyDns(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyDns.json"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -760,17 +880,23 @@ fun main() { ```kotlin // Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Run it from the Getting Started project: gradle run -PmainClass=DbExpiredKt // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbExpired(false, java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbExpired(true, date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbExpired.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -781,16 +907,22 @@ fun main() { ```kotlin // Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Run it from the Getting Started project: gradle run -PmainClass=DbExpiredCleanedKt // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbExpiredCleaned(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbExpiredCleaned(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbExpiredCleaned.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -801,17 +933,23 @@ fun main() { ```kotlin // Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Run it from the Getting Started project: gradle run -PmainClass=DbDroppedKt // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbDropped(false, java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDropped(true, date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDropped.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -822,16 +960,19 @@ fun main() { ```kotlin // Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Run it from the Getting Started project: gradle run -PmainClass=DbDroppedJsonKt // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbDroppedJson(java.time.LocalDate.now().minusDays(1).toString(), null) + + val result = api.dbDroppedJson(date = LocalDate.of(2026, 10, 1)) println(result) } @@ -843,17 +984,23 @@ fun main() { ```kotlin // Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Run it from the Getting Started project: gradle run -PmainClass=DbDroppedBacklinksKt // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbDroppedBacklinks(false, java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDroppedBacklinks(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDroppedBacklinks.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -866,16 +1013,22 @@ fun main() { ```kotlin // Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbWhoisDailyKt // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesWHOISApi() - val result = api.dbWhoisDaily(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbWhoisDaily(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbWhoisDaily.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -886,16 +1039,22 @@ fun main() { ```kotlin // Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbWhoisWeeklyKt // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesWHOISApi() - val result = api.dbWhoisWeekly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbWhoisWeekly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbWhoisWeekly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -906,16 +1065,22 @@ fun main() { ```kotlin // Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbWhoisMonthlyKt // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesWHOISApi() - val result = api.dbWhoisMonthly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbWhoisMonthly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbWhoisMonthly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -928,16 +1093,22 @@ fun main() { ```kotlin // Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// Run it from the Getting Started project: gradle run -PmainClass=DbDnsDailyKt // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesDNSApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesDNSApi() - val result = api.dbDnsDaily(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDnsDaily(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDnsDaily.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -948,16 +1119,22 @@ fun main() { ```kotlin // Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// Run it from the Getting Started project: gradle run -PmainClass=DbDnsWeeklyKt // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesDNSApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesDNSApi() - val result = api.dbDnsWeekly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDnsWeekly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDnsWeekly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -968,16 +1145,22 @@ fun main() { ```kotlin // Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// Run it from the Getting Started project: gradle run -PmainClass=DbDnsMonthlyKt // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesDNSApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesDNSApi() - val result = api.dbDnsMonthly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDnsMonthly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDnsMonthly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -990,16 +1173,22 @@ fun main() { ```kotlin // Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Run it from the Getting Started project: gradle run -PmainClass=DbSubdomainsDailyKt // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesSubdomainsApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesSubdomainsApi() - val result = api.dbSubdomainsDaily(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbSubdomainsDaily(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbSubdomainsDaily.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1010,16 +1199,22 @@ fun main() { ```kotlin // Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Run it from the Getting Started project: gradle run -PmainClass=DbSubdomainsWeeklyKt // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesSubdomainsApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesSubdomainsApi() - val result = api.dbSubdomainsWeekly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbSubdomainsWeekly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbSubdomainsWeekly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1030,16 +1225,22 @@ fun main() { ```kotlin // Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Run it from the Getting Started project: gradle run -PmainClass=DbSubdomainsMonthlyKt // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesSubdomainsApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesSubdomainsApi() - val result = api.dbSubdomainsMonthly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbSubdomainsMonthly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbSubdomainsMonthly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1052,14 +1253,16 @@ fun main() { ```kotlin // Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpCountryStatusKt // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesIPGeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPGeolocationApi() + val result = api.dbIpCountryStatus() println(result) } @@ -1072,16 +1275,22 @@ fun main() { ```kotlin // Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpCountryKt // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesIPGeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPGeolocationApi() - val result = api.dbIpCountry(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbIpCountry(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbIpCountry.zip"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1092,14 +1301,16 @@ fun main() { ```kotlin // Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpCityStatusKt // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesIPGeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPGeolocationApi() + val result = api.dbIpCityStatus() println(result) } @@ -1112,16 +1323,22 @@ fun main() { ```kotlin // Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpCityKt // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesIPGeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPGeolocationApi() - val result = api.dbIpCity(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbIpCity(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbIpCity.zip"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1134,16 +1351,22 @@ fun main() { ```kotlin // Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbAsnWhoisKt // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesASNWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesASNWHOISApi() - val result = api.dbAsnWhois(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbAsnWhois(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbAsnWhois.json.gz"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1154,14 +1377,16 @@ fun main() { ```kotlin // Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbAsnWhoisStatusKt // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesASNWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesASNWHOISApi() + val result = api.dbAsnWhoisStatus() println(result) } @@ -1176,16 +1401,22 @@ fun main() { ```kotlin // Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpWhoisKt // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesIPWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPWHOISApi() - val result = api.dbIpWhois(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbIpWhois(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbIpWhois.json.gz"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1196,14 +1427,16 @@ fun main() { ```kotlin // Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpWhoisStatusKt // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesIPWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPWHOISApi() + val result = api.dbIpWhoisStatus() println(result) } @@ -1218,16 +1451,22 @@ fun main() { ```kotlin // Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpSecurityKt // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesIPSecurityApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPSecurityApi() - val result = api.dbIpSecurity(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbIpSecurity(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbIpSecurity.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1238,14 +1477,16 @@ fun main() { ```kotlin // Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpSecurityStatusKt // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesIPSecurityApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPSecurityApi() + val result = api.dbIpSecurityStatus() println(result) } @@ -1260,16 +1501,21 @@ fun main() { ```kotlin // Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedPhishingKt // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedPhishing(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.downloadThreatFeedPhishing(date = "2026-10-01") + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedPhishing.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1280,16 +1526,21 @@ fun main() { ```kotlin // Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedPhishingSampleKt // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedPhishingSample() - println(result) + + val download = api.downloadThreatFeedPhishingSample() + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedPhishingSample.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1300,16 +1551,21 @@ fun main() { ```kotlin // Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedMalwareKt // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedMalware(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.downloadThreatFeedMalware(date = "2026-10-01") + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedMalware.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1320,16 +1576,21 @@ fun main() { ```kotlin // Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedMalwareSampleKt // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedMalwareSample() - println(result) + + val download = api.downloadThreatFeedMalwareSample() + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedMalwareSample.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1340,16 +1601,21 @@ fun main() { ```kotlin // Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedSpamKt // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedSpam(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.downloadThreatFeedSpam(date = "2026-10-01") + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedSpam.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` @@ -1360,16 +1626,21 @@ fun main() { ```kotlin // Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedSpamSampleKt // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedSpamSample() - println(result) + + val download = api.downloadThreatFeedSpamSample() + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedSpamSample.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } ``` diff --git a/docs/languages/php.md b/docs/languages/php.md index d0c5702..162eaa7 100644 --- a/docs/languages/php.md +++ b/docs/languages/php.md @@ -2,22 +2,22 @@ ## About -The official **WhoisFreaks PHP SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from PHP with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Packagist. +The official **WhoisFreaks PHP SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from PHP with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Packagist. **Keywords:** php whois api, php whois sdk, whoisfreaks php, php domain lookup, php dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api - **Registry:** Packagist -- **Package:** `WhoisFreaks/whoisfreaks-php` +- **Package:** `whoisfreaks/whoisfreaks-php` ## Install ```bash -composer require WhoisFreaks/whoisfreaks-php +composer require whoisfreaks/whoisfreaks-php ``` ## Build from Source -Prefer to build the SDK yourself instead of installing from Packagist? Clone the monorepo and build the PHP package locally: +Prefer to build the SDK yourself instead of installing from Packagist? Clone the PHP SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-php @@ -29,28 +29,41 @@ composer install A complete walkthrough from an empty directory to a running program: +You need PHP 7.4 or later (PHP 8 supported) and [Composer](https://getcomposer.org). + +1. Create a project and install the SDK: + ```bash mkdir whoisfreaks-test && cd whoisfreaks-test -composer init --no-interaction -composer require WhoisFreaks/whoisfreaks-php +composer require whoisfreaks/whoisfreaks-php ``` -Create `main.php`: +2. Create `main.php`: ```php setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); -$config = WhoisFreaks\Configuration::getDefaultConfiguration() - ->setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WhoisApi(new GuzzleHttp\Client(), $config); -$result = $api->whoisLive("example.com"); -print_r($result); +$whois = new WHOISApi(new Client(), $config); +$record = $whois->whoisLive('whoisfreaks.com'); + +echo 'Registrar: ', $record->getDomainRegistrar()->getRegistrarName(), PHP_EOL; +echo 'Created: ', $record->getCreateDate(), PHP_EOL; +echo 'Expires: ', $record->getExpiryDate(), PHP_EOL; ``` -Run it: +3. Set your API key and run it: ```bash +export WHOISFREAKS_API_KEY="your_api_key" php main.php ``` @@ -60,17 +73,32 @@ See [Authentication](../authentication.md) for how to obtain a key. Minimal setu ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->whoisLive("example.com", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\WHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new WHOISApi(new Client(), $config); + +try { + $result = $api->whoisLive('whoisfreaks.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -86,17 +114,32 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->whoisLive("example.com", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\WHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new WHOISApi(new Client(), $config); + +try { + $result = $api->whoisLive('whoisfreaks.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -106,17 +149,37 @@ print_r($result); ```php setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); -$config = WhoisFreaks\Configuration::getDefaultConfiguration() - ->setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->bulkWhois(new WhoisFreaks\Model\BulkWhoisRequest(), null); -print_r($result); +$api = new WHOISApi(new Client(), $config); + +$request = new BulkWhoisRequest([ + 'domainNames' => ['whoisfreaks.com', 'jfreaks.com'], +]); + +try { + $result = $api->bulkWhois($request); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -126,18 +189,32 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->whoisHistory("example.com", null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\WHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new WHOISApi(new Client(), $config); + +try { + $result = $api->whoisHistory('whoisfreaks.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -147,18 +224,33 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->whoisReverse("value", null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\WHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new WHOISApi(new Client(), $config); + +try { + $result = $api->whoisReverse('whoisfreaks', 1); // keyword, page + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -170,19 +262,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dnsLive("example.com", "8.8.8.8", "value", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DNSApi(new Client(), $config); + +try { + $result = $api->dnsLive('A,MX,TXT', 'whoisfreaks.com'); // type, domainName + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -192,19 +299,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dnsHistorical("example.com", "value", null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DNSApi(new Client(), $config); + +try { + $result = $api->dnsHistorical('whoisfreaks.com', 'A,MX,TXT', 1); // domainName, type, page + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -214,20 +336,35 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dnsReverse("value", "a", true, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DNSApi(new Client(), $config); + +try { + $result = $api->dnsReverse('8.8.8.8', 'a', true, 1); // value, type, exact, page + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -237,18 +374,38 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dnsBulk("value", new WhoisFreaks\Model\DnsBulkRequest(), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; +use WhoisFreaks\Model\DnsBulkRequest; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DNSApi(new Client(), $config); + +$request = new DnsBulkRequest([ + 'domainNames' => ['whoisfreaks.com', 'example.com'], +]); + +try { + $result = $api->dnsBulk('A,MX,TXT', $request); // type, dnsBulkRequest + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -260,19 +417,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DomainAvailabilityApi(new GuzzleHttp\Client(), $config); -$result = $api->domainAvailabilityV2("example.com", null, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DomainAvailabilityApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DomainAvailabilityApi(new Client(), $config); + +try { + $result = $api->domainAvailabilityV2('google.com', true, 5); // domain, sug, count + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -282,18 +454,38 @@ print_r($result); ```php setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); -$config = WhoisFreaks\Configuration::getDefaultConfiguration() - ->setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DomainAvailabilityApi(new GuzzleHttp\Client(), $config); -$result = $api->bulkDomainAvailabilityV2(new WhoisFreaks\Model\BulkDomainAvailabilityRequest(), null, null); -print_r($result); +$api = new DomainAvailabilityApi(new Client(), $config); + +$request = new BulkDomainAvailabilityRequest([ + 'domainNames' => ['whoisfreaks.com', 'example.com'], +]); + +try { + $result = $api->bulkDomainAvailabilityV2($request); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -305,18 +497,33 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\TyposquattingApi(new GuzzleHttp\Client(), $config); -$result = $api->typosquatting(null, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\TyposquattingApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new TyposquattingApi(new Client(), $config); + +try { + $result = $api->typosquatting('whoisfreaks'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -328,19 +535,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\SSLApi(new GuzzleHttp\Client(), $config); -$result = $api->sslLookup("example.com", null, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\SSLApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new SSLApi(new Client(), $config); + +try { + $result = $api->sslLookup('whoisfreaks.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -352,16 +574,31 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\GeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->geolocation("8.8.8.8"); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\GeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new GeolocationApi(new Client(), $config); + +try { + $result = $api->geolocation('8.8.8.8'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -371,16 +608,38 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\GeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->bulkGeolocation(new WhoisFreaks\Model\BulkGeolocationRequest()); -print_r($result); +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new GeolocationApi(new Client(), $config); + +$request = new BulkGeolocationRequest([ + 'ips' => ['8.8.8.8', '1.1.1.1'], +]); + +try { + $results = $api->bulkGeolocation($request); + foreach ($results as $result) { + echo $result, PHP_EOL; // models print as JSON + } +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -392,7 +651,8 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\SubdomainsApi(new GuzzleHttp\Client(), $config); -$result = $api->subdomains("example.com", "2000-01-01", (new DateTime("today"))->format("Y-m-d"), null, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\SubdomainsApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new SubdomainsApi(new Client(), $config); + +try { + $result = $api->subdomains('whoisfreaks.com', null, null, null, 1); // domain, after, before, status, page + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -418,16 +692,31 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\IPReputationApi(new GuzzleHttp\Client(), $config); -$result = $api->ipReputation("8.8.8.8"); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\IPReputationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new IPReputationApi(new Client(), $config); + +try { + $result = $api->ipReputation('8.8.8.8'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -437,16 +726,38 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\IPReputationApi(new GuzzleHttp\Client(), $config); -$result = $api->bulkIpReputation(new WhoisFreaks\Model\BulkIpReputationRequest()); -print_r($result); +use GuzzleHttp\Client; +use WhoisFreaks\Api\IPReputationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; +use WhoisFreaks\Model\BulkGeolocationRequest; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new IPReputationApi(new Client(), $config); + +$request = new BulkGeolocationRequest([ + 'ips' => ['8.8.8.8', '1.1.1.1'], +]); + +try { + $results = $api->bulkIpReputation($request); + foreach ($results as $result) { + echo $result, PHP_EOL; // models print as JSON + } +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -458,17 +769,32 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DomainReputationApi(new GuzzleHttp\Client(), $config); -$result = $api->domainReputation("example.com", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DomainReputationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DomainReputationApi(new Client(), $config); + +try { + $result = $api->domainReputation('amazon.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -480,17 +806,32 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\ASNWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->asnWhois("AS15169", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\ASNWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new ASNWHOISApi(new Client(), $config); + +try { + $result = $api->asnWhois('as15169'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -502,17 +843,32 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\IPWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->ipWhois("8.8.8.8", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\IPWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new IPWHOISApi(new Client(), $config); + +try { + $result = $api->ipWhois('8.8.8.8'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -524,16 +880,32 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\AccountApi(new GuzzleHttp\Client(), $config); -$result = $api->rotateApiKey(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\AccountApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new AccountApi(new Client(), $config); + +try { + $newKey = $api->rotateApiKey(); + // The old key stops working now: store the new one before making more calls. + echo 'New API key: ', $newKey, PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -543,16 +915,31 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\AccountApi(new GuzzleHttp\Client(), $config); -$result = $api->accountUsage(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\AccountApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new AccountApi(new Client(), $config); + +try { + $result = $api->accountUsage(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -562,16 +949,32 @@ print_r($result); ```php setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); -$config = WhoisFreaks\Configuration::getDefaultConfiguration() - ->setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\AccountApi(new GuzzleHttp\Client(), $config); -$result = $api->databaseFileStatus(); -print_r($result); +$api = new AccountApi(new Client(), $config); + +try { + $result = $api->databaseFileStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -583,18 +986,36 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyGtld(false, (new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyGtld(true, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyGtld.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -604,18 +1025,36 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyCctld(false, (new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyCctld(true, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyCctld.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -625,16 +1064,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyGtldCleaned((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyGtldCleaned('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyGtldCleaned.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -644,16 +1101,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyCctldCleaned((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyCctldCleaned('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyCctldCleaned.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -663,17 +1138,32 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyGtldJson((new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $domains = $api->dbNewlyGtldJson('2026-10-01'); + echo implode(PHP_EOL, $domains), PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -683,17 +1173,32 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyCctldJson((new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $domains = $api->dbNewlyCctldJson('2026-10-01'); + echo implode(PHP_EOL, $domains), PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -703,16 +1208,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyDns((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyDns('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyDns.json'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -724,17 +1247,35 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbExpired(false, (new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $file = $api->dbExpired(true, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbExpired.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -744,16 +1285,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbExpiredCleaned((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $file = $api->dbExpiredCleaned('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbExpiredCleaned.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -763,17 +1322,35 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDropped(false, (new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $file = $api->dbDropped(true, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDropped.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -783,17 +1360,32 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDroppedJson((new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $domains = $api->dbDroppedJson('2026-10-01'); + echo implode(PHP_EOL, $domains), PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -803,17 +1395,35 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDroppedBacklinks(false, (new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $file = $api->dbDroppedBacklinks(null, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDroppedBacklinks.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -825,16 +1435,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbWhoisDaily((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesWHOISApi(new Client(), $config); + +try { + $file = $api->dbWhoisDaily('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbWhoisDaily.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -844,16 +1472,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbWhoisWeekly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesWHOISApi(new Client(), $config); + +try { + $file = $api->dbWhoisWeekly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbWhoisWeekly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -863,16 +1509,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbWhoisMonthly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesWHOISApi(new Client(), $config); + +try { + $file = $api->dbWhoisMonthly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbWhoisMonthly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -884,16 +1548,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesDNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDnsDaily((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesDNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesDNSApi(new Client(), $config); + +try { + $file = $api->dbDnsDaily('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDnsDaily.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -903,16 +1585,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesDNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDnsWeekly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesDNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesDNSApi(new Client(), $config); + +try { + $file = $api->dbDnsWeekly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDnsWeekly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -922,16 +1622,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesDNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDnsMonthly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesDNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesDNSApi(new Client(), $config); + +try { + $file = $api->dbDnsMonthly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDnsMonthly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -943,16 +1661,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesSubdomainsApi(new GuzzleHttp\Client(), $config); -$result = $api->dbSubdomainsDaily((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesSubdomainsApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesSubdomainsApi(new Client(), $config); + +try { + $file = $api->dbSubdomainsDaily('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbSubdomainsDaily.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -962,16 +1698,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesSubdomainsApi(new GuzzleHttp\Client(), $config); -$result = $api->dbSubdomainsWeekly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesSubdomainsApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesSubdomainsApi(new Client(), $config); + +try { + $file = $api->dbSubdomainsWeekly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbSubdomainsWeekly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -981,16 +1735,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesSubdomainsApi(new GuzzleHttp\Client(), $config); -$result = $api->dbSubdomainsMonthly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesSubdomainsApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesSubdomainsApi(new Client(), $config); + +try { + $file = $api->dbSubdomainsMonthly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbSubdomainsMonthly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1002,16 +1774,31 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPGeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpCountryStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPGeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPGeolocationApi(new Client(), $config); + +try { + $result = $api->dbIpCountryStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1021,16 +1808,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPGeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpCountry((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPGeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPGeolocationApi(new Client(), $config); + +try { + $file = $api->dbIpCountry('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbIpCountry.zip'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1040,16 +1845,31 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPGeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpCityStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPGeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPGeolocationApi(new Client(), $config); + +try { + $result = $api->dbIpCityStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1059,16 +1879,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPGeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpCity((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPGeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPGeolocationApi(new Client(), $config); + +try { + $file = $api->dbIpCity('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbIpCity.zip'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1080,16 +1918,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesASNWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbAsnWhois((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesASNWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesASNWHOISApi(new Client(), $config); + +try { + $file = $api->dbAsnWhois('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbAsnWhois.json.gz'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1099,16 +1955,31 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesASNWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbAsnWhoisStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesASNWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesASNWHOISApi(new Client(), $config); + +try { + $result = $api->dbAsnWhoisStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1120,16 +1991,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpWhois((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPWHOISApi(new Client(), $config); + +try { + $file = $api->dbIpWhois('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbIpWhois.json.gz'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1139,16 +2028,31 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpWhoisStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPWHOISApi(new Client(), $config); + +try { + $result = $api->dbIpWhoisStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1160,16 +2064,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPSecurityApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpSecurity((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPSecurityApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPSecurityApi(new Client(), $config); + +try { + $file = $api->dbIpSecurity('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbIpSecurity.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1179,16 +2101,31 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPSecurityApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpSecurityStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPSecurityApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPSecurityApi(new Client(), $config); + +try { + $result = $api->dbIpSecurityStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1200,16 +2137,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedPhishing((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedPhishing('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedPhishing.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1219,16 +2174,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedPhishingSample(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedPhishingSample(); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedPhishingSample.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1238,16 +2211,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedMalware((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedMalware('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedMalware.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1257,16 +2248,34 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedMalwareSample(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedMalwareSample(); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedMalwareSample.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1276,16 +2285,34 @@ print_r($result); ```php setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); -$config = WhoisFreaks\Configuration::getDefaultConfiguration() - ->setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedSpam((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +try { + $file = $api->downloadThreatFeedSpam('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedSpam.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` @@ -1295,15 +2322,33 @@ print_r($result); ```php setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedSpamSample(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedSpamSample(); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedSpamSample.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} ``` diff --git a/docs/languages/python.md b/docs/languages/python.md index 9df028f..c446e1b 100644 --- a/docs/languages/python.md +++ b/docs/languages/python.md @@ -2,7 +2,7 @@ ## About -The official **WhoisFreaks Python SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Python with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to PyPI. +The official **WhoisFreaks Python SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Python with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to PyPI. **Keywords:** python whois api, python whois sdk, whoisfreaks python, python domain lookup, python dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api @@ -17,7 +17,7 @@ pip install whoisfreaks ## Build from Source -Prefer to build the SDK yourself instead of installing from PyPI? Clone the monorepo and build the Python package locally: +Prefer to build the SDK yourself instead of installing from PyPI? Clone the Python SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-python @@ -29,30 +29,36 @@ pip install -e . # editable local install A complete walkthrough from an empty directory to a running program: +1. Create a project folder with a virtual environment and install the SDK: + ```bash mkdir whoisfreaks-test && cd whoisfreaks-test python3 -m venv .venv -source .venv/bin/activate # Windows: .venv\Scripts\activate +source .venv/bin/activate # Windows: .venv\Scripts\activate pip install whoisfreaks ``` -Create `main.py`: +2. Create `main.py`: ```python -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi +import os + +import whoisfreaks -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.whois_live(domain_name="example.com") -print(result) +with whoisfreaks.ApiClient(config) as client: + record = whoisfreaks.WHOISApi(client).whois_live("whoisfreaks.com") + print("Domain: ", record.domain_name) + print("Created:", record.create_date) + print("Expires:", record.expiry_date) ``` -Run it: +3. Set your API key and run it: ```bash +export WHOISFREAKS_API_KEY="your_api_key" # PowerShell: $env:WHOISFREAKS_API_KEY="your_api_key" python main.py ``` @@ -61,20 +67,27 @@ python main.py See [Authentication](../authentication.md) for how to obtain a key. Minimal setup: ```python -"""Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi +"""Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisLive.py +""" +import json +import os + +import whoisfreaks -# Parameters for whoisLive (GET /v2.0/whois/live): -# - domainName (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.whois_live(domain_name="example.com") -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + # whois_live parameters: + # domain_name (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.whois_live("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ``` ## Endpoints @@ -88,20 +101,27 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, `GET /v2.0/whois/live` ```python -"""Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi +"""Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live -# Parameters for whoisLive (GET /v2.0/whois/live): -# - domainName (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisLive.py +""" +import json +import os -result = api.whois_live(domain_name="example.com") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + + # whois_live parameters: + # domain_name (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.whois_live("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ``` #### Bulk WHOIS Lookup @@ -109,22 +129,28 @@ print(result) `POST /v2.0/bulkwhois/live` ```python -"""Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi -from whoisfreaks.models.bulk_whois_request import BulkWhoisRequest +"""Bulk WHOIS Lookup: POST https://api.whoisfreaks.com/v2.0/bulkwhois/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkWhois.py +""" +import json +import os + +import whoisfreaks -# Parameters for bulkWhois (POST /v2.0/bulkwhois/live): -# - format (string (one of: json, xml), optional) -# - body: BulkWhoisRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -bulk_whois_request = BulkWhoisRequest() # populate fields as needed -result = api.bulk_whois(bulk_whois_request=bulk_whois_request) -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + # bulk_whois parameters: + # bulk_whois_request (BulkWhoisRequest, required): request body + # format (str, optional, keyword): one of json, xml; default "json" + body = whoisfreaks.BulkWhoisRequest(domain_names=["whoisfreaks.com", "jfreaks.com"]) + result = api.bulk_whois(body) + print(json.dumps(result.to_dict(), indent=2)) ``` #### Historical WHOIS records for a domain @@ -132,21 +158,27 @@ print(result) `GET /v2.0/whois/history` ```python -"""Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi +"""Historical WHOIS records for a domain: GET https://api.whoisfreaks.com/v2.0/whois/history -# Parameters for whoisHistory (GET /v2.0/whois/history): -# - domainName (string, required): Domain to fetch historical WHOIS records for -# - page (integer, optional): Page number -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisHistory.py +""" +import json +import os -result = api.whois_history(domain_name="example.com") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + + # whois_history parameters: + # domain_name (str, required): Domain to fetch historical WHOIS records for + # format (str, optional, keyword): one of json, xml + result = api.whois_history("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ``` #### Reverse WHOIS lookup by keyword @@ -154,21 +186,28 @@ print(result) `GET /v2.0/whois/reverse` ```python -"""Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi +"""Reverse WHOIS lookup by keyword: GET https://api.whoisfreaks.com/v2.0/whois/reverse + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisReverse.py +""" +import json +import os + +import whoisfreaks -# Parameters for whoisReverse (GET /v2.0/whois/reverse): -# - keyword (string, required): Keyword to search across WHOIS records -# - page (integer, optional): Page number -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.whois_reverse(keyword="value") -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + # whois_reverse parameters: + # keyword (str, required): Keyword to search across WHOIS records + # page (int, optional, keyword): Page number + # format (str, optional, keyword): one of json, xml + result = api.whois_reverse("whoisfreaks", page=1) + print(json.dumps(result.to_dict(), indent=2)) ``` ### DNS @@ -178,22 +217,29 @@ print(result) `GET /v2.0/dns/live` ```python -"""Runnable example: Live DNS Lookup (GET /v2.0/dns/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi +"""Live DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/live -# Parameters for dnsLive (GET /v2.0/dns/live): -# - domainName (string, required) -# - ipAddress (string, required): Use for PTR lookups -# - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsLive.py +""" +import json +import os -result = api.dns_live(domain_name="example.com", ip_address="8.8.8.8", var_type="value") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + + # dns_live parameters: + # type (str, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME; default "all" + # domain_name (str, optional, keyword) + # ip_address (str, optional, keyword): Use for PTR lookups + # format (str, optional, keyword): one of json, xml; default "json" + result = api.dns_live("A,MX,TXT", domain_name="whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ``` #### Historical DNS Lookup @@ -201,22 +247,29 @@ print(result) `GET /v2.0/dns/historical` ```python -"""Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi +"""Historical DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/historical + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsHistorical.py +""" +import json +import os + +import whoisfreaks -# Parameters for dnsHistorical (GET /v2.0/dns/historical): -# - domainName (string, required) -# - type (string, required) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.dns_historical(domain_name="example.com", var_type="value") -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + # dns_historical parameters: + # domain_name (str, required) + # type (str, required): default "all" + # page (int, optional, keyword): default 1 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.dns_historical("whoisfreaks.com", "A,MX,TXT", page=1) + print(json.dumps(result.to_dict(), indent=2)) ``` #### Reverse DNS Lookup @@ -224,23 +277,30 @@ print(result) `GET /v2.1/dns/reverse` ```python -"""Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi +"""Reverse DNS Lookup: GET https://api.whoisfreaks.com/v2.1/dns/reverse -# Parameters for dnsReverse (GET /v2.1/dns/reverse): -# - value (string, required): IP, CIDR, or record value -# - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) -# - exact (boolean, optional) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsReverse.py +""" +import json +import os -result = api.dns_reverse(value="value", var_type="a", exact=True) -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + + # dns_reverse parameters: + # value (str, required): IP, CIDR, or record value + # type (str, required): one of a, mx, cname, ns, aaaa, txt, soa + # exact (bool, optional, keyword): default True + # page (int, optional, keyword): default 1 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.dns_reverse("8.8.8.8", "a", page=1) + print(json.dumps(result.to_dict(), indent=2)) ``` #### Bulk DNS Lookup @@ -248,23 +308,29 @@ print(result) `POST /v2.0/dns/bulk/live` ```python -"""Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi -from whoisfreaks.models.dns_bulk_request import DnsBulkRequest +"""Bulk DNS Lookup: POST https://api.whoisfreaks.com/v2.0/dns/bulk/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsBulk.py +""" +import json +import os + +import whoisfreaks -# Parameters for dnsBulk (POST /v2.0/dns/bulk/live): -# - type (string, required) -# - format (string (one of: json, xml), optional) -# - body: DnsBulkRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -dns_bulk_request = DnsBulkRequest() # populate fields as needed -result = api.dns_bulk(var_type="value", dns_bulk_request=dns_bulk_request) -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + # dns_bulk parameters: + # type (str, required): default "all" + # dns_bulk_request (DnsBulkRequest, required): request body + # format (str, optional, keyword): one of json, xml; default "json" + body = whoisfreaks.DnsBulkRequest(domain_names=["whoisfreaks.com", "example.com"]) + result = api.dns_bulk("A,MX,TXT", body) + print(json.dumps(result.to_dict(), indent=2)) ``` ### Domain Availability @@ -274,22 +340,29 @@ print(result) `GET /v2.0/domain/availability` ```python -"""Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.domain_availability_api import DomainAvailabilityApi +"""Domain Availability Check with Suggestions: GET https://api.whoisfreaks.com/v2.0/domain/availability -# Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): -# - domain (string, required): The domain name to check -# - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. -# - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DomainAvailabilityApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DomainAvailabilityV2.py +""" +import json +import os -result = api.domain_availability_v2(domain="example.com") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DomainAvailabilityApi(client) + + # domain_availability_v2 parameters: + # domain (str, required): The domain name to check + # sug (bool, optional, keyword): Whether to return TLD suggestions alongside the queried domain; default False + # count (int, optional, keyword): Number of TLD suggestions to return when sug=true. Maximum is 100; default 5 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.domain_availability_v2("google.com", sug=True, count=5) + print(json.dumps(result.to_dict(), indent=2)) ``` #### Bulk Domain Availability Check @@ -297,23 +370,29 @@ print(result) `POST /v2.0/domain/availability` ```python -"""Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.domain_availability_api import DomainAvailabilityApi -from whoisfreaks.models.bulk_domain_availability_request import BulkDomainAvailabilityRequest +"""Bulk Domain Availability Check: POST https://api.whoisfreaks.com/v2.0/domain/availability + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkDomainAvailabilityV2.py +""" +import json +import os + +import whoisfreaks -# Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): -# - domain (string, optional): Required for TLD-mode bulk check (base domain). -# - format (string (one of: json, xml), optional) -# - body: BulkDomainAvailabilityRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DomainAvailabilityApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -bulk_domain_availability_request = BulkDomainAvailabilityRequest() # populate fields as needed -result = api.bulk_domain_availability_v2(bulk_domain_availability_request=bulk_domain_availability_request) -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DomainAvailabilityApi(client) + # bulk_domain_availability_v2 parameters: + # bulk_domain_availability_request (BulkDomainAvailabilityRequest, required): request body + # domain (str, optional, keyword): Required for TLD-mode bulk check (base domain) + # format (str, optional, keyword): one of json, xml; default "json" + body = whoisfreaks.BulkDomainAvailabilityRequest(domain_names=["whoisfreaks.com", "example.com"]) + result = api.bulk_domain_availability_v2(body) + print(json.dumps(result.to_dict(), indent=2)) ``` ### Typosquatting @@ -323,21 +402,28 @@ print(result) `GET /v3.0/domain/typos` ```python -"""Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.typosquatting_api import TyposquattingApi +"""Typosquatting Lookup: GET https://api.whoisfreaks.com/v3.0/domain/typos -# Parameters for typosquatting (GET /v3.0/domain/typos): -# - keyword (string, optional) -# - pattern (string, optional) -# - pageToken (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = TyposquattingApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python Typosquatting.py +""" +import json +import os -result = api.typosquatting() -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.TyposquattingApi(client) + + # typosquatting parameters: + # keyword (str, optional, keyword) + # pattern (str, optional, keyword) + # page_token (str, optional, keyword) + result = api.typosquatting(keyword="whoisfreaks") + print(json.dumps(result.to_dict(), indent=2)) ``` ### SSL @@ -347,22 +433,29 @@ print(result) `GET /v1.0/ssl/live` ```python -"""Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ssl_api import SSLApi +"""SSL Certificate Lookup: GET https://api.whoisfreaks.com/v1.0/ssl/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python SslLookup.py +""" +import json +import os + +import whoisfreaks -# Parameters for sslLookup (GET /v1.0/ssl/live): -# - domainName (string, required) -# - chain (boolean, optional) -# - sslRaw (boolean, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = SSLApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.ssl_lookup(domain_name="example.com") -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.SSLApi(client) + # ssl_lookup parameters: + # domain_name (str, required) + # chain (bool, optional, keyword): default False + # ssl_raw (bool, optional, keyword): default False + # format (str, optional, keyword): one of json, xml; default "json" + result = api.ssl_lookup("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) ``` ### Geolocation @@ -372,19 +465,26 @@ print(result) `GET /v1.0/geolocation` ```python -"""Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.geolocation_api import GeolocationApi +"""IP Geolocation Lookup: GET https://api.whoisfreaks.com/v1.0/geolocation -# Parameters for geolocation (GET /v1.0/geolocation): -# - ip (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = GeolocationApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python Geolocation.py +""" +import json +import os -result = api.geolocation(ip="8.8.8.8") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.GeolocationApi(client) + + # geolocation parameters: + # ip (str, required) + result = api.geolocation("8.8.8.8") + print(json.dumps(result.to_dict(), indent=2)) ``` #### Bulk IP Geolocation @@ -392,21 +492,27 @@ print(result) `POST /v1.0/geolocation` ```python -"""Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.geolocation_api import GeolocationApi -from whoisfreaks.models.bulk_geolocation_request import BulkGeolocationRequest +"""Bulk IP Geolocation: POST https://api.whoisfreaks.com/v1.0/geolocation + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkGeolocation.py +""" +import json +import os + +import whoisfreaks -# Parameters for bulkGeolocation (POST /v1.0/geolocation): -# - body: BulkGeolocationRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = GeolocationApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -bulk_geolocation_request = BulkGeolocationRequest() # populate fields as needed -result = api.bulk_geolocation(bulk_geolocation_request=bulk_geolocation_request) -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.GeolocationApi(client) + # bulk_geolocation parameters: + # bulk_geolocation_request (BulkGeolocationRequest, required): request body + body = whoisfreaks.BulkGeolocationRequest(ips=["8.8.8.8", "1.1.1.1"]) + results = api.bulk_geolocation(body) + print(json.dumps([item.to_dict() for item in results], indent=2)) ``` ### Subdomains @@ -416,25 +522,31 @@ print(result) `GET /v1.0/subdomains` ```python -"""Runnable example: Subdomains Lookup (GET /v1.0/subdomains).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.subdomains_api import SubdomainsApi +"""Subdomains Lookup: GET https://api.whoisfreaks.com/v1.0/subdomains -# Parameters for subdomains (GET /v1.0/subdomains): -# - domain (string, required) -# - after (string, optional) -# - before (string, optional) -# - status (string (one of: active, inactive), optional) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = SubdomainsApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python Subdomains.py +""" +import json +import os -result = api.subdomains(domain="example.com", after="2000-01-01", before=str(date.today())) -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.SubdomainsApi(client) + + # subdomains parameters: + # domain (str, required) + # after (datetime.date, optional, keyword) + # before (datetime.date, optional, keyword) + # status (str, optional, keyword): one of active, inactive + # page (int, optional, keyword): default 1 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.subdomains("whoisfreaks.com", page=1) + print(json.dumps(result.to_dict(), indent=2)) ``` ### IP Reputation @@ -444,19 +556,26 @@ print(result) `GET /v1.0/security` ```python -"""Runnable example: IP Reputation Lookup (GET /v1.0/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ip_reputation_api import IPReputationApi +"""IP Reputation Lookup: GET https://api.whoisfreaks.com/v1.0/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python IpReputation.py +""" +import json +import os + +import whoisfreaks -# Parameters for ipReputation (GET /v1.0/security): -# - ip (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = IPReputationApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.ip_reputation(ip="8.8.8.8") -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.IPReputationApi(client) + # ip_reputation parameters: + # ip (str, required) + result = api.ip_reputation("8.8.8.8") + print(json.dumps(result.to_dict(), indent=2)) ``` #### Bulk IP Reputation @@ -464,21 +583,27 @@ print(result) `POST /v1.0/security` ```python -"""Runnable example: Bulk IP Reputation (POST /v1.0/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ip_reputation_api import IPReputationApi -from whoisfreaks.models.bulk_ip_reputation_request import BulkIpReputationRequest +"""Bulk IP Reputation: POST https://api.whoisfreaks.com/v1.0/security -# Parameters for bulkIpReputation (POST /v1.0/security): -# - body: BulkIpReputationRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = IPReputationApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkIpReputation.py +""" +import json +import os -bulk_ip_reputation_request = BulkIpReputationRequest() # populate fields as needed -result = api.bulk_ip_reputation(bulk_ip_reputation_request=bulk_ip_reputation_request) -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.IPReputationApi(client) + + # bulk_ip_reputation parameters: + # bulk_geolocation_request (BulkGeolocationRequest, required): request body + body = whoisfreaks.BulkGeolocationRequest(ips=["8.8.8.8", "1.1.1.1"]) + results = api.bulk_ip_reputation(body) + print(json.dumps([item.to_dict() for item in results], indent=2)) ``` ### Domain Reputation @@ -488,20 +613,27 @@ print(result) `GET /v1/domain/security` ```python -"""Runnable example: Domain Reputation Lookup (GET /v1/domain/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.domain_reputation_api import DomainReputationApi +"""Domain Reputation Lookup: GET https://api.whoisfreaks.com/v1/domain/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DomainReputation.py +""" +import json +import os + +import whoisfreaks -# Parameters for domainReputation (GET /v1/domain/security): -# - domainName (string, required): The domain name to assess -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DomainReputationApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.domain_reputation(domain_name="example.com") -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DomainReputationApi(client) + # domain_reputation parameters: + # domain_name (str, required): The domain name to assess + # format (str, optional, keyword): one of json, xml; default "json" + result = api.domain_reputation("amazon.com") + print(json.dumps(result.to_dict(), indent=2)) ``` ### ASN WHOIS @@ -511,20 +643,27 @@ print(result) `GET /v2.0/asn-whois` ```python -"""Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.asnwhois_api import ASNWHOISApi +"""ASN WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/asn-whois -# Parameters for asnWhois (GET /v2.0/asn-whois): -# - asn (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = ASNWHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python AsnWhois.py +""" +import json +import os -result = api.asn_whois(asn="AS15169") -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.ASNWHOISApi(client) + + # asn_whois parameters: + # asn (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.asn_whois("as15169") + print(json.dumps(result.to_dict(), indent=2)) ``` ### IP WHOIS @@ -534,20 +673,27 @@ print(result) `GET /v1.0/ip-whois` ```python -"""Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ipwhois_api import IPWHOISApi +"""IP WHOIS Lookup: GET https://api.whoisfreaks.com/v1.0/ip-whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python IpWhois.py +""" +import json +import os + +import whoisfreaks -# Parameters for ipWhois (GET /v1.0/ip-whois): -# - ip (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = IPWHOISApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.ip_whois(ip="8.8.8.8") -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.IPWHOISApi(client) + # ip_whois parameters: + # ip (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.ip_whois("8.8.8.8") + print(json.dumps(result.to_dict(), indent=2)) ``` ### Account @@ -557,19 +703,24 @@ print(result) `GET /v1.0/api-key/rotate` ```python -"""Runnable example: Rotate API Key (GET /v1.0/api-key/rotate).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.account_api import AccountApi +"""Rotate API Key: GET https://api.whoisfreaks.com/v1.0/api-key/rotate -# Parameters for rotateApiKey (GET /v1.0/api-key/rotate): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = AccountApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python RotateApiKey.py +""" +import os -result = api.rotate_api_key() -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.AccountApi(client) + + # rotate_api_key takes no parameters. + new_key = api.rotate_api_key() # use this key from now on + print("New API key:", new_key) ``` #### Account Usage @@ -577,19 +728,25 @@ print(result) `GET /v1.0/whoisapi/usage` ```python -"""Runnable example: Account Usage (GET /v1.0/whoisapi/usage).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.account_api import AccountApi +"""Account Usage: GET https://api.whoisfreaks.com/v1.0/whoisapi/usage + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python AccountUsage.py +""" +import json +import os + +import whoisfreaks -# Parameters for accountUsage (GET /v1.0/whoisapi/usage): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = AccountApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.account_usage() -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.AccountApi(client) + # account_usage takes no parameters. + result = api.account_usage() + print(json.dumps(result.to_dict(), indent=2)) ``` #### Database File Status (Public) @@ -597,19 +754,24 @@ print(result) `GET /v3.4/status` ```python -"""Runnable example: Database File Status (Public) (GET /v3.4/status).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.account_api import AccountApi +"""Database File Status (Public): GET https://files.whoisfreaks.com/v3.4/status -# Parameters for databaseFileStatus (GET /v3.4/status): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = AccountApi(ApiClient(config)) +Run it (public endpoint, no API key needed): + python DatabaseFileStatus.py +""" +import json -result = api.database_file_status() -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +# Public endpoint: no API key needed. + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.AccountApi(client) + + # database_file_status takes no parameters. + result = api.database_file_status() + print(json.dumps(result.to_dict(), indent=2)) ``` ### Databases - Newly Registered @@ -619,25 +781,31 @@ print(result) `GET /v3.1/download/domainer/gtld` ```python -"""Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered gTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyGtld.py +""" +import os +from datetime import date + +import whoisfreaks -# Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -data = api.db_newly_gtld(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyGtld.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyGtld.gz") +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + # db_newly_gtld parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + data = api.db_newly_gtld(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyGtld.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Newly Registered ccTLD (CSV) @@ -645,25 +813,31 @@ print(f"saved {len(data)} bytes to dbNewlyGtld.gz") `GET /v3.1/download/domainer/cctld` ```python -"""Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered ccTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld -# Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyCctld.py +""" +import os +from datetime import date -data = api.db_newly_cctld(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyCctld.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyCctld.gz") +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_cctld parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + data = api.db_newly_cctld(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyCctld.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Newly Registered gTLD Cleaned WHOIS (CSV) @@ -671,23 +845,29 @@ print(f"saved {len(data)} bytes to dbNewlyCctld.gz") `GET /v3.1/download/domainer/gtld/cleaned` ```python -"""Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered gTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld/cleaned + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyGtldCleaned.py +""" +import os +from datetime import date + +import whoisfreaks -# Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -data = api.db_newly_gtld_cleaned(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyGtldCleaned.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyGtldCleaned.gz") +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + # db_newly_gtld_cleaned parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_newly_gtld_cleaned(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyGtldCleaned.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Newly Registered ccTLD Cleaned WHOIS (CSV) @@ -695,23 +875,29 @@ print(f"saved {len(data)} bytes to dbNewlyGtldCleaned.gz") `GET /v3.1/download/domainer/cctld/cleaned` ```python -"""Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered ccTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld/cleaned -# Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyCctldCleaned.py +""" +import os +from datetime import date -data = api.db_newly_cctld_cleaned(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyCctldCleaned.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyCctldCleaned.gz") +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_cctld_cleaned parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_newly_cctld_cleaned(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyCctldCleaned.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Newly Registered gTLD (JSON) @@ -719,21 +905,28 @@ print(f"saved {len(data)} bytes to dbNewlyCctldCleaned.gz") `GET /v3.1/domains/newly/gtld` ```python -"""Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered gTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/gtld + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyGtldJson.py +""" +import os +from datetime import date + +import whoisfreaks -# Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request -result = api.db_newly_gtld_json(var_date=str(date.today() - timedelta(days=1))) -print(result) +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + # db_newly_gtld_json parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + domains = api.db_newly_gtld_json(var_date=date(2026, 10, 1)) + print(f"{len(domains)} domains") + print("\n".join(domains[:10])) ``` #### Newly Registered ccTLD (JSON) @@ -741,21 +934,28 @@ print(result) `GET /v3.1/domains/newly/cctld` ```python -"""Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered ccTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/cctld -# Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyCctldJson.py +""" +import os +from datetime import date -result = api.db_newly_cctld_json(var_date=str(date.today() - timedelta(days=1))) -print(result) +import whoisfreaks +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_cctld_json parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + domains = api.db_newly_cctld_json(var_date=date(2026, 10, 1)) + print(f"{len(domains)} domains") + print("\n".join(domains[:10])) ``` #### Newly Registered With DNS @@ -763,23 +963,29 @@ print(result) `GET /v3.1/download/domainer/newly/dns` ```python -"""Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered With DNS: GET https://files.whoisfreaks.com/v3.1/download/domainer/newly/dns + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyDns.py +""" +import os +from datetime import date -# Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +import whoisfreaks -data = api.db_newly_dns(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyDns.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyDns.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_dns parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_newly_dns(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyDns.json" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` ### Databases - Expiring & Dropped @@ -789,24 +995,30 @@ print(f"saved {len(data)} bytes to dbNewlyDns.gz") `GET /v3.1/download/domainer/expired` ```python -"""Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Expiring Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbExpired.py +""" +import os +from datetime import date -# Parameters for dbExpired (GET /v3.1/download/domainer/expired): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +import whoisfreaks -data = api.db_expired(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbExpired.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbExpired.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_expired parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_expired(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbExpired.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Expiring Cleaned WHOIS @@ -814,23 +1026,29 @@ print(f"saved {len(data)} bytes to dbExpired.gz") `GET /v3.1/download/domainer/expired/cleaned` ```python -"""Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Expiring Cleaned WHOIS: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired/cleaned + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbExpiredCleaned.py +""" +import os +from datetime import date -# Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +import whoisfreaks -data = api.db_expired_cleaned(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbExpiredCleaned.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbExpiredCleaned.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_expired_cleaned parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_expired_cleaned(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbExpiredCleaned.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Dropped Domains @@ -838,24 +1056,30 @@ print(f"saved {len(data)} bytes to dbExpiredCleaned.gz") `GET /v3.1/download/domainer/dropped` ```python -"""Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Dropped Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/dropped + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDropped.py +""" +import os +from datetime import date -# Parameters for dbDropped (GET /v3.1/download/domainer/dropped): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +import whoisfreaks -data = api.db_dropped(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDropped.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDropped.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_dropped parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dropped(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDropped.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Dropped Domains (JSON) @@ -863,21 +1087,28 @@ print(f"saved {len(data)} bytes to dbDropped.gz") `GET /v3.1/domains/dropped` ```python -"""Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Dropped Domains (JSON): GET https://files.whoisfreaks.com/v3.1/domains/dropped + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDroppedJson.py +""" +import os +from datetime import date -# Parameters for dbDroppedJson (GET /v3.1/domains/dropped): -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +import whoisfreaks -result = api.db_dropped_json(var_date=str(date.today() - timedelta(days=1))) -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_dropped_json parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + domains = api.db_dropped_json(var_date=date(2026, 10, 1)) + print(f"{len(domains)} domains") + print("\n".join(domains[:10])) ``` #### Dropped With Backlinks @@ -885,24 +1116,30 @@ print(result) `GET /v3.3/download/domainer/dropped/backlinks` ```python -"""Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Dropped With Backlinks: GET https://files.whoisfreaks.com/v3.3/download/domainer/dropped/backlinks + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDroppedBacklinks.py +""" +import os +from datetime import date -# Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): -# - whois (boolean, optional) -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +import whoisfreaks -data = api.db_dropped_backlinks(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDroppedBacklinks.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDroppedBacklinks.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_dropped_backlinks parameters: + # whois (bool, optional, keyword) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dropped_backlinks(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDroppedBacklinks.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` ### Databases - WHOIS @@ -912,23 +1149,29 @@ print(f"saved {len(data)} bytes to dbDroppedBacklinks.gz") `GET /v3.3/download/dbupdate/daily/domains/whois` ```python -"""Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_whois_api import DatabasesWHOISApi +"""WHOIS Database Daily: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/daily/domains/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbWhoisDaily.py +""" +import os +from datetime import date -# Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesWHOISApi(ApiClient(config)) +import whoisfreaks -data = api.db_whois_daily(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbWhoisDaily.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbWhoisDaily.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesWHOISApi(client) + + # db_whois_daily parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_whois_daily(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbWhoisDaily.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### WHOIS Database Weekly @@ -936,23 +1179,29 @@ print(f"saved {len(data)} bytes to dbWhoisDaily.gz") `GET /v3.3/download/dbupdate/weekly/domains/whois` ```python -"""Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_whois_api import DatabasesWHOISApi +"""WHOIS Database Weekly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/weekly/domains/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbWhoisWeekly.py +""" +import os +from datetime import date -# Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesWHOISApi(ApiClient(config)) +import whoisfreaks -data = api.db_whois_weekly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbWhoisWeekly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbWhoisWeekly.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesWHOISApi(client) + + # db_whois_weekly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_whois_weekly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbWhoisWeekly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### WHOIS Database Monthly @@ -960,23 +1209,29 @@ print(f"saved {len(data)} bytes to dbWhoisWeekly.gz") `GET /v3.3/download/dbupdate/monthly/domains/whois` ```python -"""Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_whois_api import DatabasesWHOISApi +"""WHOIS Database Monthly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/monthly/domains/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbWhoisMonthly.py +""" +import os +from datetime import date -# Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesWHOISApi(ApiClient(config)) +import whoisfreaks -data = api.db_whois_monthly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbWhoisMonthly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbWhoisMonthly.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesWHOISApi(client) + + # db_whois_monthly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_whois_monthly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbWhoisMonthly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` ### Databases - DNS @@ -986,23 +1241,29 @@ print(f"saved {len(data)} bytes to dbWhoisMonthly.gz") `GET /v3.2/download/dbupdate/daily/dns` ```python -"""Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_dns_api import DatabasesDNSApi +"""DNS Database Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/dns + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDnsDaily.py +""" +import os +from datetime import date -# Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesDNSApi(ApiClient(config)) +import whoisfreaks -data = api.db_dns_daily(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDnsDaily.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDnsDaily.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesDNSApi(client) + + # db_dns_daily parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dns_daily(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDnsDaily.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### DNS Database Weekly @@ -1010,23 +1271,29 @@ print(f"saved {len(data)} bytes to dbDnsDaily.gz") `GET /v3.2/download/dbupdate/weekly/dns` ```python -"""Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_dns_api import DatabasesDNSApi +"""DNS Database Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/dns + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDnsWeekly.py +""" +import os +from datetime import date -# Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesDNSApi(ApiClient(config)) +import whoisfreaks -data = api.db_dns_weekly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDnsWeekly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDnsWeekly.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesDNSApi(client) + + # db_dns_weekly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dns_weekly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDnsWeekly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### DNS Database Monthly @@ -1034,23 +1301,29 @@ print(f"saved {len(data)} bytes to dbDnsWeekly.gz") `GET /v3.2/download/dbupdate/monthly/dns` ```python -"""Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_dns_api import DatabasesDNSApi +"""DNS Database Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/dns + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDnsMonthly.py +""" +import os +from datetime import date -# Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesDNSApi(ApiClient(config)) +import whoisfreaks -data = api.db_dns_monthly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDnsMonthly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDnsMonthly.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesDNSApi(client) + + # db_dns_monthly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dns_monthly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDnsMonthly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` ### Databases - Subdomains @@ -1060,23 +1333,29 @@ print(f"saved {len(data)} bytes to dbDnsMonthly.gz") `GET /v3.2/download/dbupdate/daily/subdomains` ```python -"""Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_subdomains_api import DatabasesSubdomainsApi +"""Subdomains Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/subdomains + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbSubdomainsDaily.py +""" +import os +from datetime import date -# Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesSubdomainsApi(ApiClient(config)) +import whoisfreaks -data = api.db_subdomains_daily(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbSubdomainsDaily.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbSubdomainsDaily.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesSubdomainsApi(client) + + # db_subdomains_daily parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_subdomains_daily(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbSubdomainsDaily.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Subdomains Weekly @@ -1084,23 +1363,29 @@ print(f"saved {len(data)} bytes to dbSubdomainsDaily.gz") `GET /v3.2/download/dbupdate/weekly/subdomains` ```python -"""Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_subdomains_api import DatabasesSubdomainsApi +"""Subdomains Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/subdomains + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbSubdomainsWeekly.py +""" +import os +from datetime import date -# Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesSubdomainsApi(ApiClient(config)) +import whoisfreaks -data = api.db_subdomains_weekly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbSubdomainsWeekly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbSubdomainsWeekly.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesSubdomainsApi(client) + + # db_subdomains_weekly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_subdomains_weekly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbSubdomainsWeekly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Subdomains Monthly @@ -1108,23 +1393,29 @@ print(f"saved {len(data)} bytes to dbSubdomainsWeekly.gz") `GET /v3.2/download/dbupdate/monthly/subdomains` ```python -"""Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_subdomains_api import DatabasesSubdomainsApi +"""Subdomains Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/subdomains + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbSubdomainsMonthly.py +""" +import os +from datetime import date -# Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesSubdomainsApi(ApiClient(config)) +import whoisfreaks -data = api.db_subdomains_monthly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbSubdomainsMonthly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbSubdomainsMonthly.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesSubdomainsApi(client) + + # db_subdomains_monthly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_subdomains_monthly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbSubdomainsMonthly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` ### Databases - IP Geolocation @@ -1134,19 +1425,25 @@ print(f"saved {len(data)} bytes to dbSubdomainsMonthly.gz") `GET /v3.3/status/snapshot/ip/country` ```python -"""Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi +"""IP to Country Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/country + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCountryStatus.py +""" +import json +import os -# Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) +import whoisfreaks -result = api.db_ip_country_status() -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_country_status takes no parameters. + result = api.db_ip_country_status() + print(json.dumps(result.to_dict(), indent=2)) ``` #### IP to Country Snapshot @@ -1154,23 +1451,29 @@ print(result) `GET /v3.3/download/snapshot/ip/country` ```python -"""Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi +"""IP to Country Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/country + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCountry.py +""" +import os +from datetime import date -# Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) +import whoisfreaks -data = api.db_ip_country(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpCountry.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpCountry.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_country parameters: + # var_date (datetime.date, required) + data = api.db_ip_country(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpCountry.zip" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### IP to City Snapshot Status @@ -1178,19 +1481,25 @@ print(f"saved {len(data)} bytes to dbIpCountry.gz") `GET /v3.3/status/snapshot/ip/city` ```python -"""Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi +"""IP to City Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/city + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCityStatus.py +""" +import json +import os -# Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) +import whoisfreaks -result = api.db_ip_city_status() -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_city_status takes no parameters. + result = api.db_ip_city_status() + print(json.dumps(result.to_dict(), indent=2)) ``` #### IP to City Snapshot @@ -1198,23 +1507,29 @@ print(result) `GET /v3.3/download/snapshot/ip/city` ```python -"""Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi +"""IP to City Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/city + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCity.py +""" +import os +from datetime import date -# Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) +import whoisfreaks -data = api.db_ip_city(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpCity.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpCity.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_city parameters: + # var_date (datetime.date, required) + data = api.db_ip_city(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpCity.zip" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` ### Databases - ASN WHOIS @@ -1224,23 +1539,29 @@ print(f"saved {len(data)} bytes to dbIpCity.gz") `GET /v3.3/download/snapshot/asn/whois` ```python -"""Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_asnwhois_api import DatabasesASNWHOISApi +"""ASN WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/asn/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbAsnWhois.py +""" +import os +from datetime import date -# Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesASNWHOISApi(ApiClient(config)) +import whoisfreaks -data = api.db_asn_whois(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbAsnWhois.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbAsnWhois.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesASNWHOISApi(client) + + # db_asn_whois parameters: + # var_date (datetime.date, required) + data = api.db_asn_whois(date(2026, 10, 1)) # the file's raw bytes + path = "DbAsnWhois.json.gz" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### ASN WHOIS Snapshot Status @@ -1248,19 +1569,25 @@ print(f"saved {len(data)} bytes to dbAsnWhois.gz") `GET /v3.3/status/snapshot/asn/whois` ```python -"""Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_asnwhois_api import DatabasesASNWHOISApi +"""ASN WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/asn/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbAsnWhoisStatus.py +""" +import json +import os -# Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesASNWHOISApi(ApiClient(config)) +import whoisfreaks -result = api.db_asn_whois_status() -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesASNWHOISApi(client) + + # db_asn_whois_status takes no parameters. + result = api.db_asn_whois_status() + print(json.dumps(result.to_dict(), indent=2)) ``` ### Databases - IP WHOIS @@ -1270,23 +1597,29 @@ print(result) `GET /v3.3/download/snapshot/ip/whois` ```python -"""Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ipwhois_api import DatabasesIPWHOISApi +"""IP WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpWhois.py +""" +import os +from datetime import date -# Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPWHOISApi(ApiClient(config)) +import whoisfreaks -data = api.db_ip_whois(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpWhois.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpWhois.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPWHOISApi(client) + + # db_ip_whois parameters: + # var_date (datetime.date, required) + data = api.db_ip_whois(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpWhois.json.gz" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### IP WHOIS Snapshot Status @@ -1294,19 +1627,25 @@ print(f"saved {len(data)} bytes to dbIpWhois.gz") `GET /v3.3/status/snapshot/ip/whois` ```python -"""Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ipwhois_api import DatabasesIPWHOISApi +"""IP WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpWhoisStatus.py +""" +import json +import os -# Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPWHOISApi(ApiClient(config)) +import whoisfreaks -result = api.db_ip_whois_status() -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPWHOISApi(client) + + # db_ip_whois_status takes no parameters. + result = api.db_ip_whois_status() + print(json.dumps(result.to_dict(), indent=2)) ``` ### Databases - IP Security @@ -1316,23 +1655,29 @@ print(result) `GET /v3.3/download/snapshot/ip/security` ```python -"""Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_security_api import DatabasesIPSecurityApi +"""IP Security Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpSecurity.py +""" +import os +from datetime import date -# Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPSecurityApi(ApiClient(config)) +import whoisfreaks -data = api.db_ip_security(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpSecurity.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpSecurity.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPSecurityApi(client) + + # db_ip_security parameters: + # var_date (datetime.date, required) + data = api.db_ip_security(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpSecurity.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### IP Security Snapshot Status @@ -1340,19 +1685,25 @@ print(f"saved {len(data)} bytes to dbIpSecurity.gz") `GET /v3.3/status/snapshot/ip/security` ```python -"""Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_security_api import DatabasesIPSecurityApi +"""IP Security Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpSecurityStatus.py +""" +import json +import os -# Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPSecurityApi(ApiClient(config)) +import whoisfreaks -result = api.db_ip_security_status() -print(result) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPSecurityApi(client) + + # db_ip_security_status takes no parameters. + result = api.db_ip_security_status() + print(json.dumps(result.to_dict(), indent=2)) ``` ### Databases - Threat Feed @@ -1362,23 +1713,28 @@ print(result) `GET /v3.4/download/threat-feed/phishing` ```python -"""Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi +"""Download the daily phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedPhishing.py +""" +import os -# Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) +import whoisfreaks -data = api.download_threat_feed_phishing(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("downloadThreatFeedPhishing.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedPhishing.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_phishing parameters: + # var_date (str, optional, keyword): Feed date (yyyy-MM-dd); omit for the full dump of the feed + data = api.download_threat_feed_phishing(var_date="2026-10-01") # the file's raw bytes + path = "DownloadThreatFeedPhishing.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Download a sample of the phishing threat feed (CSV) @@ -1386,22 +1742,27 @@ print(f"saved {len(data)} bytes to downloadThreatFeedPhishing.gz") `GET /v3.4/download/threat-feed/phishing/sample` ```python -"""Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi +"""Download a sample of the phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing/sample + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedPhishingSample.py +""" +import os -# Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) +import whoisfreaks -data = api.download_threat_feed_phishing_sample() # bytes -with open("downloadThreatFeedPhishingSample.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedPhishingSample.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_phishing_sample takes no parameters. + data = api.download_threat_feed_phishing_sample() # the file's raw bytes + path = "DownloadThreatFeedPhishingSample.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Download the daily malware threat feed (CSV) @@ -1409,23 +1770,28 @@ print(f"saved {len(data)} bytes to downloadThreatFeedPhishingSample.gz") `GET /v3.4/download/threat-feed/malware` ```python -"""Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi +"""Download the daily malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedMalware.py +""" +import os -# Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) +import whoisfreaks -data = api.download_threat_feed_malware(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("downloadThreatFeedMalware.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedMalware.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_malware parameters: + # var_date (str, optional, keyword): Feed date (yyyy-MM-dd); omit for the full dump of the feed + data = api.download_threat_feed_malware(var_date="2026-10-01") # the file's raw bytes + path = "DownloadThreatFeedMalware.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Download a sample of the malware threat feed (CSV) @@ -1433,22 +1799,27 @@ print(f"saved {len(data)} bytes to downloadThreatFeedMalware.gz") `GET /v3.4/download/threat-feed/malware/sample` ```python -"""Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi +"""Download a sample of the malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware/sample + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedMalwareSample.py +""" +import os -# Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) +import whoisfreaks -data = api.download_threat_feed_malware_sample() # bytes -with open("downloadThreatFeedMalwareSample.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedMalwareSample.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_malware_sample takes no parameters. + data = api.download_threat_feed_malware_sample() # the file's raw bytes + path = "DownloadThreatFeedMalwareSample.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Download the daily spam threat feed (CSV) @@ -1456,23 +1827,28 @@ print(f"saved {len(data)} bytes to downloadThreatFeedMalwareSample.gz") `GET /v3.4/download/threat-feed/spam` ```python -"""Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi +"""Download the daily spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedSpam.py +""" +import os -# Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) +import whoisfreaks -data = api.download_threat_feed_spam(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("downloadThreatFeedSpam.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedSpam.gz") +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_spam parameters: + # var_date (str, optional, keyword): Feed date (yyyy-MM-dd); omit for the full dump of the feed + data = api.download_threat_feed_spam(var_date="2026-10-01") # the file's raw bytes + path = "DownloadThreatFeedSpam.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` #### Download a sample of the spam threat feed (CSV) @@ -1480,20 +1856,25 @@ print(f"saved {len(data)} bytes to downloadThreatFeedSpam.gz") `GET /v3.4/download/threat-feed/spam/sample` ```python -"""Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_spam_sample() # bytes -with open("downloadThreatFeedSpamSample.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedSpamSample.gz") +"""Download a sample of the spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam/sample + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedSpamSample.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + # download_threat_feed_spam_sample takes no parameters. + data = api.download_threat_feed_spam_sample() # the file's raw bytes + path = "DownloadThreatFeedSpamSample.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") ``` diff --git a/docs/languages/ruby.md b/docs/languages/ruby.md index 1afa106..fc09aca 100644 --- a/docs/languages/ruby.md +++ b/docs/languages/ruby.md @@ -2,7 +2,7 @@ ## About -The official **WhoisFreaks Ruby SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Ruby with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to RubyGems. +The official **WhoisFreaks Ruby SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Ruby with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to RubyGems. **Keywords:** ruby whois api, ruby whois sdk, whoisfreaks ruby, ruby domain lookup, ruby dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api @@ -17,7 +17,7 @@ gem install whoisfreaks ## Build from Source -Prefer to build the SDK yourself instead of installing from RubyGems? Clone the monorepo and build the Ruby package locally: +Prefer to build the SDK yourself instead of installing from RubyGems? Clone the Ruby SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-ruby @@ -30,29 +30,50 @@ gem install ./whoisfreaks-*.gem A complete walkthrough from an empty directory to a running program: +You need Ruby 2.7 or later and Bundler. + +1. Create a project directory: + ```bash mkdir whoisfreaks-test && cd whoisfreaks-test -gem install whoisfreaks ``` -Create `main.rb`: +2. Create a `Gemfile` that pins the SDK: ```ruby -require 'whoisfreaks' +source "https://rubygems.org" +gem "whoisfreaks", "~> 0.23.0" +``` + +3. Install it: + +```bash +bundle install +``` + +4. Create `main.rb`: + +```ruby +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end -api = WhoisFreaks::WhoisApi.new -result = api.whois_live("example.com") -puts result +record = WhoisFreaks::WHOISApi.new.whois_live("whoisfreaks.com") + +puts "Registrar: #{record.domain_registrar&.registrar_name}" +puts "Created: #{record.create_date}" +puts "Expires: #{record.expiry_date}" ``` -Run it: +5. Set your API key and run it: ```bash -ruby main.rb +export WHOISFREAKS_API_KEY="your_api_key" +bundle exec ruby main.rb ``` ## Configure @@ -60,19 +81,29 @@ ruby main.rb See [Authentication](../authentication.md) for how to obtain a key. Minimal setup: ```ruby -# Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +# Live WHOIS Lookup +# # Parameters for whoisLive (GET /v2.0/whois/live): -# - domainName (string, required) +# - domain_name (string, required) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.whois_live("example.com") -puts result + +begin + result = api.whois_live("whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -87,19 +118,29 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, `GET /v2.0/whois/live` ```ruby -# Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +# Live WHOIS Lookup +# # Parameters for whoisLive (GET /v2.0/whois/live): -# - domainName (string, required) +# - domain_name (string, required) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.whois_live("example.com") -puts result + +begin + result = api.whois_live("whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -108,19 +149,31 @@ puts result `POST /v2.0/bulkwhois/live` ```ruby -# Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +# Bulk WHOIS Lookup +# # Parameters for bulkWhois (POST /v2.0/bulkwhois/live): # - format (string (one of: json, xml), optional) -# - body: BulkWhoisRequest (required) -- request body object -require 'whoisfreaks' +# - body: BulkWhoisRequest (required): request body object + +require "json" +require "whoisfreaks" +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.bulk_whois(WhoisFreaks::BulkWhoisRequest.new) -puts result + +request = WhoisFreaks::BulkWhoisRequest.new(domain_names: ["whoisfreaks.com", "jfreaks.com"]) + +begin + result = api.bulk_whois(request) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -129,20 +182,29 @@ puts result `GET /v2.0/whois/history` ```ruby -# Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +# Historical WHOIS records for a domain +# # Parameters for whoisHistory (GET /v2.0/whois/history): -# - domainName (string, required): Domain to fetch historical WHOIS records for -# - page (integer, optional): Page number +# - domain_name (string, required): Domain to fetch historical WHOIS records for # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.whois_history("example.com") -puts result + +begin + result = api.whois_history("whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -151,20 +213,30 @@ puts result `GET /v2.0/whois/reverse` ```ruby -# Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +# Reverse WHOIS lookup by keyword +# # Parameters for whoisReverse (GET /v2.0/whois/reverse): # - keyword (string, required): Keyword to search across WHOIS records # - page (integer, optional): Page number # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.whois_reverse("value") -puts result + +begin + result = api.whois_reverse("whoisfreaks", page: 1) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -175,21 +247,31 @@ puts result `GET /v2.0/dns/live` ```ruby -# Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +# Live DNS Lookup +# # Parameters for dnsLive (GET /v2.0/dns/live): -# - domainName (string, required) -# - ipAddress (string, required): Use for PTR lookups +# - domain_name (string, optional) +# - ip_address (string, optional): Use for PTR lookups # - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DNSApi.new -result = api.dns_live("example.com", "8.8.8.8", "value") -puts result + +begin + result = api.dns_live("A,MX,TXT", domain_name: "whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -198,21 +280,31 @@ puts result `GET /v2.0/dns/historical` ```ruby -# Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +# Historical DNS Lookup +# # Parameters for dnsHistorical (GET /v2.0/dns/historical): -# - domainName (string, required) +# - domain_name (string, required) # - type (string, required) # - page (integer, optional) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DNSApi.new -result = api.dns_historical("example.com", "value") -puts result + +begin + result = api.dns_historical("whoisfreaks.com", "A,MX,TXT", page: 1) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -221,22 +313,32 @@ puts result `GET /v2.1/dns/reverse` ```ruby -# Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +# Reverse DNS Lookup +# # Parameters for dnsReverse (GET /v2.1/dns/reverse): # - value (string, required): IP, CIDR, or record value # - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) # - exact (boolean, optional) # - page (integer, optional) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DNSApi.new -result = api.dns_reverse("value", "a", true) -puts result + +begin + result = api.dns_reverse("8.8.8.8", "a", page: 1) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -245,20 +347,32 @@ puts result `POST /v2.0/dns/bulk/live` ```ruby -# Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +# Bulk DNS Lookup +# # Parameters for dnsBulk (POST /v2.0/dns/bulk/live): # - type (string, required) # - format (string (one of: json, xml), optional) -# - body: DnsBulkRequest (required) -- request body object -require 'whoisfreaks' +# - body: DnsBulkRequest (required): request body object +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DNSApi.new -result = api.dns_bulk("value", WhoisFreaks::DnsBulkRequest.new) -puts result + +request = WhoisFreaks::DnsBulkRequest.new(domain_names: ["whoisfreaks.com", "example.com"]) + +begin + result = api.dns_bulk("A,MX,TXT", request) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -269,21 +383,31 @@ puts result `GET /v2.0/domain/availability` ```ruby -# Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +# Domain Availability Check with Suggestions +# # Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): # - domain (string, required): The domain name to check # - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. # - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DomainAvailabilityApi.new -result = api.domain_availability_v2("example.com") -puts result + +begin + result = api.domain_availability_v2("google.com", sug: true, count: 5) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -292,20 +416,32 @@ puts result `POST /v2.0/domain/availability` ```ruby -# Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +# Bulk Domain Availability Check +# # Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): # - domain (string, optional): Required for TLD-mode bulk check (base domain). # - format (string (one of: json, xml), optional) -# - body: BulkDomainAvailabilityRequest (required) -- request body object -require 'whoisfreaks' +# - body: BulkDomainAvailabilityRequest (required): request body object + +require "json" +require "whoisfreaks" +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DomainAvailabilityApi.new -result = api.bulk_domain_availability_v2(WhoisFreaks::BulkDomainAvailabilityRequest.new) -puts result + +request = WhoisFreaks::BulkDomainAvailabilityRequest.new(domain_names: ["whoisfreaks.com", "example.com"]) + +begin + result = api.bulk_domain_availability_v2(request) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -316,20 +452,30 @@ puts result `GET /v3.0/domain/typos` ```ruby -# Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +# Typosquatting Lookup +# # Parameters for typosquatting (GET /v3.0/domain/typos): # - keyword (string, optional) # - pattern (string, optional) -# - pageToken (string, optional) -require 'whoisfreaks' +# - page_token (string, optional) + +require "json" +require "whoisfreaks" +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::TyposquattingApi.new -result = api.typosquatting() -puts result + +begin + result = api.typosquatting(keyword: "whoisfreaks") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -340,21 +486,31 @@ puts result `GET /v1.0/ssl/live` ```ruby -# Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +# SSL Certificate Lookup +# # Parameters for sslLookup (GET /v1.0/ssl/live): -# - domainName (string, required) +# - domain_name (string, required) # - chain (boolean, optional) -# - sslRaw (boolean, optional) +# - ssl_raw (boolean, optional) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::SSLApi.new -result = api.ssl_lookup("example.com") -puts result + +begin + result = api.ssl_lookup("whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -365,18 +521,28 @@ puts result `GET /v1.0/geolocation` ```ruby -# Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +# IP Geolocation Lookup +# # Parameters for geolocation (GET /v1.0/geolocation): # - ip (string, required) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::GeolocationApi.new -result = api.geolocation("8.8.8.8") -puts result + +begin + result = api.geolocation("8.8.8.8") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -385,18 +551,30 @@ puts result `POST /v1.0/geolocation` ```ruby -# Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +# Bulk IP Geolocation +# # Parameters for bulkGeolocation (POST /v1.0/geolocation): -# - body: BulkGeolocationRequest (required) -- request body object -require 'whoisfreaks' +# - body: BulkGeolocationRequest (required): request body object + +require "json" +require "whoisfreaks" +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::GeolocationApi.new -result = api.bulk_geolocation(WhoisFreaks::BulkGeolocationRequest.new) -puts result + +request = WhoisFreaks::BulkGeolocationRequest.new(ips: ["8.8.8.8", "1.1.1.1"]) + +begin + results = api.bulk_geolocation(request) + puts JSON.pretty_generate(results.map(&:to_hash)) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -407,7 +585,8 @@ puts result `GET /v1.0/subdomains` ```ruby -# Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +# Subdomains Lookup +# # Parameters for subdomains (GET /v1.0/subdomains): # - domain (string, required) # - after (string, optional) @@ -415,16 +594,24 @@ puts result # - status (string (one of: active, inactive), optional) # - page (integer, optional) # - format (string (one of: json, xml), optional) -require 'date' -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::SubdomainsApi.new -result = api.subdomains("example.com", "2000-01-01", Date.today.to_s) -puts result + +begin + result = api.subdomains("whoisfreaks.com", page: 1) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -435,18 +622,28 @@ puts result `GET /v1.0/security` ```ruby -# Runnable example: IP Reputation Lookup (GET /v1.0/security) +# IP Reputation Lookup +# # Parameters for ipReputation (GET /v1.0/security): # - ip (string, required) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::IPReputationApi.new -result = api.ip_reputation("8.8.8.8") -puts result + +begin + result = api.ip_reputation("8.8.8.8") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -455,18 +652,30 @@ puts result `POST /v1.0/security` ```ruby -# Runnable example: Bulk IP Reputation (POST /v1.0/security) +# Bulk IP Reputation +# # Parameters for bulkIpReputation (POST /v1.0/security): -# - body: BulkIpReputationRequest (required) -- request body object -require 'whoisfreaks' +# - body: BulkGeolocationRequest (required): request body object + +require "json" +require "whoisfreaks" +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::IPReputationApi.new -result = api.bulk_ip_reputation(WhoisFreaks::BulkIpReputationRequest.new) -puts result + +request = WhoisFreaks::BulkGeolocationRequest.new(ips: ["8.8.8.8", "1.1.1.1"]) + +begin + results = api.bulk_ip_reputation(request) + puts JSON.pretty_generate(results.map(&:to_hash)) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -477,19 +686,29 @@ puts result `GET /v1/domain/security` ```ruby -# Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +# Domain Reputation Lookup +# # Parameters for domainReputation (GET /v1/domain/security): -# - domainName (string, required): The domain name to assess +# - domain_name (string, required): The domain name to assess # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DomainReputationApi.new -result = api.domain_reputation("example.com") -puts result + +begin + result = api.domain_reputation("amazon.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -500,19 +719,29 @@ puts result `GET /v2.0/asn-whois` ```ruby -# Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +# ASN WHOIS Lookup +# # Parameters for asnWhois (GET /v2.0/asn-whois): # - asn (string, required) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::ASNWHOISApi.new -result = api.asn_whois("AS15169") -puts result + +begin + result = api.asn_whois("as15169") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -523,19 +752,29 @@ puts result `GET /v1.0/ip-whois` ```ruby -# Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +# IP WHOIS Lookup +# # Parameters for ipWhois (GET /v1.0/ip-whois): # - ip (string, required) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::IPWHOISApi.new -result = api.ip_whois("8.8.8.8") -puts result + +begin + result = api.ip_whois("8.8.8.8") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -546,18 +785,28 @@ puts result `GET /v1.0/api-key/rotate` ```ruby -# Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +# Rotate API Key +# # Parameters for rotateApiKey (GET /v1.0/api-key/rotate): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::AccountApi.new -result = api.rotate_api_key() -puts result + +begin + new_key = api.rotate_api_key + # The old key stops working now: store the new one before making more calls. + puts "New API key: #{new_key}" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -566,18 +815,28 @@ puts result `GET /v1.0/whoisapi/usage` ```ruby -# Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +# Account Usage +# # Parameters for accountUsage (GET /v1.0/whoisapi/usage): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::AccountApi.new -result = api.account_usage() -puts result + +begin + result = api.account_usage + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -586,18 +845,29 @@ puts result `GET /v3.4/status` ```ruby -# Runnable example: Database File Status (Public) (GET /v3.4/status) +# Database File Status (Public) +# # Parameters for databaseFileStatus (GET /v3.4/status): -# (no parameters; the API key is set on the client) -require 'whoisfreaks' +# (no parameters; no API key required) + +require "json" +require "whoisfreaks" +# Read the API key from the environment and set it once. +# (This endpoint is public, so the key is not sent with this request.) WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::AccountApi.new -result = api.database_file_status() -puts result + +begin + result = api.database_file_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -608,21 +878,34 @@ puts result `GET /v3.1/download/domainer/gtld` ```ruby -# Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +# Newly Registered gTLD (CSV) +# # Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): # - whois (boolean, required) # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_gtld(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_gtld(true, date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyGtld.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -631,21 +914,34 @@ puts result `GET /v3.1/download/domainer/cctld` ```ruby -# Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +# Newly Registered ccTLD (CSV) +# # Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): # - whois (boolean, required) # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_cctld(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_cctld(true, date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyCctld.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -654,19 +950,32 @@ puts result `GET /v3.1/download/domainer/gtld/cleaned` ```ruby -# Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +# Newly Registered gTLD Cleaned WHOIS (CSV) +# # Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_gtld_cleaned((Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_gtld_cleaned(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyGtldCleaned.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -675,19 +984,32 @@ puts result `GET /v3.1/download/domainer/cctld/cleaned` ```ruby -# Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +# Newly Registered ccTLD Cleaned WHOIS (CSV) +# # Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_cctld_cleaned((Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_cctld_cleaned(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyCctldCleaned.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -696,20 +1018,29 @@ puts result `GET /v3.1/domains/newly/gtld` ```ruby -# Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +# Newly Registered gTLD (JSON) +# # Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_gtld_json((Date.today - 1).to_s) -puts result + +begin + domains = api.db_newly_gtld_json(date: Date.parse("2026-10-01")) + puts domains +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -718,20 +1049,29 @@ puts result `GET /v3.1/domains/newly/cctld` ```ruby -# Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +# Newly Registered ccTLD (JSON) +# # Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_cctld_json((Date.today - 1).to_s) -puts result + +begin + domains = api.db_newly_cctld_json(date: Date.parse("2026-10-01")) + puts domains +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -740,19 +1080,32 @@ puts result `GET /v3.1/download/domainer/newly/dns` ```ruby -# Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +# Newly Registered With DNS +# # Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_dns((Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_dns(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyDns.json" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -763,20 +1116,33 @@ puts result `GET /v3.1/download/domainer/expired` ```ruby -# Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +# Expiring Domains +# # Parameters for dbExpired (GET /v3.1/download/domainer/expired): # - whois (boolean, required) # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_expired(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_expired(true, date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbExpired.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -785,19 +1151,32 @@ puts result `GET /v3.1/download/domainer/expired/cleaned` ```ruby -# Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +# Expiring Cleaned WHOIS +# # Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_expired_cleaned((Date.today - 1).to_s) -puts result + +begin + file = api.db_expired_cleaned(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbExpiredCleaned.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -806,20 +1185,33 @@ puts result `GET /v3.1/download/domainer/dropped` ```ruby -# Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +# Dropped Domains +# # Parameters for dbDropped (GET /v3.1/download/domainer/dropped): # - whois (boolean, required) # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_dropped(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_dropped(true, date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDropped.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -828,20 +1220,29 @@ puts result `GET /v3.1/domains/dropped` ```ruby -# Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +# Dropped Domains (JSON) +# # Parameters for dbDroppedJson (GET /v3.1/domains/dropped): # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_dropped_json((Date.today - 1).to_s) -puts result + +begin + domains = api.db_dropped_json(date: Date.parse("2026-10-01")) + puts domains +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -850,20 +1251,33 @@ puts result `GET /v3.3/download/domainer/dropped/backlinks` ```ruby -# Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +# Dropped With Backlinks +# # Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): # - whois (boolean, optional) # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_dropped_backlinks(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_dropped_backlinks(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDroppedBacklinks.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -874,19 +1288,32 @@ puts result `GET /v3.3/download/dbupdate/daily/domains/whois` ```ruby -# Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +# WHOIS Database Daily +# # Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesWHOISApi.new -result = api.db_whois_daily((Date.today - 1).to_s) -puts result + +begin + file = api.db_whois_daily(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbWhoisDaily.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -895,19 +1322,32 @@ puts result `GET /v3.3/download/dbupdate/weekly/domains/whois` ```ruby -# Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +# WHOIS Database Weekly +# # Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesWHOISApi.new -result = api.db_whois_weekly((Date.today - 1).to_s) -puts result + +begin + file = api.db_whois_weekly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbWhoisWeekly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -916,19 +1356,32 @@ puts result `GET /v3.3/download/dbupdate/monthly/domains/whois` ```ruby -# Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +# WHOIS Database Monthly +# # Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesWHOISApi.new -result = api.db_whois_monthly((Date.today - 1).to_s) -puts result + +begin + file = api.db_whois_monthly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbWhoisMonthly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -939,19 +1392,32 @@ puts result `GET /v3.2/download/dbupdate/daily/dns` ```ruby -# Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +# DNS Database Daily +# # Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesDNSApi.new -result = api.db_dns_daily((Date.today - 1).to_s) -puts result + +begin + file = api.db_dns_daily(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDnsDaily.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -960,19 +1426,32 @@ puts result `GET /v3.2/download/dbupdate/weekly/dns` ```ruby -# Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +# DNS Database Weekly +# # Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesDNSApi.new -result = api.db_dns_weekly((Date.today - 1).to_s) -puts result + +begin + file = api.db_dns_weekly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDnsWeekly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -981,19 +1460,32 @@ puts result `GET /v3.2/download/dbupdate/monthly/dns` ```ruby -# Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +# DNS Database Monthly +# # Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesDNSApi.new -result = api.db_dns_monthly((Date.today - 1).to_s) -puts result + +begin + file = api.db_dns_monthly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDnsMonthly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1004,19 +1496,32 @@ puts result `GET /v3.2/download/dbupdate/daily/subdomains` ```ruby -# Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +# Subdomains Daily +# # Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesSubdomainsApi.new -result = api.db_subdomains_daily((Date.today - 1).to_s) -puts result + +begin + file = api.db_subdomains_daily(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbSubdomainsDaily.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1025,19 +1530,32 @@ puts result `GET /v3.2/download/dbupdate/weekly/subdomains` ```ruby -# Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +# Subdomains Weekly +# # Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesSubdomainsApi.new -result = api.db_subdomains_weekly((Date.today - 1).to_s) -puts result + +begin + file = api.db_subdomains_weekly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbSubdomainsWeekly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1046,19 +1564,32 @@ puts result `GET /v3.2/download/dbupdate/monthly/subdomains` ```ruby -# Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +# Subdomains Monthly +# # Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesSubdomainsApi.new -result = api.db_subdomains_monthly((Date.today - 1).to_s) -puts result + +begin + file = api.db_subdomains_monthly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbSubdomainsMonthly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1069,18 +1600,28 @@ puts result `GET /v3.3/status/snapshot/ip/country` ```ruby -# Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +# IP to Country Snapshot Status +# # Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPGeolocationApi.new -result = api.db_ip_country_status() -puts result + +begin + result = api.db_ip_country_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1089,19 +1630,32 @@ puts result `GET /v3.3/download/snapshot/ip/country` ```ruby -# Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +# IP to Country Snapshot +# # Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPGeolocationApi.new -result = api.db_ip_country((Date.today - 1).to_s) -puts result + +begin + file = api.db_ip_country(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbIpCountry.zip" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1110,18 +1664,28 @@ puts result `GET /v3.3/status/snapshot/ip/city` ```ruby -# Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +# IP to City Snapshot Status +# # Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPGeolocationApi.new -result = api.db_ip_city_status() -puts result + +begin + result = api.db_ip_city_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1130,19 +1694,32 @@ puts result `GET /v3.3/download/snapshot/ip/city` ```ruby -# Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +# IP to City Snapshot +# # Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPGeolocationApi.new -result = api.db_ip_city((Date.today - 1).to_s) -puts result + +begin + file = api.db_ip_city(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbIpCity.zip" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1153,19 +1730,32 @@ puts result `GET /v3.3/download/snapshot/asn/whois` ```ruby -# Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +# ASN WHOIS Snapshot +# # Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesASNWHOISApi.new -result = api.db_asn_whois((Date.today - 1).to_s) -puts result + +begin + file = api.db_asn_whois(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbAsnWhois.json.gz" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1174,18 +1764,28 @@ puts result `GET /v3.3/status/snapshot/asn/whois` ```ruby -# Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +# ASN WHOIS Snapshot Status +# # Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesASNWHOISApi.new -result = api.db_asn_whois_status() -puts result + +begin + result = api.db_asn_whois_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1196,19 +1796,32 @@ puts result `GET /v3.3/download/snapshot/ip/whois` ```ruby -# Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +# IP WHOIS Snapshot +# # Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPWHOISApi.new -result = api.db_ip_whois((Date.today - 1).to_s) -puts result + +begin + file = api.db_ip_whois(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbIpWhois.json.gz" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1217,18 +1830,28 @@ puts result `GET /v3.3/status/snapshot/ip/whois` ```ruby -# Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +# IP WHOIS Snapshot Status +# # Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPWHOISApi.new -result = api.db_ip_whois_status() -puts result + +begin + result = api.db_ip_whois_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1239,19 +1862,32 @@ puts result `GET /v3.3/download/snapshot/ip/security` ```ruby -# Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +# IP Security Snapshot +# # Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPSecurityApi.new -result = api.db_ip_security((Date.today - 1).to_s) -puts result + +begin + file = api.db_ip_security(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbIpSecurity.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1260,18 +1896,28 @@ puts result `GET /v3.3/status/snapshot/ip/security` ```ruby -# Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +# IP Security Snapshot Status +# # Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPSecurityApi.new -result = api.db_ip_security_status() -puts result + +begin + result = api.db_ip_security_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1282,19 +1928,31 @@ puts result `GET /v3.4/download/threat-feed/phishing` ```ruby -# Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +# Download the daily phishing threat feed (CSV) +# # Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -require 'date' -require 'whoisfreaks' +# - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_phishing((Date.today - 1).to_s) -puts result + +begin + file = api.download_threat_feed_phishing(date: "2026-10-01") + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedPhishing.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1303,18 +1961,31 @@ puts result `GET /v3.4/download/threat-feed/phishing/sample` ```ruby -# Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +# Download a sample of the phishing threat feed (CSV) +# # Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_phishing_sample() -puts result + +begin + file = api.download_threat_feed_phishing_sample + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedPhishingSample.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1323,19 +1994,31 @@ puts result `GET /v3.4/download/threat-feed/malware` ```ruby -# Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +# Download the daily malware threat feed (CSV) +# # Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -require 'date' -require 'whoisfreaks' +# - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_malware((Date.today - 1).to_s) -puts result + +begin + file = api.download_threat_feed_malware(date: "2026-10-01") + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedMalware.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1344,18 +2027,31 @@ puts result `GET /v3.4/download/threat-feed/malware/sample` ```ruby -# Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +# Download a sample of the malware threat feed (CSV) +# # Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_malware_sample() -puts result + +begin + file = api.download_threat_feed_malware_sample + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedMalwareSample.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1364,19 +2060,31 @@ puts result `GET /v3.4/download/threat-feed/spam` ```ruby -# Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +# Download the daily spam threat feed (CSV) +# # Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -require 'date' -require 'whoisfreaks' +# - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_spam((Date.today - 1).to_s) -puts result + +begin + file = api.download_threat_feed_spam(date: "2026-10-01") + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedSpam.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` @@ -1385,17 +2093,30 @@ puts result `GET /v3.4/download/threat-feed/spam/sample` ```ruby -# Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +# Download a sample of the spam threat feed (CSV) +# # Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_spam_sample() -puts result + +begin + file = api.download_threat_feed_spam_sample + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedSpamSample.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end ``` diff --git a/docs/languages/swift.md b/docs/languages/swift.md index 0a994fa..ccec363 100644 --- a/docs/languages/swift.md +++ b/docs/languages/swift.md @@ -2,7 +2,7 @@ ## About -The official **WhoisFreaks Swift SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Swift with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Swift PM. +The official **WhoisFreaks Swift SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from Swift with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to Swift PM. **Keywords:** swift whois api, swift whois sdk, whoisfreaks swift, swift domain lookup, swift dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api @@ -12,12 +12,12 @@ The official **WhoisFreaks Swift SDK** — a complete client for WHOIS, DNS, SSL ## Install ```swift -.package(url: "https://github.com/WhoisFreaks/whoisfreaks-swift.git", from: "LATEST") +.package(url: "https://github.com/WhoisFreaks/whoisfreaks-swift.git", from: "0.23.0") ``` ## Build from Source -Prefer to build the SDK yourself instead of installing from Swift PM? Clone the monorepo and build the Swift package locally: +Prefer to build the SDK yourself instead of installing from Swift PM? Clone the Swift SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-swift @@ -29,35 +29,56 @@ swift build A complete walkthrough from an empty directory to a running program: +You need Swift 5.7 or later (Xcode 14+) on macOS 10.15 or later. The SDK uses async/await. + +1. Create an executable package: + ```bash -mkdir whoisfreaks-test && cd whoisfreaks-test -swift package init --type executable +mkdir -p whoisfreaks-test/Sources/WhoisFreaksTest +cd whoisfreaks-test ``` -Add the dependency to `Package.swift`: +2. Create `Package.swift` with the SDK as a dependency: ```swift -.package(url: "https://github.com/WhoisFreaks/whoisfreaks-swift.git", from: "1.0.0"), +// swift-tools-version:5.7 +import PackageDescription + +let package = Package( + name: "WhoisFreaksTest", + platforms: [.macOS(.v10_15)], + dependencies: [ + .package(url: "https://github.com/WhoisFreaks/whoisfreaks-swift.git", from: "0.23.0"), + ], + targets: [ + .executableTarget( + name: "WhoisFreaksTest", + dependencies: [.product(name: "WhoisFreaks", package: "whoisfreaks-swift")] + ), + ] +) ``` -…and list `WhoisFreaks` as a target dependency. Then in `Sources/.../main.swift`: +3. Create `Sources/WhoisFreaksTest/main.swift`: ```swift +import Foundation import WhoisFreaks -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" // set once +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] -do { - let result = try await WHOISAPI.whoisLive(domainName: "example.com") - print(result) -} catch { - print(error) -} +let record = try await WHOISAPI.whoisLive(domainName: "whoisfreaks.com") + +print("Registrar:", record.domainRegistrar?.registrarName ?? "-") +print("Created: ", record.createDate ?? "-") +print("Expires: ", record.expiryDate ?? "-") ``` -Run it: +4. Set your API key and run it: ```bash +export WHOISFREAKS_API_KEY="your_api_key" swift run ``` @@ -66,20 +87,30 @@ swift run See [Authentication](../authentication.md) for how to obtain a key. Minimal setup: ```swift -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Live WHOIS Lookup +// // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await WHOISAPI.whoisLive(domainName: "example.com", format: nil) - print(result) + let result = try await WHOISAPI.whoisLive(domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -95,20 +126,30 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, `GET /v2.0/whois/live` ```swift -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Live WHOIS Lookup +// // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await WHOISAPI.whoisLive(domainName: "example.com", format: nil) - print(result) + let result = try await WHOISAPI.whoisLive(domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -118,20 +159,32 @@ do { `POST /v2.0/bulkwhois/live` ```swift -// Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Bulk WHOIS Lookup +// // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = BulkWhoisRequest(domainNames: ["whoisfreaks.com", "jfreaks.com"]) do { - let result = try await WHOISAPI.bulkWhois(bulkWhoisRequest: BulkWhoisRequest(), format: nil) - print(result) + let result = try await WHOISAPI.bulkWhois(bulkWhoisRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -141,21 +194,30 @@ do { `GET /v2.0/whois/history` ```swift -// Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Historical WHOIS records for a domain +// // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await WHOISAPI.whoisHistory(domainName: "example.com", page: nil, format: nil) - print(result) + let result = try await WHOISAPI.whoisHistory(domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -165,21 +227,31 @@ do { `GET /v2.0/whois/reverse` ```swift -// Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Reverse WHOIS lookup by keyword +// // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await WHOISAPI.whoisReverse(keyword: "value", page: nil, format: nil) - print(result) + let result = try await WHOISAPI.whoisReverse(keyword: "whoisfreaks", page: 1) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -191,22 +263,32 @@ do { `GET /v2.0/dns/live` ```swift -// Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Live DNS Lookup +// // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DNSAPI.dnsLive(domainName: "example.com", ipAddress: "8.8.8.8", type: "value", format: nil) - print(result) + let result = try await DNSAPI.dnsLive(type: "A,MX,TXT", domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -216,22 +298,32 @@ do { `GET /v2.0/dns/historical` ```swift -// Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Historical DNS Lookup +// // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) // - page (integer, optional) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DNSAPI.dnsHistorical(domainName: "example.com", type: "value", page: nil, format: nil) - print(result) + let result = try await DNSAPI.dnsHistorical(domainName: "whoisfreaks.com", type: "A,MX,TXT", page: 1) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -241,23 +333,33 @@ do { `GET /v2.1/dns/reverse` ```swift -// Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Reverse DNS Lookup +// // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) // - exact (boolean, optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DNSAPI.dnsReverse(value: "value", type: "a", exact: true, page: nil, format: nil) - print(result) + let result = try await DNSAPI.dnsReverse(value: "8.8.8.8", type: .a, page: 1) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -267,21 +369,33 @@ do { `POST /v2.0/dns/bulk/live` ```swift -// Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Bulk DNS Lookup +// // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = DnsBulkRequest(domainNames: ["whoisfreaks.com", "example.com"]) do { - let result = try await DNSAPI.dnsBulk(type: "value", dnsBulkRequest: DnsBulkRequest(), format: nil) - print(result) + let result = try await DNSAPI.dnsBulk(type: "A,MX,TXT", dnsBulkRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -293,22 +407,32 @@ do { `GET /v2.0/domain/availability` ```swift -// Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Domain Availability Check with Suggestions +// // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. // - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DomainAvailabilityAPI.domainAvailabilityV2(domain: "example.com", sug: nil, count: nil, format: nil) - print(result) + let result = try await DomainAvailabilityAPI.domainAvailabilityV2(domain: "google.com", sug: true, count: 5) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -318,21 +442,33 @@ do { `POST /v2.0/domain/availability` ```swift -// Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Bulk Domain Availability Check +// // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = BulkDomainAvailabilityRequest(domainNames: ["whoisfreaks.com", "example.com"]) do { - let result = try await DomainAvailabilityAPI.bulkDomainAvailabilityV2(bulkDomainAvailabilityRequest: BulkDomainAvailabilityRequest(), domain: nil, format: nil) - print(result) + let result = try await DomainAvailabilityAPI.bulkDomainAvailabilityV2(bulkDomainAvailabilityRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -344,21 +480,31 @@ do { `GET /v3.0/domain/typos` ```swift -// Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Typosquatting Lookup +// // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) // - pageToken (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await TyposquattingAPI.typosquatting(keyword: nil, pattern: nil, pageToken: nil) - print(result) + let result = try await TyposquattingAPI.typosquatting(keyword: "whoisfreaks") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -370,22 +516,32 @@ do { `GET /v1.0/ssl/live` ```swift -// Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// SSL Certificate Lookup +// // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) // - sslRaw (boolean, optional) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await SSLAPI.sslLookup(domainName: "example.com", chain: nil, sslRaw: nil, format: nil) - print(result) + let result = try await SSLAPI.sslLookup(domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -397,19 +553,29 @@ do { `GET /v1.0/geolocation` ```swift -// Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// IP Geolocation Lookup +// // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await GeolocationAPI.geolocation(ip: "8.8.8.8") - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -419,19 +585,31 @@ do { `POST /v1.0/geolocation` ```swift -// Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Bulk IP Geolocation +// // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = BulkGeolocationRequest(ips: ["8.8.8.8", "1.1.1.1"]) do { - let result = try await GeolocationAPI.bulkGeolocation(bulkGeolocationRequest: BulkGeolocationRequest()) - print(result) + let result = try await GeolocationAPI.bulkGeolocation(bulkGeolocationRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -443,7 +621,8 @@ do { `GET /v1.0/subdomains` ```swift -// Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Subdomains Lookup +// // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -451,17 +630,25 @@ do { // - status (string (one of: active, inactive), optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await SubdomainsAPI.subdomains(domain: "example.com", after: "2000-01-01", before: String(ISO8601DateFormatter().string(from: Date()).prefix(10)), status: nil, page: nil, format: nil) - print(result) + let result = try await SubdomainsAPI.subdomains(domain: "whoisfreaks.com", page: 1) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -473,19 +660,29 @@ do { `GET /v1.0/security` ```swift -// Runnable example: IP Reputation Lookup (GET /v1.0/security) +// IP Reputation Lookup +// // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await IPReputationAPI.ipReputation(ip: "8.8.8.8") - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -495,19 +692,31 @@ do { `POST /v1.0/security` ```swift -// Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Bulk IP Reputation +// // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = BulkGeolocationRequest(ips: ["8.8.8.8", "1.1.1.1"]) do { - let result = try await IPReputationAPI.bulkIpReputation(bulkIpReputationRequest: BulkIpReputationRequest()) - print(result) + let result = try await IPReputationAPI.bulkIpReputation(bulkGeolocationRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -519,20 +728,30 @@ do { `GET /v1/domain/security` ```swift -// Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Domain Reputation Lookup +// // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DomainReputationAPI.domainReputation(domainName: "example.com", format: nil) - print(result) + let result = try await DomainReputationAPI.domainReputation(domainName: "amazon.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -544,20 +763,30 @@ do { `GET /v2.0/asn-whois` ```swift -// Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// ASN WHOIS Lookup +// // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await ASNWHOISAPI.asnWhois(asn: "AS15169", format: nil) - print(result) + let result = try await ASNWHOISAPI.asnWhois(asn: "as15169") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -569,20 +798,30 @@ do { `GET /v1.0/ip-whois` ```swift -// Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// IP WHOIS Lookup +// // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await IPWHOISAPI.ipWhois(ip: "8.8.8.8", format: nil) - print(result) + let result = try await IPWHOISAPI.ipWhois(ip: "8.8.8.8") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -594,19 +833,30 @@ do { `GET /v1.0/api-key/rotate` ```swift -// Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Rotate API Key +// // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await AccountAPI.rotateApiKey() - print(result) + let newKey = try await AccountAPI.rotateApiKey() + // The old key stops working now: store the new one before making more calls. + print("New API key: \(newKey)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -616,19 +866,29 @@ do { `GET /v1.0/whoisapi/usage` ```swift -// Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Account Usage +// // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await AccountAPI.accountUsage() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -638,19 +898,30 @@ do { `GET /v3.4/status` ```swift -// Runnable example: Database File Status (Public) (GET /v3.4/status) +// Database File Status (Public) +// // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] +// (This endpoint is public, so the key is not sent with this request.) do { let result = try await AccountAPI.databaseFileStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -662,22 +933,35 @@ do { `GET /v3.1/download/domainer/gtld` ```swift -// Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Newly Registered gTLD (CSV) +// // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyGtld(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyGtld(whois: true, date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyGtld.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -687,22 +971,35 @@ do { `GET /v3.1/download/domainer/cctld` ```swift -// Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Newly Registered ccTLD (CSV) +// // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyCctld(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyCctld(whois: true, date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyCctld.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -712,20 +1009,33 @@ do { `GET /v3.1/download/domainer/gtld/cleaned` ```swift -// Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Newly Registered gTLD Cleaned WHOIS (CSV) +// // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyGtldCleaned(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyGtldCleaned(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyGtldCleaned.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -735,20 +1045,33 @@ do { `GET /v3.1/download/domainer/cctld/cleaned` ```swift -// Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Newly Registered ccTLD Cleaned WHOIS (CSV) +// // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyCctldCleaned(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyCctldCleaned(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyCctldCleaned.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -758,21 +1081,30 @@ do { `GET /v3.1/domains/newly/gtld` ```swift -// Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Newly Registered gTLD (JSON) +// // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyGtldJson(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let domains = try await DatabasesNewlyRegisteredAPI.dbNewlyGtldJson(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + print(domains.joined(separator: "\n")) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -782,21 +1114,30 @@ do { `GET /v3.1/domains/newly/cctld` ```swift -// Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Newly Registered ccTLD (JSON) +// // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyCctldJson(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let domains = try await DatabasesNewlyRegisteredAPI.dbNewlyCctldJson(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + print(domains.joined(separator: "\n")) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -806,20 +1147,33 @@ do { `GET /v3.1/download/domainer/newly/dns` ```swift -// Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Newly Registered With DNS +// // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyDns(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyDns(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyDns.json") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -831,21 +1185,34 @@ do { `GET /v3.1/download/domainer/expired` ```swift -// Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Expiring Domains +// // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbExpired(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesExpiringDroppedAPI.dbExpired(whois: true, date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbExpired.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -855,20 +1222,33 @@ do { `GET /v3.1/download/domainer/expired/cleaned` ```swift -// Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Expiring Cleaned WHOIS +// // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbExpiredCleaned(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesExpiringDroppedAPI.dbExpiredCleaned(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbExpiredCleaned.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -878,21 +1258,34 @@ do { `GET /v3.1/download/domainer/dropped` ```swift -// Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Dropped Domains +// // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbDropped(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesExpiringDroppedAPI.dbDropped(whois: true, date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDropped.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -902,21 +1295,30 @@ do { `GET /v3.1/domains/dropped` ```swift -// Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Dropped Domains (JSON) +// // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbDroppedJson(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let domains = try await DatabasesExpiringDroppedAPI.dbDroppedJson(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + print(domains.joined(separator: "\n")) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -926,21 +1328,34 @@ do { `GET /v3.3/download/domainer/dropped/backlinks` ```swift -// Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Dropped With Backlinks +// // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbDroppedBacklinks(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesExpiringDroppedAPI.dbDroppedBacklinks(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDroppedBacklinks.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -952,20 +1367,33 @@ do { `GET /v3.3/download/dbupdate/daily/domains/whois` ```swift -// Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// WHOIS Database Daily +// // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesWHOISAPI.dbWhoisDaily(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesWHOISAPI.dbWhoisDaily(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbWhoisDaily.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -975,20 +1403,33 @@ do { `GET /v3.3/download/dbupdate/weekly/domains/whois` ```swift -// Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// WHOIS Database Weekly +// // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesWHOISAPI.dbWhoisWeekly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesWHOISAPI.dbWhoisWeekly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbWhoisWeekly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -998,20 +1439,33 @@ do { `GET /v3.3/download/dbupdate/monthly/domains/whois` ```swift -// Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// WHOIS Database Monthly +// // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesWHOISAPI.dbWhoisMonthly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesWHOISAPI.dbWhoisMonthly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbWhoisMonthly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1023,20 +1477,33 @@ do { `GET /v3.2/download/dbupdate/daily/dns` ```swift -// Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// DNS Database Daily +// // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesDNSAPI.dbDnsDaily(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesDNSAPI.dbDnsDaily(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDnsDaily.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1046,20 +1513,33 @@ do { `GET /v3.2/download/dbupdate/weekly/dns` ```swift -// Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// DNS Database Weekly +// // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesDNSAPI.dbDnsWeekly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesDNSAPI.dbDnsWeekly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDnsWeekly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1069,20 +1549,33 @@ do { `GET /v3.2/download/dbupdate/monthly/dns` ```swift -// Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// DNS Database Monthly +// // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesDNSAPI.dbDnsMonthly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesDNSAPI.dbDnsMonthly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDnsMonthly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1094,20 +1587,33 @@ do { `GET /v3.2/download/dbupdate/daily/subdomains` ```swift -// Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Subdomains Daily +// // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesSubdomainsAPI.dbSubdomainsDaily(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesSubdomainsAPI.dbSubdomainsDaily(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbSubdomainsDaily.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1117,20 +1623,33 @@ do { `GET /v3.2/download/dbupdate/weekly/subdomains` ```swift -// Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Subdomains Weekly +// // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesSubdomainsAPI.dbSubdomainsWeekly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesSubdomainsAPI.dbSubdomainsWeekly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbSubdomainsWeekly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1140,20 +1659,33 @@ do { `GET /v3.2/download/dbupdate/monthly/subdomains` ```swift -// Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Subdomains Monthly +// // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesSubdomainsAPI.dbSubdomainsMonthly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesSubdomainsAPI.dbSubdomainsMonthly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbSubdomainsMonthly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1165,19 +1697,29 @@ do { `GET /v3.3/status/snapshot/ip/country` ```swift -// Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// IP to Country Snapshot Status +// // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesIPGeolocationAPI.dbIpCountryStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1187,20 +1729,33 @@ do { `GET /v3.3/download/snapshot/ip/country` ```swift -// Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// IP to Country Snapshot +// // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesIPGeolocationAPI.dbIpCountry(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesIPGeolocationAPI.dbIpCountry(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbIpCountry.zip") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1210,19 +1765,29 @@ do { `GET /v3.3/status/snapshot/ip/city` ```swift -// Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// IP to City Snapshot Status +// // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesIPGeolocationAPI.dbIpCityStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1232,20 +1797,33 @@ do { `GET /v3.3/download/snapshot/ip/city` ```swift -// Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// IP to City Snapshot +// // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesIPGeolocationAPI.dbIpCity(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesIPGeolocationAPI.dbIpCity(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbIpCity.zip") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1257,20 +1835,33 @@ do { `GET /v3.3/download/snapshot/asn/whois` ```swift -// Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// ASN WHOIS Snapshot +// // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesASNWHOISAPI.dbAsnWhois(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesASNWHOISAPI.dbAsnWhois(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbAsnWhois.json.gz") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1280,19 +1871,29 @@ do { `GET /v3.3/status/snapshot/asn/whois` ```swift -// Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// ASN WHOIS Snapshot Status +// // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesASNWHOISAPI.dbAsnWhoisStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1304,20 +1905,33 @@ do { `GET /v3.3/download/snapshot/ip/whois` ```swift -// Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// IP WHOIS Snapshot +// // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesIPWHOISAPI.dbIpWhois(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesIPWHOISAPI.dbIpWhois(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbIpWhois.json.gz") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1327,19 +1941,29 @@ do { `GET /v3.3/status/snapshot/ip/whois` ```swift -// Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// IP WHOIS Snapshot Status +// // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesIPWHOISAPI.dbIpWhoisStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1351,20 +1975,33 @@ do { `GET /v3.3/download/snapshot/ip/security` ```swift -// Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// IP Security Snapshot +// // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesIPSecurityAPI.dbIpSecurity(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesIPSecurityAPI.dbIpSecurity(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbIpSecurity.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1374,19 +2011,29 @@ do { `GET /v3.3/status/snapshot/ip/security` ```swift -// Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// IP Security Snapshot Status +// // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesIPSecurityAPI.dbIpSecurityStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1398,20 +2045,33 @@ do { `GET /v3.4/download/threat-feed/phishing` ```swift -// Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Download the daily phishing threat feed (CSV) +// // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedPhishing(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedPhishing(date: "2026-10-01") + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedPhishing.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1421,19 +2081,33 @@ do { `GET /v3.4/download/threat-feed/phishing/sample` ```swift -// Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Download a sample of the phishing threat feed (CSV) +// // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedPhishingSample() - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedPhishingSample() + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedPhishingSample.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1443,20 +2117,33 @@ do { `GET /v3.4/download/threat-feed/malware` ```swift -// Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Download the daily malware threat feed (CSV) +// // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedMalware(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedMalware(date: "2026-10-01") + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedMalware.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1466,19 +2153,33 @@ do { `GET /v3.4/download/threat-feed/malware/sample` ```swift -// Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Download a sample of the malware threat feed (CSV) +// // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedMalwareSample() - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedMalwareSample() + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedMalwareSample.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1488,20 +2189,33 @@ do { `GET /v3.4/download/threat-feed/spam` ```swift -// Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Download the daily spam threat feed (CSV) +// // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedSpam(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedSpam(date: "2026-10-01") + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedSpam.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` @@ -1511,19 +2225,33 @@ do { `GET /v3.4/download/threat-feed/spam/sample` ```swift -// Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Download a sample of the spam threat feed (CSV) +// // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedSpamSample() - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedSpamSample() + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedSpamSample.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } ``` diff --git a/docs/languages/typescript.md b/docs/languages/typescript.md index dbda16e..4847c26 100644 --- a/docs/languages/typescript.md +++ b/docs/languages/typescript.md @@ -2,7 +2,7 @@ ## About -The official **WhoisFreaks TypeScript SDK** — a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from TypeScript with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to npm. +The official **WhoisFreaks TypeScript SDK**: a complete client for WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP reputation, ASN, typosquatting, and domain reputation lookups, plus bulk database downloads. Query real-time and historical domain data, reverse WHOIS, and threat intelligence from TypeScript with a single API key. Generated from the WhoisFreaks OpenAPI specification and published to npm. **Keywords:** typescript whois api, typescript whois sdk, whoisfreaks typescript, typescript domain lookup, typescript dns api, whois api, whois lookup, domain api, dns api, dns lookup, reverse whois, historical whois, domain availability api, ssl certificate api, ip geolocation api, ip reputation api, asn lookup, subdomain finder, typosquatting api, domain reputation, threat intelligence api, domain data api, whois sdk, domain monitoring, brand protection api @@ -17,7 +17,7 @@ npm install whoisfreaks ## Build from Source -Prefer to build the SDK yourself instead of installing from npm? Clone the monorepo and build the TypeScript package locally: +Prefer to build the SDK yourself instead of installing from npm? Clone the TypeScript SDK repository and build it locally: ```bash git clone https://github.com/WhoisFreaks/whoisfreaks-typescript @@ -30,29 +30,53 @@ npm run build A complete walkthrough from an empty directory to a running program: +1. Create a project and install the SDK (Node.js 18 or later), plus [tsx](https://tsx.is) to run TypeScript files directly: + ```bash mkdir whoisfreaks-test && cd whoisfreaks-test npm init -y npm install whoisfreaks -npm install -D typescript ts-node @types/node +npm install -D tsx @types/node ``` -Set `"type": "module"` in `package.json`, then create `main.ts`: +2. Create `main.ts`: -```ts -import { Configuration, WHOISApi } from "whoisfreaks"; +```typescript +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -const result = await api.whoisLive({ domainName: "example.com" }); -console.log(result); +async function main(): Promise { + const record = await api.whoisLive({ domainName: "whoisfreaks.com" }); + console.log("Domain: ", record.domain_name); + console.log("Created:", record.create_date); + console.log("Expires:", record.expiry_date); +} + +main().catch(async (err: unknown) => { + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); +``` + +3. Set your API key and run it: + +```bash +export WHOISFREAKS_API_KEY="your_api_key" # PowerShell: $env:WHOISFREAKS_API_KEY="your_api_key" +npx tsx main.ts ``` -Run it: +`tsx` runs the file without a separate compile step. To type-check as well, add the compiler and run it in strict mode: ```bash -npx ts-node main.ts +npm install -D typescript +npx tsc --noEmit --strict --module nodenext --types node main.ts ``` ## Configure @@ -60,21 +84,31 @@ npx ts-node main.ts See [Authentication](../authentication.md) for how to obtain a key. Minimal setup: ```typescript -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) -// Parameters for whoisLive (GET /v2.0/whois/live): -// - domainName (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; +// Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisLive.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisLive({ domainName: "example.com", format: undefined }); - console.log(result); +// whoisLive({ domainName, format? }) +// domainName (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.whoisLive({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ## Endpoints @@ -88,21 +122,31 @@ All 60 endpoints are shown below, grouped by category. Each includes its method, `GET /v2.0/whois/live` ```typescript -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) -// Parameters for whoisLive (GET /v2.0/whois/live): -// - domainName (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; +// Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisLive.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisLive({ domainName: "example.com", format: undefined }); - console.log(result); +// whoisLive({ domainName, format? }) +// domainName (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.whoisLive({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Bulk WHOIS Lookup @@ -110,21 +154,32 @@ main().catch(console.error); `POST /v2.0/bulkwhois/live` ```typescript -// Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) -// Parameters for bulkWhois (POST /v2.0/bulkwhois/live): -// - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object -import { Configuration, WHOISApi } from "whoisfreaks"; +// Bulk WHOIS Lookup: POST https://api.whoisfreaks.com/v2.0/bulkwhois/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkWhois.ts +import { Configuration, WHOISApi, ResponseError, type BulkWhoisRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.bulkWhois({ bulkWhoisRequest: {}, format: undefined }); - console.log(result); +// bulkWhois({ bulkWhoisRequest, format? }) +// bulkWhoisRequest (BulkWhoisRequest, required): request body +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const body: BulkWhoisRequest = { domainNames: ["whoisfreaks.com", "jfreaks.com"] }; + const result = await api.bulkWhois({ bulkWhoisRequest: body }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Historical WHOIS records for a domain @@ -132,22 +187,31 @@ main().catch(console.error); `GET /v2.0/whois/history` ```typescript -// Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) -// Parameters for whoisHistory (GET /v2.0/whois/history): -// - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Historical WHOIS records for a domain: GET https://api.whoisfreaks.com/v2.0/whois/history +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisHistory.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisHistory({ domainName: "example.com", page: undefined, format: undefined }); - console.log(result); +// whoisHistory({ domainName, format? }) +// domainName (string, required): Domain to fetch historical WHOIS records for +// format ("json" | "xml", optional) +async function main(): Promise { + const result = await api.whoisHistory({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Reverse WHOIS lookup by keyword @@ -155,22 +219,32 @@ main().catch(console.error); `GET /v2.0/whois/reverse` ```typescript -// Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) -// Parameters for whoisReverse (GET /v2.0/whois/reverse): -// - keyword (string, required): Keyword to search across WHOIS records -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Reverse WHOIS lookup by keyword: GET https://api.whoisfreaks.com/v2.0/whois/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisReverse.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisReverse({ keyword: "value", page: undefined, format: undefined }); - console.log(result); +// whoisReverse({ keyword, page?, format? }) +// keyword (string, required): Keyword to search across WHOIS records +// page (number, optional): Page number +// format ("json" | "xml", optional) +async function main(): Promise { + const result = await api.whoisReverse({ keyword: "whoisfreaks", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### DNS @@ -180,23 +254,33 @@ main().catch(console.error); `GET /v2.0/dns/live` ```typescript -// Runnable example: Live DNS Lookup (GET /v2.0/dns/live) -// Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups -// - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME -// - format (string (one of: json, xml), optional) -import { Configuration, DNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Live DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsLive.ts +import { Configuration, DNSApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsLive({ domainName: "example.com", ipAddress: "8.8.8.8", type: "value", format: undefined }); - console.log(result); +// dnsLive({ type, domainName?, ipAddress?, format? }) +// type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME; default "all" +// domainName (string, optional) +// ipAddress (string, optional): Use for PTR lookups +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.dnsLive({ type: "A,MX,TXT", domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Historical DNS Lookup @@ -204,23 +288,33 @@ main().catch(console.error); `GET /v2.0/dns/historical` ```typescript -// Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) -// Parameters for dnsHistorical (GET /v2.0/dns/historical): -// - domainName (string, required) -// - type (string, required) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, DNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Historical DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/historical +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsHistorical.ts +import { Configuration, DNSApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsHistorical({ domainName: "example.com", type: "value", page: undefined, format: undefined }); - console.log(result); +// dnsHistorical({ domainName, type, page?, format? }) +// domainName (string, required) +// type (string, required): default "all" +// page (number, optional): default 1 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.dnsHistorical({ domainName: "whoisfreaks.com", type: "A,MX,TXT", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Reverse DNS Lookup @@ -228,24 +322,34 @@ main().catch(console.error); `GET /v2.1/dns/reverse` ```typescript -// Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) -// Parameters for dnsReverse (GET /v2.1/dns/reverse): -// - value (string, required): IP, CIDR, or record value -// - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, DNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Reverse DNS Lookup: GET https://api.whoisfreaks.com/v2.1/dns/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsReverse.ts +import { Configuration, DNSApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsReverse({ value: "value", type: "a", exact: true, page: undefined, format: undefined }); - console.log(result); +// dnsReverse({ value, type, exact?, page?, format? }) +// value (string, required): IP, CIDR, or record value +// type ("a" | "mx" | "cname" | "ns" | "aaaa" | "txt" | "soa", required) +// exact (boolean, optional): default true +// page (number, optional): default 1 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.dnsReverse({ value: "8.8.8.8", type: "a", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Bulk DNS Lookup @@ -253,22 +357,33 @@ main().catch(console.error); `POST /v2.0/dns/bulk/live` ```typescript -// Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) -// Parameters for dnsBulk (POST /v2.0/dns/bulk/live): -// - type (string, required) -// - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object -import { Configuration, DNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Bulk DNS Lookup: POST https://api.whoisfreaks.com/v2.0/dns/bulk/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsBulk.ts +import { Configuration, DNSApi, ResponseError, type DnsBulkRequest } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsBulk({ type: "value", dnsBulkRequest: {}, format: undefined }); - console.log(result); +// dnsBulk({ type, dnsBulkRequest, format? }) +// type (string, required): default "all" +// dnsBulkRequest (DnsBulkRequest, required): request body +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const body: DnsBulkRequest = { domainNames: ["whoisfreaks.com", "example.com"] }; + const result = await api.dnsBulk({ type: "A,MX,TXT", dnsBulkRequest: body }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Domain Availability @@ -278,23 +393,33 @@ main().catch(console.error); `GET /v2.0/domain/availability` ```typescript -// Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) -// Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): -// - domain (string, required): The domain name to check -// - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. -// - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. -// - format (string (one of: json, xml), optional) -import { Configuration, DomainAvailabilityApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Domain Availability Check with Suggestions: GET https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DomainAvailabilityV2.ts +import { Configuration, DomainAvailabilityApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DomainAvailabilityApi(config); -async function main() { - const result = await api.domainAvailabilityV2({ domain: "example.com", sug: undefined, count: undefined, format: undefined }); - console.log(result); +// domainAvailabilityV2({ domain, sug?, count?, format? }) +// domain (string, required): The domain name to check +// sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain; default false +// count (number, optional): Number of TLD suggestions to return when sug=true. Maximum is 100; default 5 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.domainAvailabilityV2({ domain: "google.com", sug: true, count: 5 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Bulk Domain Availability Check @@ -302,22 +427,33 @@ main().catch(console.error); `POST /v2.0/domain/availability` ```typescript -// Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) -// Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): -// - domain (string, optional): Required for TLD-mode bulk check (base domain). -// - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object -import { Configuration, DomainAvailabilityApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Bulk Domain Availability Check: POST https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkDomainAvailabilityV2.ts +import { Configuration, DomainAvailabilityApi, ResponseError, type BulkDomainAvailabilityRequest } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DomainAvailabilityApi(config); -async function main() { - const result = await api.bulkDomainAvailabilityV2({ bulkDomainAvailabilityRequest: {}, domain: undefined, format: undefined }); - console.log(result); +// bulkDomainAvailabilityV2({ bulkDomainAvailabilityRequest, domain?, format? }) +// bulkDomainAvailabilityRequest (BulkDomainAvailabilityRequest, required): request body +// domain (string, optional): Required for TLD-mode bulk check (base domain) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const body: BulkDomainAvailabilityRequest = { domainNames: ["whoisfreaks.com", "example.com"] }; + const result = await api.bulkDomainAvailabilityV2({ bulkDomainAvailabilityRequest: body }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Typosquatting @@ -327,22 +463,32 @@ main().catch(console.error); `GET /v3.0/domain/typos` ```typescript -// Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) -// Parameters for typosquatting (GET /v3.0/domain/typos): -// - keyword (string, optional) -// - pattern (string, optional) -// - pageToken (string, optional) -import { Configuration, TyposquattingApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Typosquatting Lookup: GET https://api.whoisfreaks.com/v3.0/domain/typos +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx Typosquatting.ts +import { Configuration, TyposquattingApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new TyposquattingApi(config); -async function main() { - const result = await api.typosquatting({ keyword: undefined, pattern: undefined, pageToken: undefined }); - console.log(result); +// typosquatting({ keyword?, pattern?, pageToken? }) +// keyword (string, optional) +// pattern (string, optional) +// pageToken (string, optional) +async function main(): Promise { + const result = await api.typosquatting({ keyword: "whoisfreaks" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### SSL @@ -352,23 +498,33 @@ main().catch(console.error); `GET /v1.0/ssl/live` ```typescript -// Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) -// Parameters for sslLookup (GET /v1.0/ssl/live): -// - domainName (string, required) -// - chain (boolean, optional) -// - sslRaw (boolean, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, SSLApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// SSL Certificate Lookup: GET https://api.whoisfreaks.com/v1.0/ssl/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx SslLookup.ts +import { Configuration, SSLApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new SSLApi(config); -async function main() { - const result = await api.sslLookup({ domainName: "example.com", chain: undefined, sslRaw: undefined, format: undefined }); - console.log(result); +// sslLookup({ domainName, chain?, sslRaw?, format? }) +// domainName (string, required) +// chain (boolean, optional): default false +// sslRaw (boolean, optional): default false +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.sslLookup({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Geolocation @@ -378,20 +534,30 @@ main().catch(console.error); `GET /v1.0/geolocation` ```typescript -// Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) -// Parameters for geolocation (GET /v1.0/geolocation): -// - ip (string, required) -import { Configuration, GeolocationApi } from "whoisfreaks"; +// IP Geolocation Lookup: GET https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx Geolocation.ts +import { Configuration, GeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new GeolocationApi(config); -async function main() { +// geolocation({ ip }) +// ip (string, required) +async function main(): Promise { const result = await api.geolocation({ ip: "8.8.8.8" }); - console.log(result); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Bulk IP Geolocation @@ -399,20 +565,31 @@ main().catch(console.error); `POST /v1.0/geolocation` ```typescript -// Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) -// Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object -import { Configuration, GeolocationApi } from "whoisfreaks"; +// Bulk IP Geolocation: POST https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkGeolocation.ts +import { Configuration, GeolocationApi, ResponseError, type BulkGeolocationRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new GeolocationApi(config); -async function main() { - const result = await api.bulkGeolocation({ bulkGeolocationRequest: {} }); - console.log(result); +// bulkGeolocation({ bulkGeolocationRequest }) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main(): Promise { + const body: BulkGeolocationRequest = { ips: ["8.8.8.8", "1.1.1.1"] }; + const results = await api.bulkGeolocation({ bulkGeolocationRequest: body }); + console.log(JSON.stringify(results, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Subdomains @@ -422,25 +599,35 @@ main().catch(console.error); `GET /v1.0/subdomains` ```typescript -// Runnable example: Subdomains Lookup (GET /v1.0/subdomains) -// Parameters for subdomains (GET /v1.0/subdomains): -// - domain (string, required) -// - after (string, optional) -// - before (string, optional) -// - status (string (one of: active, inactive), optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, SubdomainsApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Subdomains Lookup: GET https://api.whoisfreaks.com/v1.0/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx Subdomains.ts +import { Configuration, SubdomainsApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new SubdomainsApi(config); -async function main() { - const result = await api.subdomains({ domain: "example.com", after: "2000-01-01", before: new Date().toISOString().slice(0,10), status: undefined, page: undefined, format: undefined }); - console.log(result); +// subdomains({ domain, after?, before?, status?, page?, format? }) +// domain (string, required) +// after (Date, optional) +// before (Date, optional) +// status ("active" | "inactive", optional) +// page (number, optional): default 1 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.subdomains({ domain: "whoisfreaks.com", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### IP Reputation @@ -450,20 +637,30 @@ main().catch(console.error); `GET /v1.0/security` ```typescript -// Runnable example: IP Reputation Lookup (GET /v1.0/security) -// Parameters for ipReputation (GET /v1.0/security): -// - ip (string, required) -import { Configuration, IPReputationApi } from "whoisfreaks"; +// IP Reputation Lookup: GET https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx IpReputation.ts +import { Configuration, IPReputationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new IPReputationApi(config); -async function main() { +// ipReputation({ ip }) +// ip (string, required) +async function main(): Promise { const result = await api.ipReputation({ ip: "8.8.8.8" }); - console.log(result); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Bulk IP Reputation @@ -471,20 +668,31 @@ main().catch(console.error); `POST /v1.0/security` ```typescript -// Runnable example: Bulk IP Reputation (POST /v1.0/security) -// Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object -import { Configuration, IPReputationApi } from "whoisfreaks"; +// Bulk IP Reputation: POST https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkIpReputation.ts +import { Configuration, IPReputationApi, ResponseError, type BulkGeolocationRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new IPReputationApi(config); -async function main() { - const result = await api.bulkIpReputation({ bulkIpReputationRequest: {} }); - console.log(result); +// bulkIpReputation({ bulkGeolocationRequest }) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main(): Promise { + const body: BulkGeolocationRequest = { ips: ["8.8.8.8", "1.1.1.1"] }; + const results = await api.bulkIpReputation({ bulkGeolocationRequest: body }); + console.log(JSON.stringify(results, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Domain Reputation @@ -494,21 +702,31 @@ main().catch(console.error); `GET /v1/domain/security` ```typescript -// Runnable example: Domain Reputation Lookup (GET /v1/domain/security) -// Parameters for domainReputation (GET /v1/domain/security): -// - domainName (string, required): The domain name to assess -// - format (string (one of: json, xml), optional) -import { Configuration, DomainReputationApi } from "whoisfreaks"; +// Domain Reputation Lookup: GET https://api.whoisfreaks.com/v1/domain/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DomainReputation.ts +import { Configuration, DomainReputationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DomainReputationApi(config); -async function main() { - const result = await api.domainReputation({ domainName: "example.com", format: undefined }); - console.log(result); +// domainReputation({ domainName, format? }) +// domainName (string, required): The domain name to assess +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.domainReputation({ domainName: "amazon.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### ASN WHOIS @@ -518,21 +736,31 @@ main().catch(console.error); `GET /v2.0/asn-whois` ```typescript -// Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) -// Parameters for asnWhois (GET /v2.0/asn-whois): -// - asn (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, ASNWHOISApi } from "whoisfreaks"; +// ASN WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/asn-whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx AsnWhois.ts +import { Configuration, ASNWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new ASNWHOISApi(config); -async function main() { - const result = await api.asnWhois({ asn: "AS15169", format: undefined }); - console.log(result); +// asnWhois({ asn, format? }) +// asn (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.asnWhois({ asn: "as15169" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### IP WHOIS @@ -542,21 +770,31 @@ main().catch(console.error); `GET /v1.0/ip-whois` ```typescript -// Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) -// Parameters for ipWhois (GET /v1.0/ip-whois): -// - ip (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, IPWHOISApi } from "whoisfreaks"; +// IP WHOIS Lookup: GET https://api.whoisfreaks.com/v1.0/ip-whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx IpWhois.ts +import { Configuration, IPWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new IPWHOISApi(config); -async function main() { - const result = await api.ipWhois({ ip: "8.8.8.8", format: undefined }); - console.log(result); +// ipWhois({ ip, format? }) +// ip (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.ipWhois({ ip: "8.8.8.8" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Account @@ -566,20 +804,29 @@ main().catch(console.error); `GET /v1.0/api-key/rotate` ```typescript -// Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) -// Parameters for rotateApiKey (GET /v1.0/api-key/rotate): -// (no parameters; the API key is set on the client) -import { Configuration, AccountApi } from "whoisfreaks"; +// Rotate API Key: GET https://api.whoisfreaks.com/v1.0/api-key/rotate +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx RotateApiKey.ts +import { Configuration, AccountApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new AccountApi(config); -async function main() { - const result = await api.rotateApiKey({ }); - console.log(result); +// rotateApiKey() takes no parameters. +async function main(): Promise { + const newKey = await api.rotateApiKey(); // use this key from now on + console.log("New API key:", newKey); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Account Usage @@ -587,20 +834,29 @@ main().catch(console.error); `GET /v1.0/whoisapi/usage` ```typescript -// Runnable example: Account Usage (GET /v1.0/whoisapi/usage) -// Parameters for accountUsage (GET /v1.0/whoisapi/usage): -// (no parameters; the API key is set on the client) -import { Configuration, AccountApi } from "whoisfreaks"; +// Account Usage: GET https://api.whoisfreaks.com/v1.0/whoisapi/usage +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx AccountUsage.ts +import { Configuration, AccountApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new AccountApi(config); -async function main() { - const result = await api.accountUsage({ }); - console.log(result); +// accountUsage() takes no parameters. +async function main(): Promise { + const result = await api.accountUsage(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Database File Status (Public) @@ -608,20 +864,28 @@ main().catch(console.error); `GET /v3.4/status` ```typescript -// Runnable example: Database File Status (Public) (GET /v3.4/status) -// Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) -import { Configuration, AccountApi } from "whoisfreaks"; +// Database File Status (Public): GET https://files.whoisfreaks.com/v3.4/status +// Run (public endpoint, no API key needed): npx tsx DatabaseFileStatus.ts +import { AccountApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once -const api = new AccountApi(config); +// Public endpoint: no API key needed. +const api = new AccountApi(); -async function main() { - const result = await api.databaseFileStatus({ }); - console.log(result); +// databaseFileStatus() takes no parameters. +async function main(): Promise { + const result = await api.databaseFileStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - Newly Registered @@ -631,22 +895,36 @@ main().catch(console.error); `GET /v3.1/download/domainer/gtld` ```typescript -// Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) -// Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered gTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyGtld.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyGtld({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyGtld({ whois, date?, tlds? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const blob = await api.dbNewlyGtld({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyGtld.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Newly Registered ccTLD (CSV) @@ -654,22 +932,36 @@ main().catch(console.error); `GET /v3.1/download/domainer/cctld` ```typescript -// Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) -// Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered ccTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyCctld.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyCctld({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyCctld({ whois, date?, tlds? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const blob = await api.dbNewlyCctld({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyCctld.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Newly Registered gTLD Cleaned WHOIS (CSV) @@ -677,20 +969,34 @@ main().catch(console.error); `GET /v3.1/download/domainer/gtld/cleaned` ```typescript -// Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) -// Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered gTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyGtldCleaned.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyGtldCleaned({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbNewlyGtldCleaned({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbNewlyGtldCleaned({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyGtldCleaned.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Newly Registered ccTLD Cleaned WHOIS (CSV) @@ -698,20 +1004,34 @@ main().catch(console.error); `GET /v3.1/download/domainer/cctld/cleaned` ```typescript -// Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) -// Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered ccTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyCctldCleaned.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyCctldCleaned({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbNewlyCctldCleaned({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbNewlyCctldCleaned({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyCctldCleaned.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Newly Registered gTLD (JSON) @@ -719,21 +1039,32 @@ main().catch(console.error); `GET /v3.1/domains/newly/gtld` ```typescript -// Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) -// Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered gTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyGtldJson.ts +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyGtldJson({ date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyGtldJson({ date?, tlds? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const domains = await api.dbNewlyGtldJson({ date: new Date("2026-10-01") }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Newly Registered ccTLD (JSON) @@ -741,21 +1072,32 @@ main().catch(console.error); `GET /v3.1/domains/newly/cctld` ```typescript -// Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) -// Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered ccTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyCctldJson.ts +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyCctldJson({ date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyCctldJson({ date?, tlds? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const domains = await api.dbNewlyCctldJson({ date: new Date("2026-10-01") }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Newly Registered With DNS @@ -763,20 +1105,34 @@ main().catch(console.error); `GET /v3.1/download/domainer/newly/dns` ```typescript -// Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) -// Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Newly Registered With DNS: GET https://files.whoisfreaks.com/v3.1/download/domainer/newly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyDns.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyDns({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbNewlyDns({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbNewlyDns({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyDns.json"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - Expiring & Dropped @@ -786,21 +1142,35 @@ main().catch(console.error); `GET /v3.1/download/domainer/expired` ```typescript -// Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) -// Parameters for dbExpired (GET /v3.1/download/domainer/expired): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Expiring Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbExpired.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbExpired({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbExpired({ whois, date? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbExpired({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbExpired.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Expiring Cleaned WHOIS @@ -808,20 +1178,34 @@ main().catch(console.error); `GET /v3.1/download/domainer/expired/cleaned` ```typescript -// Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) -// Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Expiring Cleaned WHOIS: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbExpiredCleaned.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbExpiredCleaned({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbExpiredCleaned({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbExpiredCleaned({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbExpiredCleaned.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Dropped Domains @@ -829,21 +1213,35 @@ main().catch(console.error); `GET /v3.1/download/domainer/dropped` ```typescript -// Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) -// Parameters for dbDropped (GET /v3.1/download/domainer/dropped): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Dropped Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDropped.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbDropped({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDropped({ whois, date? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDropped({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDropped.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Dropped Domains (JSON) @@ -851,21 +1249,32 @@ main().catch(console.error); `GET /v3.1/domains/dropped` ```typescript -// Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) -// Parameters for dbDroppedJson (GET /v3.1/domains/dropped): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; +// Dropped Domains (JSON): GET https://files.whoisfreaks.com/v3.1/domains/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDroppedJson.ts +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbDroppedJson({ date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbDroppedJson({ date?, tlds? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const domains = await api.dbDroppedJson({ date: new Date("2026-10-01") }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Dropped With Backlinks @@ -873,21 +1282,35 @@ main().catch(console.error); `GET /v3.3/download/domainer/dropped/backlinks` ```typescript -// Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) -// Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): -// - whois (boolean, optional) -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Dropped With Backlinks: GET https://files.whoisfreaks.com/v3.3/download/domainer/dropped/backlinks +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDroppedBacklinks.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbDroppedBacklinks({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDroppedBacklinks({ whois?, date? }) +// whois (boolean, optional) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDroppedBacklinks({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDroppedBacklinks.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - WHOIS @@ -897,20 +1320,34 @@ main().catch(console.error); `GET /v3.3/download/dbupdate/daily/domains/whois` ```typescript -// Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) -// Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// WHOIS Database Daily: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/daily/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbWhoisDaily.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesWHOISApi(config); -async function main() { - const result = await api.dbWhoisDaily({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbWhoisDaily({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbWhoisDaily({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbWhoisDaily.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### WHOIS Database Weekly @@ -918,20 +1355,34 @@ main().catch(console.error); `GET /v3.3/download/dbupdate/weekly/domains/whois` ```typescript -// Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) -// Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// WHOIS Database Weekly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/weekly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbWhoisWeekly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesWHOISApi(config); -async function main() { - const result = await api.dbWhoisWeekly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbWhoisWeekly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbWhoisWeekly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbWhoisWeekly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### WHOIS Database Monthly @@ -939,20 +1390,34 @@ main().catch(console.error); `GET /v3.3/download/dbupdate/monthly/domains/whois` ```typescript -// Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) -// Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// WHOIS Database Monthly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/monthly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbWhoisMonthly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesWHOISApi(config); -async function main() { - const result = await api.dbWhoisMonthly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbWhoisMonthly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbWhoisMonthly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbWhoisMonthly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - DNS @@ -962,20 +1427,34 @@ main().catch(console.error); `GET /v3.2/download/dbupdate/daily/dns` ```typescript -// Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) -// Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesDNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// DNS Database Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDnsDaily.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesDNSApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesDNSApi(config); -async function main() { - const result = await api.dbDnsDaily({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDnsDaily({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDnsDaily({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDnsDaily.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### DNS Database Weekly @@ -983,20 +1462,34 @@ main().catch(console.error); `GET /v3.2/download/dbupdate/weekly/dns` ```typescript -// Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) -// Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesDNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// DNS Database Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDnsWeekly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesDNSApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesDNSApi(config); -async function main() { - const result = await api.dbDnsWeekly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDnsWeekly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDnsWeekly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDnsWeekly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### DNS Database Monthly @@ -1004,20 +1497,34 @@ main().catch(console.error); `GET /v3.2/download/dbupdate/monthly/dns` ```typescript -// Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) -// Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesDNSApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// DNS Database Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDnsMonthly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesDNSApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesDNSApi(config); -async function main() { - const result = await api.dbDnsMonthly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDnsMonthly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDnsMonthly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDnsMonthly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - Subdomains @@ -1027,20 +1534,34 @@ main().catch(console.error); `GET /v3.2/download/dbupdate/daily/subdomains` ```typescript -// Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) -// Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesSubdomainsApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Subdomains Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbSubdomainsDaily.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesSubdomainsApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesSubdomainsApi(config); -async function main() { - const result = await api.dbSubdomainsDaily({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbSubdomainsDaily({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbSubdomainsDaily({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbSubdomainsDaily.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Subdomains Weekly @@ -1048,20 +1569,34 @@ main().catch(console.error); `GET /v3.2/download/dbupdate/weekly/subdomains` ```typescript -// Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) -// Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesSubdomainsApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Subdomains Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbSubdomainsWeekly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesSubdomainsApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesSubdomainsApi(config); -async function main() { - const result = await api.dbSubdomainsWeekly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbSubdomainsWeekly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbSubdomainsWeekly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbSubdomainsWeekly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Subdomains Monthly @@ -1069,20 +1604,34 @@ main().catch(console.error); `GET /v3.2/download/dbupdate/monthly/subdomains` ```typescript -// Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) -// Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesSubdomainsApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Subdomains Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbSubdomainsMonthly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesSubdomainsApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesSubdomainsApi(config); -async function main() { - const result = await api.dbSubdomainsMonthly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbSubdomainsMonthly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbSubdomainsMonthly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbSubdomainsMonthly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - IP Geolocation @@ -1092,20 +1641,29 @@ main().catch(console.error); `GET /v3.3/status/snapshot/ip/country` ```typescript -// Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) -// Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; +// IP to Country Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCountryStatus.ts +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCountryStatus({ }); - console.log(result); +// dbIpCountryStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpCountryStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### IP to Country Snapshot @@ -1113,20 +1671,34 @@ main().catch(console.error); `GET /v3.3/download/snapshot/ip/country` ```typescript -// Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) -// Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): -// - date (string, required) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// IP to Country Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCountry.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCountry({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpCountry({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpCountry({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpCountry.zip"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### IP to City Snapshot Status @@ -1134,20 +1706,29 @@ main().catch(console.error); `GET /v3.3/status/snapshot/ip/city` ```typescript -// Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) -// Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; +// IP to City Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCityStatus.ts +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCityStatus({ }); - console.log(result); +// dbIpCityStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpCityStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### IP to City Snapshot @@ -1155,20 +1736,34 @@ main().catch(console.error); `GET /v3.3/download/snapshot/ip/city` ```typescript -// Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) -// Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): -// - date (string, required) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// IP to City Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCity.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCity({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpCity({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpCity({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpCity.zip"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - ASN WHOIS @@ -1178,20 +1773,34 @@ main().catch(console.error); `GET /v3.3/download/snapshot/asn/whois` ```typescript -// Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) -// Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): -// - date (string, required) -import { Configuration, DatabasesASNWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// ASN WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbAsnWhois.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesASNWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesASNWHOISApi(config); -async function main() { - const result = await api.dbAsnWhois({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbAsnWhois({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbAsnWhois({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbAsnWhois.json.gz"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### ASN WHOIS Snapshot Status @@ -1199,20 +1808,29 @@ main().catch(console.error); `GET /v3.3/status/snapshot/asn/whois` ```typescript -// Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) -// Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesASNWHOISApi } from "whoisfreaks"; +// ASN WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbAsnWhoisStatus.ts +import { Configuration, DatabasesASNWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesASNWHOISApi(config); -async function main() { - const result = await api.dbAsnWhoisStatus({ }); - console.log(result); +// dbAsnWhoisStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbAsnWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - IP WHOIS @@ -1222,20 +1840,34 @@ main().catch(console.error); `GET /v3.3/download/snapshot/ip/whois` ```typescript -// Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) -// Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): -// - date (string, required) -import { Configuration, DatabasesIPWHOISApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// IP WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpWhois.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPWHOISApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPWHOISApi(config); -async function main() { - const result = await api.dbIpWhois({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpWhois({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpWhois({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpWhois.json.gz"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### IP WHOIS Snapshot Status @@ -1243,20 +1875,29 @@ main().catch(console.error); `GET /v3.3/status/snapshot/ip/whois` ```typescript -// Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) -// Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPWHOISApi } from "whoisfreaks"; +// IP WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpWhoisStatus.ts +import { Configuration, DatabasesIPWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPWHOISApi(config); -async function main() { - const result = await api.dbIpWhoisStatus({ }); - console.log(result); +// dbIpWhoisStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - IP Security @@ -1266,20 +1907,34 @@ main().catch(console.error); `GET /v3.3/download/snapshot/ip/security` ```typescript -// Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) -// Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): -// - date (string, required) -import { Configuration, DatabasesIPSecurityApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// IP Security Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpSecurity.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPSecurityApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPSecurityApi(config); -async function main() { - const result = await api.dbIpSecurity({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpSecurity({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpSecurity({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpSecurity.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### IP Security Snapshot Status @@ -1287,20 +1942,29 @@ main().catch(console.error); `GET /v3.3/status/snapshot/ip/security` ```typescript -// Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) -// Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPSecurityApi } from "whoisfreaks"; +// IP Security Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpSecurityStatus.ts +import { Configuration, DatabasesIPSecurityApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPSecurityApi(config); -async function main() { - const result = await api.dbIpSecurityStatus({ }); - console.log(result); +// dbIpSecurityStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpSecurityStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` ### Databases - Threat Feed @@ -1310,20 +1974,34 @@ main().catch(console.error); `GET /v3.4/download/threat-feed/phishing` ```typescript -// Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) -// Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download the daily phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedPhishing.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedPhishing({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// downloadThreatFeedPhishing({ date? }) +// date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main(): Promise { + const blob = await api.downloadThreatFeedPhishing({ date: "2026-10-01" }); // a Blob with the file's bytes + const file = "DownloadThreatFeedPhishing.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Download a sample of the phishing threat feed (CSV) @@ -1331,20 +2009,33 @@ main().catch(console.error); `GET /v3.4/download/threat-feed/phishing/sample` ```typescript -// Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) -// Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download a sample of the phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing/sample +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedPhishingSample.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedPhishingSample({ }); - console.log(result); +// downloadThreatFeedPhishingSample() takes no parameters. +async function main(): Promise { + const blob = await api.downloadThreatFeedPhishingSample(); // a Blob with the file's bytes + const file = "DownloadThreatFeedPhishingSample.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Download the daily malware threat feed (CSV) @@ -1352,20 +2043,34 @@ main().catch(console.error); `GET /v3.4/download/threat-feed/malware` ```typescript -// Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) -// Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download the daily malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedMalware.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedMalware({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// downloadThreatFeedMalware({ date? }) +// date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main(): Promise { + const blob = await api.downloadThreatFeedMalware({ date: "2026-10-01" }); // a Blob with the file's bytes + const file = "DownloadThreatFeedMalware.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Download a sample of the malware threat feed (CSV) @@ -1373,20 +2078,33 @@ main().catch(console.error); `GET /v3.4/download/threat-feed/malware/sample` ```typescript -// Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) -// Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download a sample of the malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware/sample +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedMalwareSample.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedMalwareSample({ }); - console.log(result); +// downloadThreatFeedMalwareSample() takes no parameters. +async function main(): Promise { + const blob = await api.downloadThreatFeedMalwareSample(); // a Blob with the file's bytes + const file = "DownloadThreatFeedMalwareSample.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Download the daily spam threat feed (CSV) @@ -1394,20 +2112,34 @@ main().catch(console.error); `GET /v3.4/download/threat-feed/spam` ```typescript -// Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) -// Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download the daily spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedSpam.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedSpam({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// downloadThreatFeedSpam({ date? }) +// date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main(): Promise { + const blob = await api.downloadThreatFeedSpam({ date: "2026-10-01" }); // a Blob with the file's bytes + const file = "DownloadThreatFeedSpam.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` #### Download a sample of the spam threat feed (CSV) @@ -1415,18 +2147,31 @@ main().catch(console.error); `GET /v3.4/download/threat-feed/spam/sample` ```typescript -// Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) -// Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; - -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Download a sample of the spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam/sample +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedSpamSample.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; + +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedSpamSample({ }); - console.log(result); +// downloadThreatFeedSpamSample() takes no parameters. +async function main(): Promise { + const blob = await api.downloadThreatFeedSpamSample(); // a Blob with the file's bytes + const file = "DownloadThreatFeedSpamSample.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); ``` diff --git a/examples/README.md b/examples/README.md index 6d82891..0789df5 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,7 +2,7 @@ Copy-paste, ready-to-run examples for **every one of the 60 endpoints** in **all 10 languages** (600 files). -Set `YOUR_API_KEY` to your key (from ) and run. Layout: `examples//.`. +Set the `WHOISFREAKS_API_KEY` environment variable to your key (from ) and run. Layout: `examples//.`. | Endpoint | Operation | Example file (per language) | |----------|-----------|------------------------------| diff --git a/examples/csharp/AccountUsage.cs b/examples/csharp/AccountUsage.cs index e107371..81514f7 100644 --- a/examples/csharp/AccountUsage.cs +++ b/examples/csharp/AccountUsage.cs @@ -1,16 +1,17 @@ // Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class AccountUsage { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new AccountApi(config); - var result = api.AccountUsage(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new AccountApi(config); + +AccountUsageResponse result = api.AccountUsage(); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/AsnWhois.cs b/examples/csharp/AsnWhois.cs index 7819c71..c4c66e8 100644 --- a/examples/csharp/AsnWhois.cs +++ b/examples/csharp/AsnWhois.cs @@ -1,17 +1,18 @@ // Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class AsnWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new ASNWHOISApi(config); - var result = api.AsnWhois("AS15169", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new ASNWHOISApi(config); + +AsnWhoisResponse result = api.AsnWhois("as15169"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/BulkDomainAvailabilityV2.cs b/examples/csharp/BulkDomainAvailabilityV2.cs index 01f0c15..1f40e39 100644 --- a/examples/csharp/BulkDomainAvailabilityV2.cs +++ b/examples/csharp/BulkDomainAvailabilityV2.cs @@ -1,19 +1,21 @@ // Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class BulkDomainAvailabilityV2 { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DomainAvailabilityApi(config); - var result = api.BulkDomainAvailabilityV2(new BulkDomainAvailabilityRequest(), null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DomainAvailabilityApi(config); + +var body = new BulkDomainAvailabilityRequest(domainNames: new List { "whoisfreaks.com", "example.com" }); +BulkDomainAvailabilityResponse result = api.BulkDomainAvailabilityV2(body); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/BulkGeolocation.cs b/examples/csharp/BulkGeolocation.cs index 548f01c..8027b13 100644 --- a/examples/csharp/BulkGeolocation.cs +++ b/examples/csharp/BulkGeolocation.cs @@ -1,17 +1,22 @@ // Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class BulkGeolocation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new GeolocationApi(config); - var result = api.BulkGeolocation(new BulkGeolocationRequest()); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new GeolocationApi(config); + +var body = new BulkGeolocationRequest(ips: new List { "8.8.8.8", "1.1.1.1" }); +List result = api.BulkGeolocation(body); +foreach (var item in result) +{ + Console.WriteLine(item.ToJson()); } diff --git a/examples/csharp/BulkIpReputation.cs b/examples/csharp/BulkIpReputation.cs index aa2ef78..77f7503 100644 --- a/examples/csharp/BulkIpReputation.cs +++ b/examples/csharp/BulkIpReputation.cs @@ -1,17 +1,22 @@ // Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class BulkIpReputation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new IPReputationApi(config); - var result = api.BulkIpReputation(new BulkIpReputationRequest()); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new IPReputationApi(config); + +var body = new BulkGeolocationRequest(ips: new List { "8.8.8.8", "1.1.1.1" }); +List result = api.BulkIpReputation(body); +foreach (var item in result) +{ + Console.WriteLine(item.ToJson()); } diff --git a/examples/csharp/BulkWhois.cs b/examples/csharp/BulkWhois.cs index 67085e4..e643804 100644 --- a/examples/csharp/BulkWhois.cs +++ b/examples/csharp/BulkWhois.cs @@ -1,18 +1,20 @@ // Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class BulkWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.BulkWhois(new BulkWhoisRequest(), null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +var body = new BulkWhoisRequest(domainNames: new List { "whoisfreaks.com", "jfreaks.com" }); +BulkWhoisResponse result = api.BulkWhois(body); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DatabaseFileStatus.cs b/examples/csharp/DatabaseFileStatus.cs index 48e2d61..b345efd 100644 --- a/examples/csharp/DatabaseFileStatus.cs +++ b/examples/csharp/DatabaseFileStatus.cs @@ -1,16 +1,15 @@ // Runnable example: Database File Status (Public) (GET /v3.4/status) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DatabaseFileStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new AccountApi(config); - var result = api.DatabaseFileStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +// Public endpoint: no API key needed. +var api = new AccountApi(config); + +DatabaseFileStatus result = api.DatabaseFileStatus(); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DbAsnWhois.cs b/examples/csharp/DbAsnWhois.cs index 0ac1679..e28f19c 100644 --- a/examples/csharp/DbAsnWhois.cs +++ b/examples/csharp/DbAsnWhois.cs @@ -1,16 +1,24 @@ // Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbAsnWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesASNWHOISApi(config); - var result = api.DbAsnWhois(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesASNWHOISApi(config); + +FileParameter download = api.DbAsnWhois(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbAsnWhois.json.gz"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbAsnWhoisStatus.cs b/examples/csharp/DbAsnWhoisStatus.cs index 0909b9e..48bd5e8 100644 --- a/examples/csharp/DbAsnWhoisStatus.cs +++ b/examples/csharp/DbAsnWhoisStatus.cs @@ -1,16 +1,17 @@ // Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbAsnWhoisStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesASNWHOISApi(config); - var result = api.DbAsnWhoisStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesASNWHOISApi(config); + +SnapshotStatus result = api.DbAsnWhoisStatus(); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DbDnsDaily.cs b/examples/csharp/DbDnsDaily.cs index 7a282ac..051079d 100644 --- a/examples/csharp/DbDnsDaily.cs +++ b/examples/csharp/DbDnsDaily.cs @@ -1,16 +1,24 @@ // Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDnsDaily { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesDNSApi(config); - var result = api.DbDnsDaily(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesDNSApi(config); + +FileParameter download = api.DbDnsDaily(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDnsDaily.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbDnsMonthly.cs b/examples/csharp/DbDnsMonthly.cs index 469795f..b821e8d 100644 --- a/examples/csharp/DbDnsMonthly.cs +++ b/examples/csharp/DbDnsMonthly.cs @@ -1,16 +1,24 @@ // Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDnsMonthly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesDNSApi(config); - var result = api.DbDnsMonthly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesDNSApi(config); + +FileParameter download = api.DbDnsMonthly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDnsMonthly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbDnsWeekly.cs b/examples/csharp/DbDnsWeekly.cs index 78dd5ed..a62ba0a 100644 --- a/examples/csharp/DbDnsWeekly.cs +++ b/examples/csharp/DbDnsWeekly.cs @@ -1,16 +1,24 @@ // Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDnsWeekly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesDNSApi(config); - var result = api.DbDnsWeekly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesDNSApi(config); + +FileParameter download = api.DbDnsWeekly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDnsWeekly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbDropped.cs b/examples/csharp/DbDropped.cs index 021d459..c5225c9 100644 --- a/examples/csharp/DbDropped.cs +++ b/examples/csharp/DbDropped.cs @@ -1,17 +1,25 @@ // Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDropped { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbDropped(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +FileParameter download = api.DbDropped(true, date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDropped.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbDroppedBacklinks.cs b/examples/csharp/DbDroppedBacklinks.cs index c412d49..d264def 100644 --- a/examples/csharp/DbDroppedBacklinks.cs +++ b/examples/csharp/DbDroppedBacklinks.cs @@ -1,17 +1,25 @@ // Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDroppedBacklinks { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbDroppedBacklinks(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +FileParameter download = api.DbDroppedBacklinks(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbDroppedBacklinks.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbDroppedJson.cs b/examples/csharp/DbDroppedJson.cs index 1452a0e..8e77a8a 100644 --- a/examples/csharp/DbDroppedJson.cs +++ b/examples/csharp/DbDroppedJson.cs @@ -1,17 +1,21 @@ // Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbDroppedJson { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbDroppedJson(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +List result = api.DbDroppedJson(date: new DateOnly(2026, 10, 1)); +foreach (var item in result) +{ + Console.WriteLine(item); } diff --git a/examples/csharp/DbExpired.cs b/examples/csharp/DbExpired.cs index ac7ba34..632d61b 100644 --- a/examples/csharp/DbExpired.cs +++ b/examples/csharp/DbExpired.cs @@ -1,17 +1,25 @@ // Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbExpired { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbExpired(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +FileParameter download = api.DbExpired(true, date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbExpired.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbExpiredCleaned.cs b/examples/csharp/DbExpiredCleaned.cs index 59ec09f..72ebeb3 100644 --- a/examples/csharp/DbExpiredCleaned.cs +++ b/examples/csharp/DbExpiredCleaned.cs @@ -1,16 +1,24 @@ // Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbExpiredCleaned { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesExpiringDroppedApi(config); - var result = api.DbExpiredCleaned(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesExpiringDroppedApi(config); + +FileParameter download = api.DbExpiredCleaned(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbExpiredCleaned.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbIpCity.cs b/examples/csharp/DbIpCity.cs index 7765251..f195823 100644 --- a/examples/csharp/DbIpCity.cs +++ b/examples/csharp/DbIpCity.cs @@ -1,16 +1,24 @@ // Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbIpCity { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPGeolocationApi(config); - var result = api.DbIpCity(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPGeolocationApi(config); + +FileParameter download = api.DbIpCity(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbIpCity.zip"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbIpCityStatus.cs b/examples/csharp/DbIpCityStatus.cs index 15afbad..417e2c6 100644 --- a/examples/csharp/DbIpCityStatus.cs +++ b/examples/csharp/DbIpCityStatus.cs @@ -1,16 +1,17 @@ // Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbIpCityStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPGeolocationApi(config); - var result = api.DbIpCityStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPGeolocationApi(config); + +SnapshotStatus result = api.DbIpCityStatus(); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DbIpCountry.cs b/examples/csharp/DbIpCountry.cs index dea857f..5502637 100644 --- a/examples/csharp/DbIpCountry.cs +++ b/examples/csharp/DbIpCountry.cs @@ -1,16 +1,24 @@ // Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbIpCountry { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPGeolocationApi(config); - var result = api.DbIpCountry(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPGeolocationApi(config); + +FileParameter download = api.DbIpCountry(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbIpCountry.zip"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbIpCountryStatus.cs b/examples/csharp/DbIpCountryStatus.cs index d4f947e..7cb3682 100644 --- a/examples/csharp/DbIpCountryStatus.cs +++ b/examples/csharp/DbIpCountryStatus.cs @@ -1,16 +1,17 @@ // Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbIpCountryStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPGeolocationApi(config); - var result = api.DbIpCountryStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPGeolocationApi(config); + +SnapshotStatus result = api.DbIpCountryStatus(); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DbIpSecurity.cs b/examples/csharp/DbIpSecurity.cs index 4a27e4f..179591c 100644 --- a/examples/csharp/DbIpSecurity.cs +++ b/examples/csharp/DbIpSecurity.cs @@ -1,16 +1,24 @@ // Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbIpSecurity { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPSecurityApi(config); - var result = api.DbIpSecurity(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPSecurityApi(config); + +FileParameter download = api.DbIpSecurity(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbIpSecurity.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbIpSecurityStatus.cs b/examples/csharp/DbIpSecurityStatus.cs index b9f0168..c585659 100644 --- a/examples/csharp/DbIpSecurityStatus.cs +++ b/examples/csharp/DbIpSecurityStatus.cs @@ -1,16 +1,17 @@ // Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbIpSecurityStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPSecurityApi(config); - var result = api.DbIpSecurityStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPSecurityApi(config); + +SnapshotStatus result = api.DbIpSecurityStatus(); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DbIpWhois.cs b/examples/csharp/DbIpWhois.cs index dd56797..c87f6d1 100644 --- a/examples/csharp/DbIpWhois.cs +++ b/examples/csharp/DbIpWhois.cs @@ -1,16 +1,24 @@ // Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbIpWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPWHOISApi(config); - var result = api.DbIpWhois(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPWHOISApi(config); + +FileParameter download = api.DbIpWhois(new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbIpWhois.json.gz"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbIpWhoisStatus.cs b/examples/csharp/DbIpWhoisStatus.cs index 9007773..29f8bfc 100644 --- a/examples/csharp/DbIpWhoisStatus.cs +++ b/examples/csharp/DbIpWhoisStatus.cs @@ -1,16 +1,17 @@ // Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DbIpWhoisStatus { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesIPWHOISApi(config); - var result = api.DbIpWhoisStatus(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesIPWHOISApi(config); + +SnapshotStatus result = api.DbIpWhoisStatus(); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DbNewlyCctld.cs b/examples/csharp/DbNewlyCctld.cs index a2aaf08..fcaddfc 100644 --- a/examples/csharp/DbNewlyCctld.cs +++ b/examples/csharp/DbNewlyCctld.cs @@ -1,18 +1,26 @@ // Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyCctld { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyCctld(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyCctld(true, date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyCctld.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbNewlyCctldCleaned.cs b/examples/csharp/DbNewlyCctldCleaned.cs index 8c8889e..be7e980 100644 --- a/examples/csharp/DbNewlyCctldCleaned.cs +++ b/examples/csharp/DbNewlyCctldCleaned.cs @@ -1,16 +1,24 @@ // Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyCctldCleaned { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyCctldCleaned(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyCctldCleaned(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyCctldCleaned.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbNewlyCctldJson.cs b/examples/csharp/DbNewlyCctldJson.cs index dabb615..00e435f 100644 --- a/examples/csharp/DbNewlyCctldJson.cs +++ b/examples/csharp/DbNewlyCctldJson.cs @@ -1,17 +1,21 @@ // Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyCctldJson { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyCctldJson(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +List result = api.DbNewlyCctldJson(date: new DateOnly(2026, 10, 1)); +foreach (var item in result) +{ + Console.WriteLine(item); } diff --git a/examples/csharp/DbNewlyDns.cs b/examples/csharp/DbNewlyDns.cs index d83abe0..f8cc88e 100644 --- a/examples/csharp/DbNewlyDns.cs +++ b/examples/csharp/DbNewlyDns.cs @@ -1,16 +1,24 @@ // Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyDns { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyDns(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyDns(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyDns.json"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbNewlyGtld.cs b/examples/csharp/DbNewlyGtld.cs index ab9e63e..a5b83c9 100644 --- a/examples/csharp/DbNewlyGtld.cs +++ b/examples/csharp/DbNewlyGtld.cs @@ -1,18 +1,26 @@ // Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyGtld { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyGtld(false, DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyGtld(true, date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyGtld.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbNewlyGtldCleaned.cs b/examples/csharp/DbNewlyGtldCleaned.cs index ffe41e9..160776c 100644 --- a/examples/csharp/DbNewlyGtldCleaned.cs +++ b/examples/csharp/DbNewlyGtldCleaned.cs @@ -1,16 +1,24 @@ // Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyGtldCleaned { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyGtldCleaned(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +FileParameter download = api.DbNewlyGtldCleaned(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbNewlyGtldCleaned.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbNewlyGtldJson.cs b/examples/csharp/DbNewlyGtldJson.cs index 57d1ba2..2430365 100644 --- a/examples/csharp/DbNewlyGtldJson.cs +++ b/examples/csharp/DbNewlyGtldJson.cs @@ -1,17 +1,21 @@ // Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbNewlyGtldJson { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesNewlyRegisteredApi(config); - var result = api.DbNewlyGtldJson(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), null); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesNewlyRegisteredApi(config); + +List result = api.DbNewlyGtldJson(date: new DateOnly(2026, 10, 1)); +foreach (var item in result) +{ + Console.WriteLine(item); } diff --git a/examples/csharp/DbSubdomainsDaily.cs b/examples/csharp/DbSubdomainsDaily.cs index 02e9cc2..1cdb7a7 100644 --- a/examples/csharp/DbSubdomainsDaily.cs +++ b/examples/csharp/DbSubdomainsDaily.cs @@ -1,16 +1,24 @@ // Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbSubdomainsDaily { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesSubdomainsApi(config); - var result = api.DbSubdomainsDaily(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesSubdomainsApi(config); + +FileParameter download = api.DbSubdomainsDaily(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbSubdomainsDaily.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbSubdomainsMonthly.cs b/examples/csharp/DbSubdomainsMonthly.cs index 58fe919..cf620e1 100644 --- a/examples/csharp/DbSubdomainsMonthly.cs +++ b/examples/csharp/DbSubdomainsMonthly.cs @@ -1,16 +1,24 @@ // Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbSubdomainsMonthly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesSubdomainsApi(config); - var result = api.DbSubdomainsMonthly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesSubdomainsApi(config); + +FileParameter download = api.DbSubdomainsMonthly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbSubdomainsMonthly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbSubdomainsWeekly.cs b/examples/csharp/DbSubdomainsWeekly.cs index 7c2157b..089c283 100644 --- a/examples/csharp/DbSubdomainsWeekly.cs +++ b/examples/csharp/DbSubdomainsWeekly.cs @@ -1,16 +1,24 @@ // Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbSubdomainsWeekly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesSubdomainsApi(config); - var result = api.DbSubdomainsWeekly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesSubdomainsApi(config); + +FileParameter download = api.DbSubdomainsWeekly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbSubdomainsWeekly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbWhoisDaily.cs b/examples/csharp/DbWhoisDaily.cs index 1347c6c..b77b426 100644 --- a/examples/csharp/DbWhoisDaily.cs +++ b/examples/csharp/DbWhoisDaily.cs @@ -1,16 +1,24 @@ // Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbWhoisDaily { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesWHOISApi(config); - var result = api.DbWhoisDaily(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesWHOISApi(config); + +FileParameter download = api.DbWhoisDaily(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbWhoisDaily.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbWhoisMonthly.cs b/examples/csharp/DbWhoisMonthly.cs index dae57c7..3793b62 100644 --- a/examples/csharp/DbWhoisMonthly.cs +++ b/examples/csharp/DbWhoisMonthly.cs @@ -1,16 +1,24 @@ // Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbWhoisMonthly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesWHOISApi(config); - var result = api.DbWhoisMonthly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesWHOISApi(config); + +FileParameter download = api.DbWhoisMonthly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbWhoisMonthly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DbWhoisWeekly.cs b/examples/csharp/DbWhoisWeekly.cs index aeeba7e..5c9c385 100644 --- a/examples/csharp/DbWhoisWeekly.cs +++ b/examples/csharp/DbWhoisWeekly.cs @@ -1,16 +1,24 @@ // Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DbWhoisWeekly { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesWHOISApi(config); - var result = api.DbWhoisWeekly(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesWHOISApi(config); + +FileParameter download = api.DbWhoisWeekly(date: new DateOnly(2026, 10, 1)); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DbWhoisWeekly.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DnsBulk.cs b/examples/csharp/DnsBulk.cs index 5c2c52d..e52bd51 100644 --- a/examples/csharp/DnsBulk.cs +++ b/examples/csharp/DnsBulk.cs @@ -1,19 +1,21 @@ // Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object using System; +using System.Collections.Generic; using WhoisFreaks.Api; using WhoisFreaks.Client; using WhoisFreaks.Model; -class DnsBulk { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DNSApi(config); - var result = api.DnsBulk("value", new DnsBulkRequest(), null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DNSApi(config); + +var body = new DnsBulkRequest(domainNames: new List { "whoisfreaks.com", "example.com" }); +BulkDnsResponse result = api.DnsBulk("A,MX,TXT", body); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DnsHistorical.cs b/examples/csharp/DnsHistorical.cs index 3041d4f..4e8f356 100644 --- a/examples/csharp/DnsHistorical.cs +++ b/examples/csharp/DnsHistorical.cs @@ -1,4 +1,5 @@ // Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) @@ -7,13 +8,13 @@ using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DnsHistorical { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DNSApi(config); - var result = api.DnsHistorical("example.com", "value", null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DNSApi(config); + +HistoricalDnsResponse result = api.DnsHistorical("whoisfreaks.com", "A,MX,TXT", page: 1); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DnsLive.cs b/examples/csharp/DnsLive.cs index 449e94b..01c40b5 100644 --- a/examples/csharp/DnsLive.cs +++ b/examples/csharp/DnsLive.cs @@ -1,19 +1,20 @@ // Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DnsLive { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DNSApi(config); - var result = api.DnsLive("example.com", "8.8.8.8", "value", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DNSApi(config); + +DnsResponse result = api.DnsLive("A,MX,TXT", domainName: "whoisfreaks.com"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DnsReverse.cs b/examples/csharp/DnsReverse.cs index 332237e..590c52e 100644 --- a/examples/csharp/DnsReverse.cs +++ b/examples/csharp/DnsReverse.cs @@ -1,4 +1,5 @@ // Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) @@ -8,13 +9,13 @@ using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DnsReverse { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DNSApi(config); - var result = api.DnsReverse("value", "a", true, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DNSApi(config); + +ReverseDnsResponse result = api.DnsReverse("8.8.8.8", "a", page: 1); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DomainAvailabilityV2.cs b/examples/csharp/DomainAvailabilityV2.cs index 8f88b52..00c9358 100644 --- a/examples/csharp/DomainAvailabilityV2.cs +++ b/examples/csharp/DomainAvailabilityV2.cs @@ -1,4 +1,5 @@ // Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. @@ -7,13 +8,13 @@ using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DomainAvailabilityV2 { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DomainAvailabilityApi(config); - var result = api.DomainAvailabilityV2("example.com", null, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DomainAvailabilityApi(config); + +DomainAvailabilityResponse result = api.DomainAvailabilityV2("google.com", sug: true, count: 5); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DomainReputation.cs b/examples/csharp/DomainReputation.cs index 95fe3d2..e258359 100644 --- a/examples/csharp/DomainReputation.cs +++ b/examples/csharp/DomainReputation.cs @@ -1,17 +1,18 @@ // Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class DomainReputation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DomainReputationApi(config); - var result = api.DomainReputation("example.com", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DomainReputationApi(config); + +DomainReputationResponse result = api.DomainReputation("amazon.com"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/DownloadThreatFeedMalware.cs b/examples/csharp/DownloadThreatFeedMalware.cs index e17774c..fa57c51 100644 --- a/examples/csharp/DownloadThreatFeedMalware.cs +++ b/examples/csharp/DownloadThreatFeedMalware.cs @@ -1,16 +1,24 @@ // Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedMalware { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedMalware(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedMalware(date: "2026-10-01"); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedMalware.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DownloadThreatFeedMalwareSample.cs b/examples/csharp/DownloadThreatFeedMalwareSample.cs index 798430c..d94e188 100644 --- a/examples/csharp/DownloadThreatFeedMalwareSample.cs +++ b/examples/csharp/DownloadThreatFeedMalwareSample.cs @@ -1,16 +1,24 @@ // Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedMalwareSample { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedMalwareSample(); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedMalwareSample(); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedMalwareSample.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DownloadThreatFeedPhishing.cs b/examples/csharp/DownloadThreatFeedPhishing.cs index 7d5dca6..4f2ee34 100644 --- a/examples/csharp/DownloadThreatFeedPhishing.cs +++ b/examples/csharp/DownloadThreatFeedPhishing.cs @@ -1,16 +1,24 @@ // Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedPhishing { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedPhishing(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedPhishing(date: "2026-10-01"); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedPhishing.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DownloadThreatFeedPhishingSample.cs b/examples/csharp/DownloadThreatFeedPhishingSample.cs index 77aea96..d7a2772 100644 --- a/examples/csharp/DownloadThreatFeedPhishingSample.cs +++ b/examples/csharp/DownloadThreatFeedPhishingSample.cs @@ -1,16 +1,24 @@ // Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedPhishingSample { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedPhishingSample(); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedPhishingSample(); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedPhishingSample.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DownloadThreatFeedSpam.cs b/examples/csharp/DownloadThreatFeedSpam.cs index 5a785f2..908c2e1 100644 --- a/examples/csharp/DownloadThreatFeedSpam.cs +++ b/examples/csharp/DownloadThreatFeedSpam.cs @@ -1,16 +1,24 @@ // Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedSpam { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedSpam(DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd")); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedSpam(date: "2026-10-01"); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedSpam.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/DownloadThreatFeedSpamSample.cs b/examples/csharp/DownloadThreatFeedSpamSample.cs index 6bbb7dc..9dd1fed 100644 --- a/examples/csharp/DownloadThreatFeedSpamSample.cs +++ b/examples/csharp/DownloadThreatFeedSpamSample.cs @@ -1,16 +1,24 @@ // Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) using System; +using System.IO; using WhoisFreaks.Api; using WhoisFreaks.Client; -class DownloadThreatFeedSpamSample { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new DatabasesThreatFeedApi(config); - var result = api.DownloadThreatFeedSpamSample(); - Console.WriteLine(result); - } +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new DatabasesThreatFeedApi(config); + +FileParameter download = api.DownloadThreatFeedSpamSample(); +// The SDK returns the response body as a stream: copy it to a file. +var path = Path.GetFullPath("DownloadThreatFeedSpamSample.csv"); +using (Stream input = download.Content) +using (FileStream output = File.Create(path)) +{ + input.CopyTo(output); } +Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}"); diff --git a/examples/csharp/Geolocation.cs b/examples/csharp/Geolocation.cs index 39fe435..156908e 100644 --- a/examples/csharp/Geolocation.cs +++ b/examples/csharp/Geolocation.cs @@ -1,16 +1,17 @@ // Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class Geolocation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new GeolocationApi(config); - var result = api.Geolocation("8.8.8.8"); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new GeolocationApi(config); + +GeolocationResponse result = api.Geolocation("8.8.8.8"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/IpReputation.cs b/examples/csharp/IpReputation.cs index ec2a0f9..f22c769 100644 --- a/examples/csharp/IpReputation.cs +++ b/examples/csharp/IpReputation.cs @@ -1,16 +1,17 @@ // Runnable example: IP Reputation Lookup (GET /v1.0/security) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class IpReputation { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new IPReputationApi(config); - var result = api.IpReputation("8.8.8.8"); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new IPReputationApi(config); + +IpReputationResponse result = api.IpReputation("8.8.8.8"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/IpWhois.cs b/examples/csharp/IpWhois.cs index 9aad385..2831499 100644 --- a/examples/csharp/IpWhois.cs +++ b/examples/csharp/IpWhois.cs @@ -1,17 +1,18 @@ // Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class IpWhois { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new IPWHOISApi(config); - var result = api.IpWhois("8.8.8.8", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new IPWHOISApi(config); + +IpWhoisResponse result = api.IpWhois("8.8.8.8"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/README.md b/examples/csharp/README.md index e57c9d2..e7fd537 100644 --- a/examples/csharp/README.md +++ b/examples/csharp/README.md @@ -1,107 +1,107 @@ -# C# / .NET — Runnable Examples +# C# / .NET Runnable Examples -Install: see the [C# / .NET guide](../../docs/languages/csharp.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [C# / .NET guide](../../docs/languages/csharp.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.cs`](WhoisLive.cs) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.cs`](BulkWhois.cs) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.cs`](WhoisHistory.cs) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.cs`](WhoisReverse.cs) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.cs`](WhoisLive.cs): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.cs`](BulkWhois.cs): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.cs`](WhoisHistory.cs): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.cs`](WhoisReverse.cs): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.cs`](DnsLive.cs) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.cs`](DnsHistorical.cs) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.cs`](DnsReverse.cs) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.cs`](DnsBulk.cs) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.cs`](DnsLive.cs): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.cs`](DnsHistorical.cs): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.cs`](DnsReverse.cs): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.cs`](DnsBulk.cs): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.cs`](DomainAvailabilityV2.cs) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.cs`](BulkDomainAvailabilityV2.cs) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.cs`](DomainAvailabilityV2.cs): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.cs`](BulkDomainAvailabilityV2.cs): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.cs`](Typosquatting.cs) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.cs`](Typosquatting.cs): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.cs`](SslLookup.cs) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.cs`](SslLookup.cs): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.cs`](Geolocation.cs) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.cs`](BulkGeolocation.cs) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.cs`](Geolocation.cs): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.cs`](BulkGeolocation.cs): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.cs`](Subdomains.cs) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.cs`](Subdomains.cs): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.cs`](IpReputation.cs) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.cs`](BulkIpReputation.cs) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.cs`](IpReputation.cs): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.cs`](BulkIpReputation.cs): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.cs`](DomainReputation.cs) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.cs`](DomainReputation.cs): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.cs`](AsnWhois.cs) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.cs`](AsnWhois.cs): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.cs`](IpWhois.cs) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.cs`](IpWhois.cs): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.cs`](RotateApiKey.cs) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.cs`](AccountUsage.cs) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.cs`](DatabaseFileStatus.cs) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.cs`](RotateApiKey.cs): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.cs`](AccountUsage.cs): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.cs`](DatabaseFileStatus.cs): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.cs`](DbNewlyGtld.cs) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.cs`](DbNewlyCctld.cs) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.cs`](DbNewlyGtldCleaned.cs) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.cs`](DbNewlyCctldCleaned.cs) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.cs`](DbNewlyGtldJson.cs) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.cs`](DbNewlyCctldJson.cs) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.cs`](DbNewlyDns.cs) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.cs`](DbNewlyGtld.cs): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.cs`](DbNewlyCctld.cs): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.cs`](DbNewlyGtldCleaned.cs): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.cs`](DbNewlyCctldCleaned.cs): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.cs`](DbNewlyGtldJson.cs): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.cs`](DbNewlyCctldJson.cs): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.cs`](DbNewlyDns.cs): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.cs`](DbExpired.cs) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.cs`](DbExpiredCleaned.cs) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.cs`](DbDropped.cs) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.cs`](DbDroppedJson.cs) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.cs`](DbDroppedBacklinks.cs) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.cs`](DbExpired.cs): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.cs`](DbExpiredCleaned.cs): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.cs`](DbDropped.cs): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.cs`](DbDroppedJson.cs): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.cs`](DbDroppedBacklinks.cs): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.cs`](DbWhoisDaily.cs) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.cs`](DbWhoisWeekly.cs) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.cs`](DbWhoisMonthly.cs) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.cs`](DbWhoisDaily.cs): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.cs`](DbWhoisWeekly.cs): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.cs`](DbWhoisMonthly.cs): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.cs`](DbDnsDaily.cs) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.cs`](DbDnsWeekly.cs) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.cs`](DbDnsMonthly.cs) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.cs`](DbDnsDaily.cs): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.cs`](DbDnsWeekly.cs): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.cs`](DbDnsMonthly.cs): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.cs`](DbSubdomainsDaily.cs) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.cs`](DbSubdomainsWeekly.cs) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.cs`](DbSubdomainsMonthly.cs) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.cs`](DbSubdomainsDaily.cs): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.cs`](DbSubdomainsWeekly.cs): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.cs`](DbSubdomainsMonthly.cs): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.cs`](DbIpCountryStatus.cs) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.cs`](DbIpCountry.cs) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.cs`](DbIpCityStatus.cs) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.cs`](DbIpCity.cs) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.cs`](DbIpCountryStatus.cs): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.cs`](DbIpCountry.cs): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.cs`](DbIpCityStatus.cs): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.cs`](DbIpCity.cs): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.cs`](DbAsnWhois.cs) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.cs`](DbAsnWhoisStatus.cs) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.cs`](DbAsnWhois.cs): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.cs`](DbAsnWhoisStatus.cs): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.cs`](DbIpWhois.cs) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.cs`](DbIpWhoisStatus.cs) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.cs`](DbIpWhois.cs): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.cs`](DbIpWhoisStatus.cs): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.cs`](DbIpSecurity.cs) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.cs`](DbIpSecurityStatus.cs) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.cs`](DbIpSecurity.cs): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.cs`](DbIpSecurityStatus.cs): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.cs`](DownloadThreatFeedPhishing.cs) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.cs`](DownloadThreatFeedPhishingSample.cs) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.cs`](DownloadThreatFeedMalware.cs) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.cs`](DownloadThreatFeedMalwareSample.cs) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.cs`](DownloadThreatFeedSpam.cs) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.cs`](DownloadThreatFeedSpamSample.cs) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.cs`](DownloadThreatFeedPhishing.cs): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.cs`](DownloadThreatFeedPhishingSample.cs): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.cs`](DownloadThreatFeedMalware.cs): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.cs`](DownloadThreatFeedMalwareSample.cs): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.cs`](DownloadThreatFeedSpam.cs): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.cs`](DownloadThreatFeedSpamSample.cs): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/csharp/RotateApiKey.cs b/examples/csharp/RotateApiKey.cs index a4cb1ab..8d4f86f 100644 --- a/examples/csharp/RotateApiKey.cs +++ b/examples/csharp/RotateApiKey.cs @@ -1,16 +1,17 @@ // Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; -class RotateApiKey { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new AccountApi(config); - var result = api.RotateApiKey(); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new AccountApi(config); + +string newKey = api.RotateApiKey(); +// The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY. +Console.WriteLine($"New API key: {newKey}"); diff --git a/examples/csharp/SslLookup.cs b/examples/csharp/SslLookup.cs index 45bc3e6..55f4c51 100644 --- a/examples/csharp/SslLookup.cs +++ b/examples/csharp/SslLookup.cs @@ -1,4 +1,5 @@ // Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) @@ -7,13 +8,13 @@ using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class SslLookup { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new SSLApi(config); - var result = api.SslLookup("example.com", null, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new SSLApi(config); + +SslResponse result = api.SslLookup("whoisfreaks.com"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/Subdomains.cs b/examples/csharp/Subdomains.cs index c8a2ec4..765d945 100644 --- a/examples/csharp/Subdomains.cs +++ b/examples/csharp/Subdomains.cs @@ -1,4 +1,5 @@ // Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -9,13 +10,13 @@ using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class Subdomains { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new SubdomainsApi(config); - var result = api.Subdomains("example.com", "2000-01-01", DateTime.UtcNow.ToString("yyyy-MM-dd"), null, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new SubdomainsApi(config); + +SubdomainsResponse result = api.Subdomains("whoisfreaks.com", page: 1); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/Typosquatting.cs b/examples/csharp/Typosquatting.cs index 71ce6bb..07ab5d7 100644 --- a/examples/csharp/Typosquatting.cs +++ b/examples/csharp/Typosquatting.cs @@ -1,4 +1,5 @@ // Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) @@ -6,13 +7,13 @@ using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class Typosquatting { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new TyposquattingApi(config); - var result = api.Typosquatting(null, null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new TyposquattingApi(config); + +TyposquattingResponse result = api.Typosquatting(keyword: "whoisfreaks"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/WhoisHistoricalOrReverse.cs b/examples/csharp/WhoisHistoricalOrReverse.cs deleted file mode 100644 index 0e16921..0000000 --- a/examples/csharp/WhoisHistoricalOrReverse.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Runnable example: WHOIS Historical or Reverse Lookup (GET /v1.0/whois) -// Parameters for whoisHistoricalOrReverse (GET /v1.0/whois): -// - apiKey (string, required): Your WHOISFreaks API key -// - whois (string (one of: historical, reverse), required) -// - domainName (string, required): Required for historical lookup -// - keyword (string, optional): For reverse — domain keyword search -// - email (string, optional): For reverse — registrant email search -// - owner (string, optional): For reverse — registrant name search -// - company (string, optional): For reverse — company name search -// - mode (string (one of: default, mini), optional) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -using System; -using WhoisFreaks.Api; -using WhoisFreaks.Client; - -class WhoisHistoricalOrReverse { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - var api = new WHOISApi(config); - var resp = api.WhoisHistoricalOrReverseWithHttpInfo("YOUR_API_KEY", "historical", "example.com", true, null, null, null, null, null, null, null); - Console.WriteLine($"status: {(int)resp.StatusCode}"); - Console.WriteLine(resp.Data); - } -} diff --git a/examples/csharp/WhoisHistory.cs b/examples/csharp/WhoisHistory.cs index c08c8f6..ce7d07a 100644 --- a/examples/csharp/WhoisHistory.cs +++ b/examples/csharp/WhoisHistory.cs @@ -1,18 +1,18 @@ // Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class WhoisHistory { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.WhoisHistory("example.com", null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +WhoisHistoricalResponse result = api.WhoisHistory("whoisfreaks.com"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/WhoisLive.cs b/examples/csharp/WhoisLive.cs index 3c5b922..b29991f 100644 --- a/examples/csharp/WhoisLive.cs +++ b/examples/csharp/WhoisLive.cs @@ -1,17 +1,18 @@ // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class WhoisLive { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.WhoisLive("example.com", null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +WhoisResponse result = api.WhoisLive("whoisfreaks.com"); +Console.WriteLine(result.ToJson()); diff --git a/examples/csharp/WhoisReverse.cs b/examples/csharp/WhoisReverse.cs index d9af0ca..13a6cdd 100644 --- a/examples/csharp/WhoisReverse.cs +++ b/examples/csharp/WhoisReverse.cs @@ -1,4 +1,5 @@ // Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run` // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number @@ -6,13 +7,13 @@ using System; using WhoisFreaks.Api; using WhoisFreaks.Client; +using WhoisFreaks.Model; -class WhoisReverse { - static void Main() { - var config = new Configuration { BasePath = "https://api.whoisfreaks.com" }; - config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once - var api = new WHOISApi(config); - var result = api.WhoisReverse("value", null, null); - Console.WriteLine(result); - } -} +var config = new Configuration(); +var apiKey = Environment.GetEnvironmentVariable("WHOISFREAKS_API_KEY") + ?? throw new InvalidOperationException("Set the WHOISFREAKS_API_KEY environment variable"); +config.AddApiKey("apiKey", apiKey); // set once, sent with every call +var api = new WHOISApi(config); + +ReverseWhoisResponse result = api.WhoisReverse("whoisfreaks", page: 1); +Console.WriteLine(result.ToJson()); diff --git a/examples/go/AccountUsage.go b/examples/go/AccountUsage.go index a85457c..cc81dfe 100644 --- a/examples/go/AccountUsage.go +++ b/examples/go/AccountUsage.go @@ -1,23 +1,30 @@ // Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.AccountAPI.AccountUsage(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.AccountAPI.AccountUsage(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/AsnWhois.go b/examples/go/AsnWhois.go index 15a9b90..974fec6 100644 --- a/examples/go/AsnWhois.go +++ b/examples/go/AsnWhois.go @@ -1,24 +1,31 @@ // Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.ASNWHOISAPI.AsnWhois(ctx).Asn("AS15169").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.ASNWHOISAPI.AsnWhois(ctx).Asn("as15169").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/BulkDomainAvailabilityV2.go b/examples/go/BulkDomainAvailabilityV2.go index 72246b0..dde6169 100644 --- a/examples/go/BulkDomainAvailabilityV2.go +++ b/examples/go/BulkDomainAvailabilityV2.go @@ -1,25 +1,35 @@ // Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DomainAvailabilityAPI.BulkDomainAvailabilityV2(ctx).BulkDomainAvailabilityRequest(*wf.NewBulkDomainAvailabilityRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkDomainAvailabilityRequest() + body.SetDomainNames([]string{"whoisfreaks.com", "example.com"}) + result, _, err := client.DomainAvailabilityAPI.BulkDomainAvailabilityV2(ctx). + BulkDomainAvailabilityRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/BulkGeolocation.go b/examples/go/BulkGeolocation.go index db5363f..f5f268a 100644 --- a/examples/go/BulkGeolocation.go +++ b/examples/go/BulkGeolocation.go @@ -1,23 +1,32 @@ // Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.GeolocationAPI.BulkGeolocation(ctx).BulkGeolocationRequest(*wf.NewBulkGeolocationRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkGeolocationRequest([]string{"8.8.8.8", "1.1.1.1"}) + result, _, err := client.GeolocationAPI.BulkGeolocation(ctx). + BulkGeolocationRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/BulkIpReputation.go b/examples/go/BulkIpReputation.go index 4a9fd94..a7fa494 100644 --- a/examples/go/BulkIpReputation.go +++ b/examples/go/BulkIpReputation.go @@ -1,23 +1,32 @@ // Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.IPReputationAPI.BulkIpReputation(ctx).BulkIpReputationRequest(*wf.NewBulkIpReputationRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkGeolocationRequest([]string{"8.8.8.8", "1.1.1.1"}) + result, _, err := client.IPReputationAPI.BulkIpReputation(ctx). + BulkGeolocationRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/BulkWhois.go b/examples/go/BulkWhois.go index bee429b..390acf0 100644 --- a/examples/go/BulkWhois.go +++ b/examples/go/BulkWhois.go @@ -1,24 +1,32 @@ // Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.BulkWhois(ctx).BulkWhoisRequest(*wf.NewBulkWhoisRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewBulkWhoisRequest([]string{"whoisfreaks.com", "jfreaks.com"}) + result, _, err := client.WHOISAPI.BulkWhois(ctx).BulkWhoisRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DatabaseFileStatus.go b/examples/go/DatabaseFileStatus.go index c1de7f4..4fab541 100644 --- a/examples/go/DatabaseFileStatus.go +++ b/examples/go/DatabaseFileStatus.go @@ -1,23 +1,28 @@ // Runnable example: Database File Status (Public) (GET /v3.4/status) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.AccountAPI.DatabaseFileStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Public endpoint: no API key needed. + ctx := context.Background() + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.AccountAPI.DatabaseFileStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DbAsnWhois.go b/examples/go/DbAsnWhois.go index c0ad8c7..f983125 100644 --- a/examples/go/DbAsnWhois.go +++ b/examples/go/DbAsnWhois.go @@ -1,25 +1,44 @@ // Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesASNWHOISAPI.DbAsnWhois(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbAsnWhois.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbAsnWhois.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesASNWHOISAPI.DbAsnWhois(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbAsnWhois.json.gz") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbAsnWhoisStatus.go b/examples/go/DbAsnWhoisStatus.go index 1a3ae2a..c509625 100644 --- a/examples/go/DbAsnWhoisStatus.go +++ b/examples/go/DbAsnWhoisStatus.go @@ -1,23 +1,30 @@ // Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesASNWHOISAPI.DbAsnWhoisStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesASNWHOISAPI.DbAsnWhoisStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DbDnsDaily.go b/examples/go/DbDnsDaily.go index 17e824a..684581e 100644 --- a/examples/go/DbDnsDaily.go +++ b/examples/go/DbDnsDaily.go @@ -1,25 +1,44 @@ // Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesDNSAPI.DbDnsDaily(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDnsDaily.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDnsDaily.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesDNSAPI.DbDnsDaily(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDnsDaily.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbDnsMonthly.go b/examples/go/DbDnsMonthly.go index 0b67672..c47005e 100644 --- a/examples/go/DbDnsMonthly.go +++ b/examples/go/DbDnsMonthly.go @@ -1,25 +1,44 @@ // Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesDNSAPI.DbDnsMonthly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDnsMonthly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDnsMonthly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesDNSAPI.DbDnsMonthly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDnsMonthly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbDnsWeekly.go b/examples/go/DbDnsWeekly.go index 8eb1483..b7c292e 100644 --- a/examples/go/DbDnsWeekly.go +++ b/examples/go/DbDnsWeekly.go @@ -1,25 +1,44 @@ // Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesDNSAPI.DbDnsWeekly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDnsWeekly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDnsWeekly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesDNSAPI.DbDnsWeekly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDnsWeekly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbDropped.go b/examples/go/DbDropped.go index 7158e50..a1d96c1 100644 --- a/examples/go/DbDropped.go +++ b/examples/go/DbDropped.go @@ -1,26 +1,46 @@ // Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbDropped(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDropped.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDropped.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbDropped(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDropped.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbDroppedBacklinks.go b/examples/go/DbDroppedBacklinks.go index a0e58c4..7300b49 100644 --- a/examples/go/DbDroppedBacklinks.go +++ b/examples/go/DbDroppedBacklinks.go @@ -1,26 +1,46 @@ // Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedBacklinks(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbDroppedBacklinks.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbDroppedBacklinks.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedBacklinks(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbDroppedBacklinks.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbDroppedJson.go b/examples/go/DbDroppedJson.go index c5d82aa..29945d1 100644 --- a/examples/go/DbDroppedJson.go +++ b/examples/go/DbDroppedJson.go @@ -1,25 +1,32 @@ // Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedJson(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesExpiringDroppedAPI.DbDroppedJson(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DbExpired.go b/examples/go/DbExpired.go index 86d17ea..d12e593 100644 --- a/examples/go/DbExpired.go +++ b/examples/go/DbExpired.go @@ -1,26 +1,46 @@ // Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbExpired(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbExpired.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbExpired.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbExpired(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbExpired.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbExpiredCleaned.go b/examples/go/DbExpiredCleaned.go index a540d83..a330091 100644 --- a/examples/go/DbExpiredCleaned.go +++ b/examples/go/DbExpiredCleaned.go @@ -1,25 +1,45 @@ // Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesExpiringDroppedAPI.DbExpiredCleaned(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbExpiredCleaned.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbExpiredCleaned.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesExpiringDroppedAPI.DbExpiredCleaned(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbExpiredCleaned.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbIpCity.go b/examples/go/DbIpCity.go index 32ae0e4..920a42b 100644 --- a/examples/go/DbIpCity.go +++ b/examples/go/DbIpCity.go @@ -1,25 +1,44 @@ // Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPGeolocationAPI.DbIpCity(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpCity.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpCity.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPGeolocationAPI.DbIpCity(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpCity.zip") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbIpCityStatus.go b/examples/go/DbIpCityStatus.go index e8fe742..813273a 100644 --- a/examples/go/DbIpCityStatus.go +++ b/examples/go/DbIpCityStatus.go @@ -1,23 +1,30 @@ // Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPGeolocationAPI.DbIpCityStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPGeolocationAPI.DbIpCityStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DbIpCountry.go b/examples/go/DbIpCountry.go index 4f169d2..3af0522 100644 --- a/examples/go/DbIpCountry.go +++ b/examples/go/DbIpCountry.go @@ -1,25 +1,44 @@ // Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPGeolocationAPI.DbIpCountry(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpCountry.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpCountry.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPGeolocationAPI.DbIpCountry(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpCountry.zip") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbIpCountryStatus.go b/examples/go/DbIpCountryStatus.go index cc6c413..74faaea 100644 --- a/examples/go/DbIpCountryStatus.go +++ b/examples/go/DbIpCountryStatus.go @@ -1,23 +1,30 @@ // Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPGeolocationAPI.DbIpCountryStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPGeolocationAPI.DbIpCountryStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DbIpSecurity.go b/examples/go/DbIpSecurity.go index 7da1b18..24eb1ed 100644 --- a/examples/go/DbIpSecurity.go +++ b/examples/go/DbIpSecurity.go @@ -1,25 +1,44 @@ // Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPSecurityAPI.DbIpSecurity(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpSecurity.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpSecurity.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPSecurityAPI.DbIpSecurity(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpSecurity.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbIpSecurityStatus.go b/examples/go/DbIpSecurityStatus.go index 52822b0..135d876 100644 --- a/examples/go/DbIpSecurityStatus.go +++ b/examples/go/DbIpSecurityStatus.go @@ -1,23 +1,30 @@ // Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPSecurityAPI.DbIpSecurityStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPSecurityAPI.DbIpSecurityStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DbIpWhois.go b/examples/go/DbIpWhois.go index 0784d9a..8d9e026 100644 --- a/examples/go/DbIpWhois.go +++ b/examples/go/DbIpWhois.go @@ -1,25 +1,44 @@ // Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesIPWHOISAPI.DbIpWhois(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbIpWhois.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbIpWhois.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesIPWHOISAPI.DbIpWhois(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbIpWhois.json.gz") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbIpWhoisStatus.go b/examples/go/DbIpWhoisStatus.go index ba55a2f..328c014 100644 --- a/examples/go/DbIpWhoisStatus.go +++ b/examples/go/DbIpWhoisStatus.go @@ -1,23 +1,30 @@ // Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesIPWHOISAPI.DbIpWhoisStatus(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesIPWHOISAPI.DbIpWhoisStatus(ctx).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DbNewlyCctld.go b/examples/go/DbNewlyCctld.go index fee2613..5fc37da 100644 --- a/examples/go/DbNewlyCctld.go +++ b/examples/go/DbNewlyCctld.go @@ -1,27 +1,47 @@ // Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctld(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyCctld.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyCctld.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctld(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyCctld.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbNewlyCctldCleaned.go b/examples/go/DbNewlyCctldCleaned.go index a0e0318..8ceff58 100644 --- a/examples/go/DbNewlyCctldCleaned.go +++ b/examples/go/DbNewlyCctldCleaned.go @@ -1,25 +1,45 @@ // Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldCleaned(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyCctldCleaned.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyCctldCleaned.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldCleaned(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyCctldCleaned.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbNewlyCctldJson.go b/examples/go/DbNewlyCctldJson.go index 8d5afd5..0f90ccb 100644 --- a/examples/go/DbNewlyCctldJson.go +++ b/examples/go/DbNewlyCctldJson.go @@ -1,25 +1,32 @@ // Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldJson(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyCctldJson(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DbNewlyDns.go b/examples/go/DbNewlyDns.go index 4b3ae74..783a1e6 100644 --- a/examples/go/DbNewlyDns.go +++ b/examples/go/DbNewlyDns.go @@ -1,25 +1,44 @@ // Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyDns(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyDns.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyDns.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyDns(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyDns.json") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbNewlyGtld.go b/examples/go/DbNewlyGtld.go index 1001705..f663e6f 100644 --- a/examples/go/DbNewlyGtld.go +++ b/examples/go/DbNewlyGtld.go @@ -1,27 +1,47 @@ // Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtld(ctx).Whois(false).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyGtld.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyGtld.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtld(ctx). + Whois(true).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyGtld.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbNewlyGtldCleaned.go b/examples/go/DbNewlyGtldCleaned.go index 5a615dc..4a44958 100644 --- a/examples/go/DbNewlyGtldCleaned.go +++ b/examples/go/DbNewlyGtldCleaned.go @@ -1,25 +1,45 @@ // Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldCleaned(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbNewlyGtldCleaned.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbNewlyGtldCleaned.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldCleaned(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbNewlyGtldCleaned.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbNewlyGtldJson.go b/examples/go/DbNewlyGtldJson.go index 181a352..4980d84 100644 --- a/examples/go/DbNewlyGtldJson.go +++ b/examples/go/DbNewlyGtldJson.go @@ -1,25 +1,32 @@ // Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldJson(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DatabasesNewlyRegisteredAPI.DbNewlyGtldJson(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DbSubdomainsDaily.go b/examples/go/DbSubdomainsDaily.go index 7c3271b..55c6b8f 100644 --- a/examples/go/DbSubdomainsDaily.go +++ b/examples/go/DbSubdomainsDaily.go @@ -1,25 +1,45 @@ // Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsDaily(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbSubdomainsDaily.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbSubdomainsDaily.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsDaily(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbSubdomainsDaily.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbSubdomainsMonthly.go b/examples/go/DbSubdomainsMonthly.go index 772401b..ca66708 100644 --- a/examples/go/DbSubdomainsMonthly.go +++ b/examples/go/DbSubdomainsMonthly.go @@ -1,25 +1,45 @@ // Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsMonthly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbSubdomainsMonthly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbSubdomainsMonthly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsMonthly(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbSubdomainsMonthly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbSubdomainsWeekly.go b/examples/go/DbSubdomainsWeekly.go index c0d043a..f845a71 100644 --- a/examples/go/DbSubdomainsWeekly.go +++ b/examples/go/DbSubdomainsWeekly.go @@ -1,25 +1,45 @@ // Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsWeekly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbSubdomainsWeekly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbSubdomainsWeekly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesSubdomainsAPI.DbSubdomainsWeekly(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbSubdomainsWeekly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbWhoisDaily.go b/examples/go/DbWhoisDaily.go index 64fc946..3f3a147 100644 --- a/examples/go/DbWhoisDaily.go +++ b/examples/go/DbWhoisDaily.go @@ -1,25 +1,44 @@ // Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesWHOISAPI.DbWhoisDaily(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbWhoisDaily.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbWhoisDaily.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesWHOISAPI.DbWhoisDaily(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbWhoisDaily.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbWhoisMonthly.go b/examples/go/DbWhoisMonthly.go index 6633c63..38aaae8 100644 --- a/examples/go/DbWhoisMonthly.go +++ b/examples/go/DbWhoisMonthly.go @@ -1,25 +1,44 @@ // Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesWHOISAPI.DbWhoisMonthly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbWhoisMonthly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbWhoisMonthly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesWHOISAPI.DbWhoisMonthly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbWhoisMonthly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DbWhoisWeekly.go b/examples/go/DbWhoisWeekly.go index 8c4c8aa..448e86b 100644 --- a/examples/go/DbWhoisWeekly.go +++ b/examples/go/DbWhoisWeekly.go @@ -1,25 +1,44 @@ // Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesWHOISAPI.DbWhoisWeekly(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("dbWhoisWeekly.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to dbWhoisWeekly.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesWHOISAPI.DbWhoisWeekly(ctx).Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DbWhoisWeekly.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DnsBulk.go b/examples/go/DnsBulk.go index ae51bf5..f5a0696 100644 --- a/examples/go/DnsBulk.go +++ b/examples/go/DnsBulk.go @@ -1,25 +1,34 @@ // Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsBulk(ctx).Type("value").DnsBulkRequest(*wf.NewDnsBulkRequest()).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + body := whoisfreaks.NewDnsBulkRequest() + body.SetDomainNames([]string{"whoisfreaks.com", "example.com"}) + result, _, err := client.DNSAPI.DnsBulk(ctx).Type_("A,MX,TXT").DnsBulkRequest(*body).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DnsHistorical.go b/examples/go/DnsHistorical.go index 8b84380..88bf148 100644 --- a/examples/go/DnsHistorical.go +++ b/examples/go/DnsHistorical.go @@ -1,26 +1,34 @@ // Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) // - page (integer, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsHistorical(ctx).DomainName("example.com").Type("value").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DNSAPI.DnsHistorical(ctx). + DomainName("whoisfreaks.com").Type_("A,MX,TXT").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DnsLive.go b/examples/go/DnsLive.go index 0ece956..7f2f4c5 100644 --- a/examples/go/DnsLive.go +++ b/examples/go/DnsLive.go @@ -1,26 +1,34 @@ // Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsLive(ctx).DomainName("example.com").IpAddress("8.8.8.8").Type("value").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DNSAPI.DnsLive(ctx). + DomainName("whoisfreaks.com").Type_("A,MX,TXT").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DnsReverse.go b/examples/go/DnsReverse.go index 287c765..a6cebbf 100644 --- a/examples/go/DnsReverse.go +++ b/examples/go/DnsReverse.go @@ -1,27 +1,34 @@ // Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) // - exact (boolean, optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DNSAPI.DnsReverse(ctx).Value("value").Type("a").Exact(true).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DNSAPI.DnsReverse(ctx).Value("8.8.8.8").Type_("a").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DomainAvailabilityV2.go b/examples/go/DomainAvailabilityV2.go index fe08c0a..7d55530 100644 --- a/examples/go/DomainAvailabilityV2.go +++ b/examples/go/DomainAvailabilityV2.go @@ -1,26 +1,34 @@ // Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. // - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DomainAvailabilityAPI.DomainAvailabilityV2(ctx).Domain("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DomainAvailabilityAPI.DomainAvailabilityV2(ctx). + Domain("google.com").Sug(true).Count(5).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DomainReputation.go b/examples/go/DomainReputation.go index 4fc95d8..7efa827 100644 --- a/examples/go/DomainReputation.go +++ b/examples/go/DomainReputation.go @@ -1,24 +1,32 @@ // Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.DomainReputationAPI.DomainReputation(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.DomainReputationAPI.DomainReputation(ctx). + DomainName("amazon.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/DownloadThreatFeedMalware.go b/examples/go/DownloadThreatFeedMalware.go index 55c54b8..98da01f 100644 --- a/examples/go/DownloadThreatFeedMalware.go +++ b/examples/go/DownloadThreatFeedMalware.go @@ -1,25 +1,45 @@ // Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalware(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedMalware.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedMalware.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalware(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedMalware.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DownloadThreatFeedMalwareSample.go b/examples/go/DownloadThreatFeedMalwareSample.go index f075d13..2f0b671 100644 --- a/examples/go/DownloadThreatFeedMalwareSample.go +++ b/examples/go/DownloadThreatFeedMalwareSample.go @@ -1,24 +1,44 @@ // Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) + package main import ( - "context" - "fmt" - "os" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalwareSample(ctx).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedMalwareSample.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedMalwareSample.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedMalwareSample(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedMalwareSample.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DownloadThreatFeedPhishing.go b/examples/go/DownloadThreatFeedPhishing.go index 0bb386c..6d488f8 100644 --- a/examples/go/DownloadThreatFeedPhishing.go +++ b/examples/go/DownloadThreatFeedPhishing.go @@ -1,25 +1,45 @@ // Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishing(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedPhishing.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedPhishing.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishing(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedPhishing.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DownloadThreatFeedPhishingSample.go b/examples/go/DownloadThreatFeedPhishingSample.go index 3b656d0..869a5e8 100644 --- a/examples/go/DownloadThreatFeedPhishingSample.go +++ b/examples/go/DownloadThreatFeedPhishingSample.go @@ -1,24 +1,44 @@ // Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) + package main import ( - "context" - "fmt" - "os" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishingSample(ctx).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedPhishingSample.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedPhishingSample.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedPhishingSample(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedPhishingSample.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DownloadThreatFeedSpam.go b/examples/go/DownloadThreatFeedSpam.go index 2bf77de..2327b30 100644 --- a/examples/go/DownloadThreatFeedSpam.go +++ b/examples/go/DownloadThreatFeedSpam.go @@ -1,25 +1,45 @@ // Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + package main import ( - "context" - "fmt" - "os" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpam(ctx).Date(time.Now().AddDate(0,0,-1).Format("2006-01-02")).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedSpam.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedSpam.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpam(ctx). + Date("2026-10-01").Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedSpam.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/DownloadThreatFeedSpamSample.go b/examples/go/DownloadThreatFeedSpamSample.go index ec0beb9..bce64de 100644 --- a/examples/go/DownloadThreatFeedSpamSample.go +++ b/examples/go/DownloadThreatFeedSpamSample.go @@ -1,24 +1,44 @@ // Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) + package main import ( - "context" - "fmt" - "os" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - // returns raw bytes (compressed/binary file) -- write to disk - data, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpamSample(ctx).Execute() - if err != nil { panic(err) } - if err := os.WriteFile("downloadThreatFeedSpamSample.gz", data, 0644); err != nil { panic(err) } - fmt.Printf("saved %d bytes to downloadThreatFeedSpamSample.gz\n", len(data)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + file, _, err := client.DatabasesThreatFeedAPI.DownloadThreatFeedSpamSample(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The SDK saves the response to a temporary file: copy it to its destination. + defer os.Remove(file.Name()) + defer file.Close() + + out, err := os.Create("DownloadThreatFeedSpamSample.csv") + if err != nil { + log.Fatal(err) + } + defer out.Close() + n, err := io.Copy(out, file) + if err != nil { + log.Fatal(err) + } + path, _ := filepath.Abs(out.Name()) + fmt.Printf("Saved %d bytes to %s\n", n, path) } diff --git a/examples/go/Geolocation.go b/examples/go/Geolocation.go index e86f30f..679bb14 100644 --- a/examples/go/Geolocation.go +++ b/examples/go/Geolocation.go @@ -1,23 +1,30 @@ // Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.GeolocationAPI.Geolocation(ctx).Ip("8.8.8.8").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.GeolocationAPI.Geolocation(ctx).Ip("8.8.8.8").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/IpReputation.go b/examples/go/IpReputation.go index f697ecb..1ea4ebc 100644 --- a/examples/go/IpReputation.go +++ b/examples/go/IpReputation.go @@ -1,23 +1,30 @@ // Runnable example: IP Reputation Lookup (GET /v1.0/security) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.IPReputationAPI.IpReputation(ctx).Ip("8.8.8.8").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.IPReputationAPI.IpReputation(ctx).Ip("8.8.8.8").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/IpWhois.go b/examples/go/IpWhois.go index 4fd28ae..8728508 100644 --- a/examples/go/IpWhois.go +++ b/examples/go/IpWhois.go @@ -1,24 +1,31 @@ // Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.IPWHOISAPI.IpWhois(ctx).Ip("8.8.8.8").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.IPWHOISAPI.IpWhois(ctx).Ip("8.8.8.8").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/README.md b/examples/go/README.md index b929e16..a25f27b 100644 --- a/examples/go/README.md +++ b/examples/go/README.md @@ -1,107 +1,107 @@ -# Go — Runnable Examples +# Go Runnable Examples -Install: see the [Go guide](../../docs/languages/go.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [Go guide](../../docs/languages/go.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.go`](WhoisLive.go) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.go`](BulkWhois.go) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.go`](WhoisHistory.go) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.go`](WhoisReverse.go) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.go`](WhoisLive.go): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.go`](BulkWhois.go): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.go`](WhoisHistory.go): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.go`](WhoisReverse.go): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.go`](DnsLive.go) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.go`](DnsHistorical.go) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.go`](DnsReverse.go) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.go`](DnsBulk.go) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.go`](DnsLive.go): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.go`](DnsHistorical.go): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.go`](DnsReverse.go): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.go`](DnsBulk.go): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.go`](DomainAvailabilityV2.go) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.go`](BulkDomainAvailabilityV2.go) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.go`](DomainAvailabilityV2.go): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.go`](BulkDomainAvailabilityV2.go): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.go`](Typosquatting.go) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.go`](Typosquatting.go): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.go`](SslLookup.go) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.go`](SslLookup.go): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.go`](Geolocation.go) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.go`](BulkGeolocation.go) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.go`](Geolocation.go): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.go`](BulkGeolocation.go): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.go`](Subdomains.go) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.go`](Subdomains.go): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.go`](IpReputation.go) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.go`](BulkIpReputation.go) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.go`](IpReputation.go): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.go`](BulkIpReputation.go): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.go`](DomainReputation.go) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.go`](DomainReputation.go): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.go`](AsnWhois.go) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.go`](AsnWhois.go): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.go`](IpWhois.go) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.go`](IpWhois.go): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.go`](RotateApiKey.go) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.go`](AccountUsage.go) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.go`](DatabaseFileStatus.go) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.go`](RotateApiKey.go): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.go`](AccountUsage.go): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.go`](DatabaseFileStatus.go): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.go`](DbNewlyGtld.go) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.go`](DbNewlyCctld.go) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.go`](DbNewlyGtldCleaned.go) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.go`](DbNewlyCctldCleaned.go) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.go`](DbNewlyGtldJson.go) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.go`](DbNewlyCctldJson.go) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.go`](DbNewlyDns.go) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.go`](DbNewlyGtld.go): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.go`](DbNewlyCctld.go): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.go`](DbNewlyGtldCleaned.go): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.go`](DbNewlyCctldCleaned.go): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.go`](DbNewlyGtldJson.go): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.go`](DbNewlyCctldJson.go): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.go`](DbNewlyDns.go): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.go`](DbExpired.go) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.go`](DbExpiredCleaned.go) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.go`](DbDropped.go) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.go`](DbDroppedJson.go) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.go`](DbDroppedBacklinks.go) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.go`](DbExpired.go): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.go`](DbExpiredCleaned.go): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.go`](DbDropped.go): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.go`](DbDroppedJson.go): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.go`](DbDroppedBacklinks.go): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.go`](DbWhoisDaily.go) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.go`](DbWhoisWeekly.go) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.go`](DbWhoisMonthly.go) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.go`](DbWhoisDaily.go): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.go`](DbWhoisWeekly.go): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.go`](DbWhoisMonthly.go): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.go`](DbDnsDaily.go) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.go`](DbDnsWeekly.go) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.go`](DbDnsMonthly.go) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.go`](DbDnsDaily.go): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.go`](DbDnsWeekly.go): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.go`](DbDnsMonthly.go): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.go`](DbSubdomainsDaily.go) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.go`](DbSubdomainsWeekly.go) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.go`](DbSubdomainsMonthly.go) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.go`](DbSubdomainsDaily.go): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.go`](DbSubdomainsWeekly.go): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.go`](DbSubdomainsMonthly.go): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.go`](DbIpCountryStatus.go) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.go`](DbIpCountry.go) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.go`](DbIpCityStatus.go) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.go`](DbIpCity.go) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.go`](DbIpCountryStatus.go): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.go`](DbIpCountry.go): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.go`](DbIpCityStatus.go): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.go`](DbIpCity.go): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.go`](DbAsnWhois.go) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.go`](DbAsnWhoisStatus.go) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.go`](DbAsnWhois.go): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.go`](DbAsnWhoisStatus.go): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.go`](DbIpWhois.go) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.go`](DbIpWhoisStatus.go) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.go`](DbIpWhois.go): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.go`](DbIpWhoisStatus.go): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.go`](DbIpSecurity.go) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.go`](DbIpSecurityStatus.go) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.go`](DbIpSecurity.go): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.go`](DbIpSecurityStatus.go): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.go`](DownloadThreatFeedPhishing.go) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.go`](DownloadThreatFeedPhishingSample.go) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.go`](DownloadThreatFeedMalware.go) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.go`](DownloadThreatFeedMalwareSample.go) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.go`](DownloadThreatFeedSpam.go) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.go`](DownloadThreatFeedSpamSample.go) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.go`](DownloadThreatFeedPhishing.go): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.go`](DownloadThreatFeedPhishingSample.go): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.go`](DownloadThreatFeedMalware.go): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.go`](DownloadThreatFeedMalwareSample.go): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.go`](DownloadThreatFeedSpam.go): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.go`](DownloadThreatFeedSpamSample.go): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/go/RotateApiKey.go b/examples/go/RotateApiKey.go index 41d05d2..54ed657 100644 --- a/examples/go/RotateApiKey.go +++ b/examples/go/RotateApiKey.go @@ -1,23 +1,29 @@ // Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.AccountAPI.RotateApiKey(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + newKey, _, err := client.AccountAPI.RotateApiKey(ctx).Execute() + if err != nil { + log.Fatal(err) + } + // The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY. + fmt.Println("New API key:", newKey) } diff --git a/examples/go/SslLookup.go b/examples/go/SslLookup.go index 231874d..ffe002c 100644 --- a/examples/go/SslLookup.go +++ b/examples/go/SslLookup.go @@ -1,26 +1,33 @@ // Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) // - sslRaw (boolean, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.SSLAPI.SslLookup(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.SSLAPI.SslLookup(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/Subdomains.go b/examples/go/Subdomains.go index 3660f61..f4ec354 100644 --- a/examples/go/Subdomains.go +++ b/examples/go/Subdomains.go @@ -1,4 +1,5 @@ // Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -6,24 +7,29 @@ // - status (string (one of: active, inactive), optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - "time" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.SubdomainsAPI.Subdomains(ctx).Domain("example.com").After("2000-01-01").Before(time.Now().Format("2006-01-02")).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.SubdomainsAPI.Subdomains(ctx).Domain("whoisfreaks.com").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/Typosquatting.go b/examples/go/Typosquatting.go index b4249b3..2869caf 100644 --- a/examples/go/Typosquatting.go +++ b/examples/go/Typosquatting.go @@ -1,25 +1,32 @@ // Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) // - pageToken (string, optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.TyposquattingAPI.Typosquatting(ctx).Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.TyposquattingAPI.Typosquatting(ctx).Keyword("whoisfreaks").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/WhoisHistoricalOrReverse.go b/examples/go/WhoisHistoricalOrReverse.go deleted file mode 100644 index 1c57fa6..0000000 --- a/examples/go/WhoisHistoricalOrReverse.go +++ /dev/null @@ -1,32 +0,0 @@ -// Runnable example: WHOIS Historical or Reverse Lookup (GET /v1.0/whois) -// Parameters for whoisHistoricalOrReverse (GET /v1.0/whois): -// - apiKey (string, required): Your WHOISFreaks API key -// - whois (string (one of: historical, reverse), required) -// - domainName (string, required): Required for historical lookup -// - keyword (string, optional): For reverse — domain keyword search -// - email (string, optional): For reverse — registrant email search -// - owner (string, optional): For reverse — registrant name search -// - company (string, optional): For reverse — company name search -// - mode (string (one of: default, mini), optional) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -package main - -import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" -) - -func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is a builder method on the request, not a config/context value - result, httpRes, err := client.WHOISAPI.WhoisHistoricalOrReverse(context.Background()).ApiKey("YOUR_API_KEY").Whois("historical").DomainName("example.com").Exact(true).Execute() - if err != nil { panic(err) } - fmt.Println("status:", httpRes.StatusCode) - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) -} diff --git a/examples/go/WhoisHistory.go b/examples/go/WhoisHistory.go index 70d441c..2b981b4 100644 --- a/examples/go/WhoisHistory.go +++ b/examples/go/WhoisHistory.go @@ -1,25 +1,31 @@ // Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisHistory(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisHistory(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/WhoisLive.go b/examples/go/WhoisLive.go index 3ffcc11..4871731 100644 --- a/examples/go/WhoisLive.go +++ b/examples/go/WhoisLive.go @@ -1,24 +1,31 @@ // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("example.com").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("whoisfreaks.com").Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/go/WhoisReverse.go b/examples/go/WhoisReverse.go index 91ba6b1..de01b6c 100644 --- a/examples/go/WhoisReverse.go +++ b/examples/go/WhoisReverse.go @@ -1,25 +1,32 @@ // Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Run it from the Getting Started module: save it as main.go, then `go run .` // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number // - format (string (one of: json, xml), optional) + package main import ( - "context" - "encoding/json" - "fmt" - wf "github.com/WhoisFreaks/whoisfreaks-go" + "context" + "encoding/json" + "fmt" + "log" + "os" + + whoisfreaks "github.com/WhoisFreaks/whoisfreaks-go" ) func main() { - cfg := wf.NewConfiguration() - client := wf.NewAPIClient(cfg) - // apiKey is set once via the request context - ctx := context.WithValue(context.Background(), wf.ContextAPIKeys, - map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}}) - result, _, err := client.WHOISAPI.WhoisReverse(ctx).Keyword("value").Execute() - if err != nil { panic(err) } - b, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(b)) + // Set the API key once on the context; every call made with ctx sends it. + ctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys, + map[string]whoisfreaks.APIKey{"ApiKeyAuth": {Key: os.Getenv("WHOISFREAKS_API_KEY")}}) + client := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration()) + + result, _, err := client.WHOISAPI.WhoisReverse(ctx).Keyword("whoisfreaks").Page(1).Execute() + if err != nil { + log.Fatal(err) + } + out, _ := json.MarshalIndent(result, "", " ") + fmt.Println(string(out)) } diff --git a/examples/java/AccountUsage.java b/examples/java/AccountUsage.java index 288508b..595e56d 100644 --- a/examples/java/AccountUsage.java +++ b/examples/java/AccountUsage.java @@ -1,18 +1,21 @@ // Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=AccountUsage // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.AccountApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.AccountUsageResponse; public class AccountUsage { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call AccountApi api = new AccountApi(client); - var result = api.accountUsage(); + + AccountUsageResponse result = api.accountUsage(); System.out.println(result); } } diff --git a/examples/java/AsnWhois.java b/examples/java/AsnWhois.java index 24fd2d3..434db04 100644 --- a/examples/java/AsnWhois.java +++ b/examples/java/AsnWhois.java @@ -1,19 +1,23 @@ // Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=AsnWhois // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.AsnWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.AsnWhoisResponse; public class AsnWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call AsnWhoisApi api = new AsnWhoisApi(client); - var result = api.asnWhois("AS15169", null); + + // asnWhois(asn, format); null leaves an optional parameter unset + AsnWhoisResponse result = api.asnWhois("as15169", null); System.out.println(result); } } diff --git a/examples/java/BulkDomainAvailabilityV2.java b/examples/java/BulkDomainAvailabilityV2.java index 7fa2a41..29e2ad3 100644 --- a/examples/java/BulkDomainAvailabilityV2.java +++ b/examples/java/BulkDomainAvailabilityV2.java @@ -1,21 +1,29 @@ // Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=BulkDomainAvailabilityV2 // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DomainAvailabilityApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.model.BulkDomainAvailabilityRequest; +import com.whoisfreaks.client.model.BulkDomainAvailabilityResponse; + +import java.util.Arrays; public class BulkDomainAvailabilityV2 { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DomainAvailabilityApi api = new DomainAvailabilityApi(client); - var result = api.bulkDomainAvailabilityV2(new BulkDomainAvailabilityRequest(), null, null); + + BulkDomainAvailabilityRequest body = new BulkDomainAvailabilityRequest() + .domainNames(Arrays.asList("whoisfreaks.com", "example.com")); + // bulkDomainAvailabilityV2(bulkDomainAvailabilityRequest, domain, format); null leaves an optional parameter unset + BulkDomainAvailabilityResponse result = api.bulkDomainAvailabilityV2(body, null, null); System.out.println(result); } } diff --git a/examples/java/BulkGeolocation.java b/examples/java/BulkGeolocation.java index b69311c..8486535 100644 --- a/examples/java/BulkGeolocation.java +++ b/examples/java/BulkGeolocation.java @@ -1,19 +1,27 @@ // Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=BulkGeolocation // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.GeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.model.BulkGeolocationRequest; +import com.whoisfreaks.client.model.GeolocationResponse; + +import java.util.Arrays; +import java.util.List; public class BulkGeolocation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call GeolocationApi api = new GeolocationApi(client); - var result = api.bulkGeolocation(new BulkGeolocationRequest()); + + BulkGeolocationRequest body = new BulkGeolocationRequest() + .ips(Arrays.asList("8.8.8.8", "1.1.1.1")); + List result = api.bulkGeolocation(body); System.out.println(result); } } diff --git a/examples/java/BulkIpReputation.java b/examples/java/BulkIpReputation.java index ba8b3d0..df3045e 100644 --- a/examples/java/BulkIpReputation.java +++ b/examples/java/BulkIpReputation.java @@ -1,19 +1,27 @@ // Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=BulkIpReputation // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.IpReputationApi; -import com.whoisfreaks.client.model.BulkIpReputationRequest; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.BulkGeolocationRequest; +import com.whoisfreaks.client.model.IpReputationResponse; + +import java.util.Arrays; +import java.util.List; public class BulkIpReputation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call IpReputationApi api = new IpReputationApi(client); - var result = api.bulkIpReputation(new BulkIpReputationRequest()); + + BulkGeolocationRequest body = new BulkGeolocationRequest() + .ips(Arrays.asList("8.8.8.8", "1.1.1.1")); + List result = api.bulkIpReputation(body); System.out.println(result); } } diff --git a/examples/java/BulkWhois.java b/examples/java/BulkWhois.java index c9cb2d9..575bf7e 100644 --- a/examples/java/BulkWhois.java +++ b/examples/java/BulkWhois.java @@ -1,20 +1,28 @@ // Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=BulkWhois // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.model.BulkWhoisRequest; +import com.whoisfreaks.client.model.BulkWhoisResponse; + +import java.util.Arrays; public class BulkWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.bulkWhois(new BulkWhoisRequest(), null); + + BulkWhoisRequest body = new BulkWhoisRequest() + .domainNames(Arrays.asList("whoisfreaks.com", "jfreaks.com")); + // bulkWhois(bulkWhoisRequest, format); null leaves an optional parameter unset + BulkWhoisResponse result = api.bulkWhois(body, null); System.out.println(result); } } diff --git a/examples/java/DatabaseFileStatus.java b/examples/java/DatabaseFileStatus.java index 7719ef9..63de71e 100644 --- a/examples/java/DatabaseFileStatus.java +++ b/examples/java/DatabaseFileStatus.java @@ -1,18 +1,18 @@ // Runnable example: Database File Status (Public) (GET /v3.4/status) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DatabaseFileStatus // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.AccountApi; public class DatabaseFileStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + // Public endpoint: no API key needed. AccountApi api = new AccountApi(client); - var result = api.databaseFileStatus(); + + com.whoisfreaks.client.model.DatabaseFileStatus result = api.databaseFileStatus(); System.out.println(result); } } diff --git a/examples/java/DbAsnWhois.java b/examples/java/DbAsnWhois.java index 461e39f..72719b3 100644 --- a/examples/java/DbAsnWhois.java +++ b/examples/java/DbAsnWhois.java @@ -1,18 +1,30 @@ // Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbAsnWhois // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesAsnWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbAsnWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesAsnWhoisApi api = new DatabasesAsnWhoisApi(client); - var result = api.dbAsnWhois(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbAsnWhois(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbAsnWhois.json.gz"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbAsnWhoisStatus.java b/examples/java/DbAsnWhoisStatus.java index 2a39e96..ce19e0f 100644 --- a/examples/java/DbAsnWhoisStatus.java +++ b/examples/java/DbAsnWhoisStatus.java @@ -1,18 +1,21 @@ // Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbAsnWhoisStatus // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesAsnWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbAsnWhoisStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesAsnWhoisApi api = new DatabasesAsnWhoisApi(client); - var result = api.dbAsnWhoisStatus(); + + SnapshotStatus result = api.dbAsnWhoisStatus(); System.out.println(result); } } diff --git a/examples/java/DbDnsDaily.java b/examples/java/DbDnsDaily.java index 169cee5..1a3b49a 100644 --- a/examples/java/DbDnsDaily.java +++ b/examples/java/DbDnsDaily.java @@ -1,18 +1,30 @@ // Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDnsDaily // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesDnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDnsDaily { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesDnsApi api = new DatabasesDnsApi(client); - var result = api.dbDnsDaily(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbDnsDaily(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDnsDaily.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbDnsMonthly.java b/examples/java/DbDnsMonthly.java index b25eeef..fc688a6 100644 --- a/examples/java/DbDnsMonthly.java +++ b/examples/java/DbDnsMonthly.java @@ -1,18 +1,30 @@ // Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDnsMonthly // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesDnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDnsMonthly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesDnsApi api = new DatabasesDnsApi(client); - var result = api.dbDnsMonthly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbDnsMonthly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDnsMonthly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbDnsWeekly.java b/examples/java/DbDnsWeekly.java index b3f3131..c0faf46 100644 --- a/examples/java/DbDnsWeekly.java +++ b/examples/java/DbDnsWeekly.java @@ -1,18 +1,30 @@ // Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDnsWeekly // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesDnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDnsWeekly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesDnsApi api = new DatabasesDnsApi(client); - var result = api.dbDnsWeekly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbDnsWeekly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDnsWeekly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbDropped.java b/examples/java/DbDropped.java index 217f263..7ed5522 100644 --- a/examples/java/DbDropped.java +++ b/examples/java/DbDropped.java @@ -1,19 +1,31 @@ // Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDropped // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDropped { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbDropped(false, java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbDropped(true, LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDropped.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbDroppedBacklinks.java b/examples/java/DbDroppedBacklinks.java index 6f0cd64..8e9ced7 100644 --- a/examples/java/DbDroppedBacklinks.java +++ b/examples/java/DbDroppedBacklinks.java @@ -1,19 +1,32 @@ // Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDroppedBacklinks // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbDroppedBacklinks { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbDroppedBacklinks(false, java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + // dbDroppedBacklinks(whois, date); null leaves an optional parameter unset + File download = api.dbDroppedBacklinks(null, LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbDroppedBacklinks.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbDroppedJson.java b/examples/java/DbDroppedJson.java index 4631fc1..bf1c7eb 100644 --- a/examples/java/DbDroppedJson.java +++ b/examples/java/DbDroppedJson.java @@ -1,19 +1,25 @@ // Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbDroppedJson // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.time.LocalDate; +import java.util.List; public class DbDroppedJson { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbDroppedJson(java.time.LocalDate.now().minusDays(1).toString(), null); + + // dbDroppedJson(date, tlds); null leaves an optional parameter unset + List result = api.dbDroppedJson(LocalDate.of(2026, 10, 1), null); System.out.println(result); } } diff --git a/examples/java/DbExpired.java b/examples/java/DbExpired.java index e84989e..6169d9a 100644 --- a/examples/java/DbExpired.java +++ b/examples/java/DbExpired.java @@ -1,19 +1,31 @@ // Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbExpired // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbExpired { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbExpired(false, java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbExpired(true, LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbExpired.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbExpiredCleaned.java b/examples/java/DbExpiredCleaned.java index 2a106e7..e9c41c2 100644 --- a/examples/java/DbExpiredCleaned.java +++ b/examples/java/DbExpiredCleaned.java @@ -1,18 +1,30 @@ // Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbExpiredCleaned // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesExpiringDroppedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbExpiredCleaned { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesExpiringDroppedApi api = new DatabasesExpiringDroppedApi(client); - var result = api.dbExpiredCleaned(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbExpiredCleaned(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbExpiredCleaned.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbIpCity.java b/examples/java/DbIpCity.java index da41ee6..85983f7 100644 --- a/examples/java/DbIpCity.java +++ b/examples/java/DbIpCity.java @@ -1,18 +1,30 @@ // Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpCity // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpGeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbIpCity { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpGeolocationApi api = new DatabasesIpGeolocationApi(client); - var result = api.dbIpCity(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbIpCity(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbIpCity.zip"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbIpCityStatus.java b/examples/java/DbIpCityStatus.java index e5524af..7981a5f 100644 --- a/examples/java/DbIpCityStatus.java +++ b/examples/java/DbIpCityStatus.java @@ -1,18 +1,21 @@ // Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpCityStatus // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpGeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbIpCityStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpGeolocationApi api = new DatabasesIpGeolocationApi(client); - var result = api.dbIpCityStatus(); + + SnapshotStatus result = api.dbIpCityStatus(); System.out.println(result); } } diff --git a/examples/java/DbIpCountry.java b/examples/java/DbIpCountry.java index 7664c51..15a9550 100644 --- a/examples/java/DbIpCountry.java +++ b/examples/java/DbIpCountry.java @@ -1,18 +1,30 @@ // Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpCountry // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpGeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbIpCountry { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpGeolocationApi api = new DatabasesIpGeolocationApi(client); - var result = api.dbIpCountry(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbIpCountry(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbIpCountry.zip"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbIpCountryStatus.java b/examples/java/DbIpCountryStatus.java index b9951a8..5cebdef 100644 --- a/examples/java/DbIpCountryStatus.java +++ b/examples/java/DbIpCountryStatus.java @@ -1,18 +1,21 @@ // Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpCountryStatus // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpGeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbIpCountryStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpGeolocationApi api = new DatabasesIpGeolocationApi(client); - var result = api.dbIpCountryStatus(); + + SnapshotStatus result = api.dbIpCountryStatus(); System.out.println(result); } } diff --git a/examples/java/DbIpSecurity.java b/examples/java/DbIpSecurity.java index 76ae3f8..4b813cb 100644 --- a/examples/java/DbIpSecurity.java +++ b/examples/java/DbIpSecurity.java @@ -1,18 +1,30 @@ // Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpSecurity // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpSecurityApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbIpSecurity { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpSecurityApi api = new DatabasesIpSecurityApi(client); - var result = api.dbIpSecurity(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbIpSecurity(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbIpSecurity.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbIpSecurityStatus.java b/examples/java/DbIpSecurityStatus.java index 6394b6b..8883fe5 100644 --- a/examples/java/DbIpSecurityStatus.java +++ b/examples/java/DbIpSecurityStatus.java @@ -1,18 +1,21 @@ // Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpSecurityStatus // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpSecurityApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbIpSecurityStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpSecurityApi api = new DatabasesIpSecurityApi(client); - var result = api.dbIpSecurityStatus(); + + SnapshotStatus result = api.dbIpSecurityStatus(); System.out.println(result); } } diff --git a/examples/java/DbIpWhois.java b/examples/java/DbIpWhois.java index 71e0ae8..9ec5260 100644 --- a/examples/java/DbIpWhois.java +++ b/examples/java/DbIpWhois.java @@ -1,18 +1,30 @@ // Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpWhois // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbIpWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpWhoisApi api = new DatabasesIpWhoisApi(client); - var result = api.dbIpWhois(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbIpWhois(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbIpWhois.json.gz"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbIpWhoisStatus.java b/examples/java/DbIpWhoisStatus.java index dbe50b3..e95629c 100644 --- a/examples/java/DbIpWhoisStatus.java +++ b/examples/java/DbIpWhoisStatus.java @@ -1,18 +1,21 @@ // Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbIpWhoisStatus // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesIpWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SnapshotStatus; public class DbIpWhoisStatus { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesIpWhoisApi api = new DatabasesIpWhoisApi(client); - var result = api.dbIpWhoisStatus(); + + SnapshotStatus result = api.dbIpWhoisStatus(); System.out.println(result); } } diff --git a/examples/java/DbNewlyCctld.java b/examples/java/DbNewlyCctld.java index bdb7689..594b050 100644 --- a/examples/java/DbNewlyCctld.java +++ b/examples/java/DbNewlyCctld.java @@ -1,20 +1,33 @@ // Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyCctld // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyCctld { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyCctld(false, java.time.LocalDate.now().minusDays(1).toString(), null); - System.out.println(result); + + // dbNewlyCctld(whois, date, tlds); null leaves an optional parameter unset + File download = api.dbNewlyCctld(true, LocalDate.of(2026, 10, 1), null); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyCctld.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbNewlyCctldCleaned.java b/examples/java/DbNewlyCctldCleaned.java index 125b090..654c2a1 100644 --- a/examples/java/DbNewlyCctldCleaned.java +++ b/examples/java/DbNewlyCctldCleaned.java @@ -1,18 +1,30 @@ // Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyCctldCleaned // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyCctldCleaned { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyCctldCleaned(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbNewlyCctldCleaned(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyCctldCleaned.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbNewlyCctldJson.java b/examples/java/DbNewlyCctldJson.java index 02b001b..dd387be 100644 --- a/examples/java/DbNewlyCctldJson.java +++ b/examples/java/DbNewlyCctldJson.java @@ -1,19 +1,25 @@ // Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyCctldJson // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.time.LocalDate; +import java.util.List; public class DbNewlyCctldJson { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyCctldJson(java.time.LocalDate.now().minusDays(1).toString(), null); + + // dbNewlyCctldJson(date, tlds); null leaves an optional parameter unset + List result = api.dbNewlyCctldJson(LocalDate.of(2026, 10, 1), null); System.out.println(result); } } diff --git a/examples/java/DbNewlyDns.java b/examples/java/DbNewlyDns.java index fe4393b..5977bcd 100644 --- a/examples/java/DbNewlyDns.java +++ b/examples/java/DbNewlyDns.java @@ -1,18 +1,30 @@ // Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyDns // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyDns { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyDns(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbNewlyDns(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyDns.json"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbNewlyGtld.java b/examples/java/DbNewlyGtld.java index 69bc1db..8153a35 100644 --- a/examples/java/DbNewlyGtld.java +++ b/examples/java/DbNewlyGtld.java @@ -1,20 +1,33 @@ // Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyGtld // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyGtld { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyGtld(false, java.time.LocalDate.now().minusDays(1).toString(), null); - System.out.println(result); + + // dbNewlyGtld(whois, date, tlds); null leaves an optional parameter unset + File download = api.dbNewlyGtld(true, LocalDate.of(2026, 10, 1), null); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyGtld.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbNewlyGtldCleaned.java b/examples/java/DbNewlyGtldCleaned.java index aa0c88f..dd9f146 100644 --- a/examples/java/DbNewlyGtldCleaned.java +++ b/examples/java/DbNewlyGtldCleaned.java @@ -1,18 +1,30 @@ // Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyGtldCleaned // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbNewlyGtldCleaned { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyGtldCleaned(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbNewlyGtldCleaned(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbNewlyGtldCleaned.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbNewlyGtldJson.java b/examples/java/DbNewlyGtldJson.java index ec20285..d172dd2 100644 --- a/examples/java/DbNewlyGtldJson.java +++ b/examples/java/DbNewlyGtldJson.java @@ -1,19 +1,25 @@ // Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbNewlyGtldJson // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesNewlyRegisteredApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.time.LocalDate; +import java.util.List; public class DbNewlyGtldJson { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesNewlyRegisteredApi api = new DatabasesNewlyRegisteredApi(client); - var result = api.dbNewlyGtldJson(java.time.LocalDate.now().minusDays(1).toString(), null); + + // dbNewlyGtldJson(date, tlds); null leaves an optional parameter unset + List result = api.dbNewlyGtldJson(LocalDate.of(2026, 10, 1), null); System.out.println(result); } } diff --git a/examples/java/DbSubdomainsDaily.java b/examples/java/DbSubdomainsDaily.java index 8e28c85..64cfe43 100644 --- a/examples/java/DbSubdomainsDaily.java +++ b/examples/java/DbSubdomainsDaily.java @@ -1,18 +1,30 @@ // Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbSubdomainsDaily // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesSubdomainsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbSubdomainsDaily { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesSubdomainsApi api = new DatabasesSubdomainsApi(client); - var result = api.dbSubdomainsDaily(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbSubdomainsDaily(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbSubdomainsDaily.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbSubdomainsMonthly.java b/examples/java/DbSubdomainsMonthly.java index cb2b43f..c2f044b 100644 --- a/examples/java/DbSubdomainsMonthly.java +++ b/examples/java/DbSubdomainsMonthly.java @@ -1,18 +1,30 @@ // Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbSubdomainsMonthly // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesSubdomainsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbSubdomainsMonthly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesSubdomainsApi api = new DatabasesSubdomainsApi(client); - var result = api.dbSubdomainsMonthly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbSubdomainsMonthly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbSubdomainsMonthly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbSubdomainsWeekly.java b/examples/java/DbSubdomainsWeekly.java index 7452629..f2d83c9 100644 --- a/examples/java/DbSubdomainsWeekly.java +++ b/examples/java/DbSubdomainsWeekly.java @@ -1,18 +1,30 @@ // Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbSubdomainsWeekly // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesSubdomainsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbSubdomainsWeekly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesSubdomainsApi api = new DatabasesSubdomainsApi(client); - var result = api.dbSubdomainsWeekly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbSubdomainsWeekly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbSubdomainsWeekly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbWhoisDaily.java b/examples/java/DbWhoisDaily.java index ebb6ed3..7faab58 100644 --- a/examples/java/DbWhoisDaily.java +++ b/examples/java/DbWhoisDaily.java @@ -1,18 +1,30 @@ // Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbWhoisDaily // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbWhoisDaily { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesWhoisApi api = new DatabasesWhoisApi(client); - var result = api.dbWhoisDaily(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbWhoisDaily(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbWhoisDaily.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbWhoisMonthly.java b/examples/java/DbWhoisMonthly.java index de589c7..0be4655 100644 --- a/examples/java/DbWhoisMonthly.java +++ b/examples/java/DbWhoisMonthly.java @@ -1,18 +1,30 @@ // Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbWhoisMonthly // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbWhoisMonthly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesWhoisApi api = new DatabasesWhoisApi(client); - var result = api.dbWhoisMonthly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbWhoisMonthly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbWhoisMonthly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DbWhoisWeekly.java b/examples/java/DbWhoisWeekly.java index b96a1e9..e833d8a 100644 --- a/examples/java/DbWhoisWeekly.java +++ b/examples/java/DbWhoisWeekly.java @@ -1,18 +1,30 @@ // Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DbWhoisWeekly // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; public class DbWhoisWeekly { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesWhoisApi api = new DatabasesWhoisApi(client); - var result = api.dbWhoisWeekly(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.dbWhoisWeekly(LocalDate.of(2026, 10, 1)); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DbWhoisWeekly.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DnsBulk.java b/examples/java/DnsBulk.java index 1c0a8e1..b73df4c 100644 --- a/examples/java/DnsBulk.java +++ b/examples/java/DnsBulk.java @@ -1,21 +1,29 @@ // Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DnsBulk // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.BulkDnsResponse; import com.whoisfreaks.client.model.DnsBulkRequest; +import java.util.Arrays; + public class DnsBulk { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DnsApi api = new DnsApi(client); - var result = api.dnsBulk("value", new DnsBulkRequest(), null); + + DnsBulkRequest body = new DnsBulkRequest() + .domainNames(Arrays.asList("whoisfreaks.com", "example.com")); + // dnsBulk(type, dnsBulkRequest, format); null leaves an optional parameter unset + BulkDnsResponse result = api.dnsBulk("A,MX,TXT", body, null); System.out.println(result); } } diff --git a/examples/java/DnsHistorical.java b/examples/java/DnsHistorical.java index 81f3c5f..e4278ee 100644 --- a/examples/java/DnsHistorical.java +++ b/examples/java/DnsHistorical.java @@ -1,4 +1,5 @@ // Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DnsHistorical // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) @@ -6,16 +7,19 @@ // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.HistoricalDnsResponse; public class DnsHistorical { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DnsApi api = new DnsApi(client); - var result = api.dnsHistorical("example.com", "value", null, null); + + // dnsHistorical(domainName, type, page, format); null leaves an optional parameter unset + HistoricalDnsResponse result = api.dnsHistorical("whoisfreaks.com", "A,MX,TXT", 1, null); System.out.println(result); } } diff --git a/examples/java/DnsLive.java b/examples/java/DnsLive.java index 5933f86..d9c3c34 100644 --- a/examples/java/DnsLive.java +++ b/examples/java/DnsLive.java @@ -1,21 +1,25 @@ // Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DnsLive // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.DnsResponse; public class DnsLive { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DnsApi api = new DnsApi(client); - var result = api.dnsLive("example.com", "8.8.8.8", "value", null); + + // dnsLive(type, domainName, ipAddress, format); null leaves an optional parameter unset + DnsResponse result = api.dnsLive("A,MX,TXT", "whoisfreaks.com", null, null); System.out.println(result); } } diff --git a/examples/java/DnsReverse.java b/examples/java/DnsReverse.java index 9475c78..f9ba2b0 100644 --- a/examples/java/DnsReverse.java +++ b/examples/java/DnsReverse.java @@ -1,4 +1,5 @@ // Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DnsReverse // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) @@ -7,16 +8,19 @@ // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DnsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.ReverseDnsResponse; public class DnsReverse { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DnsApi api = new DnsApi(client); - var result = api.dnsReverse("value", "a", true, null, null); + + // dnsReverse(value, type, exact, page, format); null leaves an optional parameter unset + ReverseDnsResponse result = api.dnsReverse("8.8.8.8", "a", null, 1, null); System.out.println(result); } } diff --git a/examples/java/DomainAvailabilityV2.java b/examples/java/DomainAvailabilityV2.java index c6db2c6..5d2d23b 100644 --- a/examples/java/DomainAvailabilityV2.java +++ b/examples/java/DomainAvailabilityV2.java @@ -1,4 +1,5 @@ // Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DomainAvailabilityV2 // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. @@ -6,16 +7,19 @@ // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DomainAvailabilityApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.DomainAvailabilityResponse; public class DomainAvailabilityV2 { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DomainAvailabilityApi api = new DomainAvailabilityApi(client); - var result = api.domainAvailabilityV2("example.com", null, null, null); + + // domainAvailabilityV2(domain, sug, count, format); null leaves an optional parameter unset + DomainAvailabilityResponse result = api.domainAvailabilityV2("google.com", true, 5, null); System.out.println(result); } } diff --git a/examples/java/DomainReputation.java b/examples/java/DomainReputation.java index 9680086..d6ef988 100644 --- a/examples/java/DomainReputation.java +++ b/examples/java/DomainReputation.java @@ -1,19 +1,23 @@ // Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DomainReputation // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DomainReputationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.DomainReputationResponse; public class DomainReputation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DomainReputationApi api = new DomainReputationApi(client); - var result = api.domainReputation("example.com", null); + + // domainReputation(domainName, format); null leaves an optional parameter unset + DomainReputationResponse result = api.domainReputation("amazon.com", null); System.out.println(result); } } diff --git a/examples/java/DownloadThreatFeedMalware.java b/examples/java/DownloadThreatFeedMalware.java index 5187675..161d6cc 100644 --- a/examples/java/DownloadThreatFeedMalware.java +++ b/examples/java/DownloadThreatFeedMalware.java @@ -1,18 +1,29 @@ // Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedMalware // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedMalware { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedMalware(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.downloadThreatFeedMalware("2026-10-01"); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedMalware.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DownloadThreatFeedMalwareSample.java b/examples/java/DownloadThreatFeedMalwareSample.java index eee8be1..3788bd4 100644 --- a/examples/java/DownloadThreatFeedMalwareSample.java +++ b/examples/java/DownloadThreatFeedMalwareSample.java @@ -1,18 +1,29 @@ // Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedMalwareSample // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedMalwareSample { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedMalwareSample(); - System.out.println(result); + + File download = api.downloadThreatFeedMalwareSample(); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedMalwareSample.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DownloadThreatFeedPhishing.java b/examples/java/DownloadThreatFeedPhishing.java index 499be0f..077d063 100644 --- a/examples/java/DownloadThreatFeedPhishing.java +++ b/examples/java/DownloadThreatFeedPhishing.java @@ -1,18 +1,29 @@ // Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedPhishing // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedPhishing { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedPhishing(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.downloadThreatFeedPhishing("2026-10-01"); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedPhishing.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DownloadThreatFeedPhishingSample.java b/examples/java/DownloadThreatFeedPhishingSample.java index 7d2fcf1..6004fca 100644 --- a/examples/java/DownloadThreatFeedPhishingSample.java +++ b/examples/java/DownloadThreatFeedPhishingSample.java @@ -1,18 +1,29 @@ // Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedPhishingSample // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedPhishingSample { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedPhishingSample(); - System.out.println(result); + + File download = api.downloadThreatFeedPhishingSample(); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedPhishingSample.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DownloadThreatFeedSpam.java b/examples/java/DownloadThreatFeedSpam.java index a02b445..3dafc81 100644 --- a/examples/java/DownloadThreatFeedSpam.java +++ b/examples/java/DownloadThreatFeedSpam.java @@ -1,18 +1,29 @@ // Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedSpam // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedSpam { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedSpam(java.time.LocalDate.now().minusDays(1).toString()); - System.out.println(result); + + File download = api.downloadThreatFeedSpam("2026-10-01"); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedSpam.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/DownloadThreatFeedSpamSample.java b/examples/java/DownloadThreatFeedSpamSample.java index fd8ccaf..23e1267 100644 --- a/examples/java/DownloadThreatFeedSpamSample.java +++ b/examples/java/DownloadThreatFeedSpamSample.java @@ -1,18 +1,29 @@ // Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=DownloadThreatFeedSpamSample // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.DatabasesThreatFeedApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; public class DownloadThreatFeedSpamSample { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call DatabasesThreatFeedApi api = new DatabasesThreatFeedApi(client); - var result = api.downloadThreatFeedSpamSample(); - System.out.println(result); + + File download = api.downloadThreatFeedSpamSample(); + // The SDK saves the response to a temporary file: move it where you want it. + Path target = Paths.get("DownloadThreatFeedSpamSample.csv"); + Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING); + System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath()); } } diff --git a/examples/java/Geolocation.java b/examples/java/Geolocation.java index 001ebc3..e9e22d0 100644 --- a/examples/java/Geolocation.java +++ b/examples/java/Geolocation.java @@ -1,18 +1,21 @@ // Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=Geolocation // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.GeolocationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.GeolocationResponse; public class Geolocation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call GeolocationApi api = new GeolocationApi(client); - var result = api.geolocation("8.8.8.8"); + + GeolocationResponse result = api.geolocation("8.8.8.8"); System.out.println(result); } } diff --git a/examples/java/IpReputation.java b/examples/java/IpReputation.java index 22c002f..7863b09 100644 --- a/examples/java/IpReputation.java +++ b/examples/java/IpReputation.java @@ -1,18 +1,21 @@ // Runnable example: IP Reputation Lookup (GET /v1.0/security) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=IpReputation // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.IpReputationApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.IpReputationResponse; public class IpReputation { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call IpReputationApi api = new IpReputationApi(client); - var result = api.ipReputation("8.8.8.8"); + + IpReputationResponse result = api.ipReputation("8.8.8.8"); System.out.println(result); } } diff --git a/examples/java/IpWhois.java b/examples/java/IpWhois.java index 1479d87..aac809e 100644 --- a/examples/java/IpWhois.java +++ b/examples/java/IpWhois.java @@ -1,19 +1,23 @@ // Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=IpWhois // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.IpWhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.IpWhoisResponse; public class IpWhois { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call IpWhoisApi api = new IpWhoisApi(client); - var result = api.ipWhois("8.8.8.8", null); + + // ipWhois(ip, format); null leaves an optional parameter unset + IpWhoisResponse result = api.ipWhois("8.8.8.8", null); System.out.println(result); } } diff --git a/examples/java/README.md b/examples/java/README.md index 5d13e34..697daa9 100644 --- a/examples/java/README.md +++ b/examples/java/README.md @@ -1,107 +1,107 @@ -# Java — Runnable Examples +# Java Runnable Examples -Install: see the [Java guide](../../docs/languages/java.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [Java guide](../../docs/languages/java.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.java`](WhoisLive.java) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.java`](BulkWhois.java) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.java`](WhoisHistory.java) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.java`](WhoisReverse.java) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.java`](WhoisLive.java): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.java`](BulkWhois.java): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.java`](WhoisHistory.java): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.java`](WhoisReverse.java): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.java`](DnsLive.java) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.java`](DnsHistorical.java) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.java`](DnsReverse.java) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.java`](DnsBulk.java) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.java`](DnsLive.java): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.java`](DnsHistorical.java): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.java`](DnsReverse.java): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.java`](DnsBulk.java): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.java`](DomainAvailabilityV2.java) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.java`](BulkDomainAvailabilityV2.java) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.java`](DomainAvailabilityV2.java): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.java`](BulkDomainAvailabilityV2.java): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.java`](Typosquatting.java) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.java`](Typosquatting.java): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.java`](SslLookup.java) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.java`](SslLookup.java): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.java`](Geolocation.java) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.java`](BulkGeolocation.java) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.java`](Geolocation.java): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.java`](BulkGeolocation.java): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.java`](Subdomains.java) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.java`](Subdomains.java): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.java`](IpReputation.java) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.java`](BulkIpReputation.java) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.java`](IpReputation.java): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.java`](BulkIpReputation.java): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.java`](DomainReputation.java) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.java`](DomainReputation.java): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.java`](AsnWhois.java) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.java`](AsnWhois.java): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.java`](IpWhois.java) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.java`](IpWhois.java): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.java`](RotateApiKey.java) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.java`](AccountUsage.java) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.java`](DatabaseFileStatus.java) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.java`](RotateApiKey.java): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.java`](AccountUsage.java): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.java`](DatabaseFileStatus.java): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.java`](DbNewlyGtld.java) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.java`](DbNewlyCctld.java) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.java`](DbNewlyGtldCleaned.java) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.java`](DbNewlyCctldCleaned.java) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.java`](DbNewlyGtldJson.java) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.java`](DbNewlyCctldJson.java) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.java`](DbNewlyDns.java) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.java`](DbNewlyGtld.java): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.java`](DbNewlyCctld.java): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.java`](DbNewlyGtldCleaned.java): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.java`](DbNewlyCctldCleaned.java): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.java`](DbNewlyGtldJson.java): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.java`](DbNewlyCctldJson.java): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.java`](DbNewlyDns.java): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.java`](DbExpired.java) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.java`](DbExpiredCleaned.java) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.java`](DbDropped.java) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.java`](DbDroppedJson.java) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.java`](DbDroppedBacklinks.java) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.java`](DbExpired.java): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.java`](DbExpiredCleaned.java): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.java`](DbDropped.java): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.java`](DbDroppedJson.java): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.java`](DbDroppedBacklinks.java): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.java`](DbWhoisDaily.java) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.java`](DbWhoisWeekly.java) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.java`](DbWhoisMonthly.java) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.java`](DbWhoisDaily.java): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.java`](DbWhoisWeekly.java): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.java`](DbWhoisMonthly.java): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.java`](DbDnsDaily.java) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.java`](DbDnsWeekly.java) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.java`](DbDnsMonthly.java) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.java`](DbDnsDaily.java): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.java`](DbDnsWeekly.java): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.java`](DbDnsMonthly.java): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.java`](DbSubdomainsDaily.java) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.java`](DbSubdomainsWeekly.java) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.java`](DbSubdomainsMonthly.java) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.java`](DbSubdomainsDaily.java): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.java`](DbSubdomainsWeekly.java): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.java`](DbSubdomainsMonthly.java): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.java`](DbIpCountryStatus.java) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.java`](DbIpCountry.java) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.java`](DbIpCityStatus.java) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.java`](DbIpCity.java) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.java`](DbIpCountryStatus.java): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.java`](DbIpCountry.java): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.java`](DbIpCityStatus.java): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.java`](DbIpCity.java): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.java`](DbAsnWhois.java) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.java`](DbAsnWhoisStatus.java) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.java`](DbAsnWhois.java): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.java`](DbAsnWhoisStatus.java): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.java`](DbIpWhois.java) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.java`](DbIpWhoisStatus.java) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.java`](DbIpWhois.java): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.java`](DbIpWhoisStatus.java): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.java`](DbIpSecurity.java) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.java`](DbIpSecurityStatus.java) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.java`](DbIpSecurity.java): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.java`](DbIpSecurityStatus.java): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.java`](DownloadThreatFeedPhishing.java) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.java`](DownloadThreatFeedPhishingSample.java) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.java`](DownloadThreatFeedMalware.java) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.java`](DownloadThreatFeedMalwareSample.java) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.java`](DownloadThreatFeedSpam.java) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.java`](DownloadThreatFeedSpamSample.java) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.java`](DownloadThreatFeedPhishing.java): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.java`](DownloadThreatFeedPhishingSample.java): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.java`](DownloadThreatFeedMalware.java): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.java`](DownloadThreatFeedMalwareSample.java): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.java`](DownloadThreatFeedSpam.java): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.java`](DownloadThreatFeedSpamSample.java): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/java/RotateApiKey.java b/examples/java/RotateApiKey.java index 8dd405c..9dc6bd3 100644 --- a/examples/java/RotateApiKey.java +++ b/examples/java/RotateApiKey.java @@ -1,18 +1,21 @@ // Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=RotateApiKey // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.AccountApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; public class RotateApiKey { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call AccountApi api = new AccountApi(client); - var result = api.rotateApiKey(); - System.out.println(result); + + String newKey = api.rotateApiKey(); + // The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY. + System.out.println("New API key: " + newKey); } } diff --git a/examples/java/SslLookup.java b/examples/java/SslLookup.java index b50075f..ce4dee3 100644 --- a/examples/java/SslLookup.java +++ b/examples/java/SslLookup.java @@ -1,4 +1,5 @@ // Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=SslLookup // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) @@ -6,16 +7,19 @@ // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.SslApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SslResponse; public class SslLookup { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call SslApi api = new SslApi(client); - var result = api.sslLookup("example.com", null, null, null); + + // sslLookup(domainName, chain, sslRaw, format); null leaves an optional parameter unset + SslResponse result = api.sslLookup("whoisfreaks.com", null, null, null); System.out.println(result); } } diff --git a/examples/java/Subdomains.java b/examples/java/Subdomains.java index 6457092..0cffa73 100644 --- a/examples/java/Subdomains.java +++ b/examples/java/Subdomains.java @@ -1,4 +1,5 @@ // Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=Subdomains // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -8,16 +9,19 @@ // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.SubdomainsApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.SubdomainsResponse; public class Subdomains { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call SubdomainsApi api = new SubdomainsApi(client); - var result = api.subdomains("example.com", "2000-01-01", java.time.LocalDate.now().toString(), null, null, null); + + // subdomains(domain, after, before, status, page, format); null leaves an optional parameter unset + SubdomainsResponse result = api.subdomains("whoisfreaks.com", null, null, null, 1, null); System.out.println(result); } } diff --git a/examples/java/Typosquatting.java b/examples/java/Typosquatting.java index 9571948..d6c8ef0 100644 --- a/examples/java/Typosquatting.java +++ b/examples/java/Typosquatting.java @@ -1,20 +1,24 @@ // Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=Typosquatting // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) // - pageToken (string, optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.TyposquattingApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.TyposquattingResponse; public class Typosquatting { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call TyposquattingApi api = new TyposquattingApi(client); - var result = api.typosquatting(null, null, null); + + // typosquatting(keyword, pattern, pageToken); null leaves an optional parameter unset + TyposquattingResponse result = api.typosquatting("whoisfreaks", null, null); System.out.println(result); } } diff --git a/examples/java/WhoisHistoricalOrReverse.java b/examples/java/WhoisHistoricalOrReverse.java deleted file mode 100644 index 53fbd13..0000000 --- a/examples/java/WhoisHistoricalOrReverse.java +++ /dev/null @@ -1,27 +0,0 @@ -// Runnable example: WHOIS Historical or Reverse Lookup (GET /v1.0/whois) -// Parameters for whoisHistoricalOrReverse (GET /v1.0/whois): -// - apiKey (string, required): Your WHOISFreaks API key -// - whois (string (one of: historical, reverse), required) -// - domainName (string, required): Required for historical lookup -// - keyword (string, optional): For reverse — domain keyword search -// - email (string, optional): For reverse — registrant email search -// - owner (string, optional): For reverse — registrant name search -// - company (string, optional): For reverse — company name search -// - mode (string (one of: default, mini), optional) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import com.whoisfreaks.client.ApiClient; -import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.api.WhoisApi; - -public class WhoisHistoricalOrReverse { - public static void main(String[] args) throws Exception { - ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - WhoisApi api = new WhoisApi(client); - var resp = api.whoisHistoricalOrReverseWithHttpInfo("YOUR_API_KEY", "historical", "example.com", true, null, null, null, null, null, null, null); - System.out.println("status: " + resp.getStatusCode()); - System.out.println(resp.getData()); - } -} diff --git a/examples/java/WhoisHistory.java b/examples/java/WhoisHistory.java index e00bea2..73896a9 100644 --- a/examples/java/WhoisHistory.java +++ b/examples/java/WhoisHistory.java @@ -1,20 +1,23 @@ // Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=WhoisHistory // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.WhoisHistoricalResponse; public class WhoisHistory { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.whoisHistory("example.com", null, null); + + // whoisHistory(domainName, format); null leaves an optional parameter unset + WhoisHistoricalResponse result = api.whoisHistory("whoisfreaks.com", null); System.out.println(result); } } diff --git a/examples/java/WhoisLive.java b/examples/java/WhoisLive.java index 128e243..9478130 100644 --- a/examples/java/WhoisLive.java +++ b/examples/java/WhoisLive.java @@ -1,19 +1,23 @@ // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=WhoisLive // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.WhoisResponse; public class WhoisLive { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.whoisLive("example.com", null); + + // whoisLive(domainName, format); null leaves an optional parameter unset + WhoisResponse result = api.whoisLive("whoisfreaks.com", null); System.out.println(result); } } diff --git a/examples/java/WhoisReverse.java b/examples/java/WhoisReverse.java index c652879..8bbbdcc 100644 --- a/examples/java/WhoisReverse.java +++ b/examples/java/WhoisReverse.java @@ -1,20 +1,24 @@ // Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass=WhoisReverse // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.ApiClient; import com.whoisfreaks.client.Configuration; -import com.whoisfreaks.client.auth.ApiKeyAuth; import com.whoisfreaks.client.api.WhoisApi; +import com.whoisfreaks.client.auth.ApiKeyAuth; +import com.whoisfreaks.client.model.ReverseWhoisResponse; public class WhoisReverse { public static void main(String[] args) throws Exception { ApiClient client = Configuration.getDefaultApiClient(); - client.setBasePath("https://api.whoisfreaks.com"); - ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once + ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth"); + auth.setApiKey(System.getenv("WHOISFREAKS_API_KEY")); // set once, sent with every call WhoisApi api = new WhoisApi(client); - var result = api.whoisReverse("value", null, null); + + // whoisReverse(keyword, page, format); null leaves an optional parameter unset + ReverseWhoisResponse result = api.whoisReverse("whoisfreaks", 1, null); System.out.println(result); } } diff --git a/examples/javascript/AccountUsage.js b/examples/javascript/AccountUsage.js index e34ba28..4691072 100644 --- a/examples/javascript/AccountUsage.js +++ b/examples/javascript/AccountUsage.js @@ -1,15 +1,20 @@ -// Runnable example: Account Usage (GET /v1.0/whoisapi/usage) -// Parameters for accountUsage (GET /v1.0/whoisapi/usage): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, AccountApi } = pkg; -// or: const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Account Usage: GET https://api.whoisfreaks.com/v1.0/whoisapi/usage +// Run: WHOISFREAKS_API_KEY=your_api_key node AccountUsage.js +const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new AccountApi(client); -api.accountUsage() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// accountUsage() takes no parameters. +async function main() { + const result = await api.accountUsage(); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/AsnWhois.js b/examples/javascript/AsnWhois.js index deeb00e..24e6d0b 100644 --- a/examples/javascript/AsnWhois.js +++ b/examples/javascript/AsnWhois.js @@ -1,16 +1,22 @@ -// Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) -// Parameters for asnWhois (GET /v2.0/asn-whois): -// - asn (string, required) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, ASNWHOISApi } = pkg; -// or: const { ApiClient, ASNWHOISApi } = require("whoisfreaks-js"); +// ASN WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/asn-whois +// Run: WHOISFREAKS_API_KEY=your_api_key node AsnWhois.js +const { ApiClient, ASNWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new ASNWHOISApi(client); -api.asnWhois("AS15169") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// asnWhois(asn, opts) +// asn (string, required) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.asnWhois("as15169"); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/BulkDomainAvailabilityV2.js b/examples/javascript/BulkDomainAvailabilityV2.js index 172a6a7..a1c0cf3 100644 --- a/examples/javascript/BulkDomainAvailabilityV2.js +++ b/examples/javascript/BulkDomainAvailabilityV2.js @@ -1,17 +1,24 @@ -// Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) -// Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): -// - domain (string, optional): Required for TLD-mode bulk check (base domain). -// - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DomainAvailabilityApi } = pkg; -// or: const { ApiClient, DomainAvailabilityApi } = require("whoisfreaks-js"); +// Bulk Domain Availability Check: POST https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key node BulkDomainAvailabilityV2.js +const { ApiClient, DomainAvailabilityApi, BulkDomainAvailabilityRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DomainAvailabilityApi(client); -api.bulkDomainAvailabilityV2({}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// bulkDomainAvailabilityV2(bulkDomainAvailabilityRequest, opts) +// bulkDomainAvailabilityRequest (BulkDomainAvailabilityRequest, required): request body +// opts.domain (string, optional): Required for TLD-mode bulk check (base domain) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const body = BulkDomainAvailabilityRequest.constructFromObject({ domainNames: ["whoisfreaks.com", "example.com"] }); + const result = await api.bulkDomainAvailabilityV2(body); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/BulkGeolocation.js b/examples/javascript/BulkGeolocation.js index 2a8a71d..f6fd4c5 100644 --- a/examples/javascript/BulkGeolocation.js +++ b/examples/javascript/BulkGeolocation.js @@ -1,15 +1,22 @@ -// Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) -// Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, GeolocationApi } = pkg; -// or: const { ApiClient, GeolocationApi } = require("whoisfreaks-js"); +// Bulk IP Geolocation: POST https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key node BulkGeolocation.js +const { ApiClient, GeolocationApi, BulkGeolocationRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new GeolocationApi(client); -api.bulkGeolocation({}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// bulkGeolocation(bulkGeolocationRequest) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main() { + const body = BulkGeolocationRequest.constructFromObject({ ips: ["8.8.8.8", "1.1.1.1"] }); + const results = await api.bulkGeolocation(body); + console.log(JSON.stringify(results, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/BulkIpReputation.js b/examples/javascript/BulkIpReputation.js index b5261cd..3d1f744 100644 --- a/examples/javascript/BulkIpReputation.js +++ b/examples/javascript/BulkIpReputation.js @@ -1,15 +1,22 @@ -// Runnable example: Bulk IP Reputation (POST /v1.0/security) -// Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, IPReputationApi } = pkg; -// or: const { ApiClient, IPReputationApi } = require("whoisfreaks-js"); +// Bulk IP Reputation: POST https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key node BulkIpReputation.js +const { ApiClient, IPReputationApi, BulkGeolocationRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new IPReputationApi(client); -api.bulkIpReputation({}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// bulkIpReputation(bulkGeolocationRequest) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main() { + const body = BulkGeolocationRequest.constructFromObject({ ips: ["8.8.8.8", "1.1.1.1"] }); + const results = await api.bulkIpReputation(body); + console.log(JSON.stringify(results, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/BulkWhois.js b/examples/javascript/BulkWhois.js index 2f1799c..fef0cad 100644 --- a/examples/javascript/BulkWhois.js +++ b/examples/javascript/BulkWhois.js @@ -1,16 +1,23 @@ -// Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) -// Parameters for bulkWhois (POST /v2.0/bulkwhois/live): -// - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Bulk WHOIS Lookup: POST https://api.whoisfreaks.com/v2.0/bulkwhois/live +// Run: WHOISFREAKS_API_KEY=your_api_key node BulkWhois.js +const { ApiClient, WHOISApi, BulkWhoisRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.bulkWhois({}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// bulkWhois(bulkWhoisRequest, opts) +// bulkWhoisRequest (BulkWhoisRequest, required): request body +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const body = BulkWhoisRequest.constructFromObject({ domainNames: ["whoisfreaks.com", "jfreaks.com"] }); + const result = await api.bulkWhois(body); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DatabaseFileStatus.js b/examples/javascript/DatabaseFileStatus.js index 8633a2b..a4e48bf 100644 --- a/examples/javascript/DatabaseFileStatus.js +++ b/examples/javascript/DatabaseFileStatus.js @@ -1,15 +1,18 @@ -// Runnable example: Database File Status (Public) (GET /v3.4/status) -// Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, AccountApi } = pkg; -// or: const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Database File Status (Public): GET https://files.whoisfreaks.com/v3.4/status +// Run (public endpoint, no API key needed): node DatabaseFileStatus.js +const { AccountApi } = require("whoisfreaks-js"); -const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once -const api = new AccountApi(client); +// Public endpoint: no API key needed. +const api = new AccountApi(); -api.databaseFileStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// databaseFileStatus() takes no parameters. +async function main() { + const result = await api.databaseFileStatus(); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbAsnWhois.js b/examples/javascript/DbAsnWhois.js index 95a19bd..fca5075 100644 --- a/examples/javascript/DbAsnWhois.js +++ b/examples/javascript/DbAsnWhois.js @@ -1,15 +1,25 @@ -// Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) -// Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesASNWHOISApi } = pkg; -// or: const { ApiClient, DatabasesASNWHOISApi } = require("whoisfreaks-js"); +// ASN WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbAsnWhois.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesASNWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesASNWHOISApi(client); -api.dbAsnWhois(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbAsnWhois(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbAsnWhois("2026-10-01"); // a Buffer with the file's bytes + const file = "DbAsnWhois.json.gz"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbAsnWhoisStatus.js b/examples/javascript/DbAsnWhoisStatus.js index 9cdc308..fb66cfb 100644 --- a/examples/javascript/DbAsnWhoisStatus.js +++ b/examples/javascript/DbAsnWhoisStatus.js @@ -1,15 +1,20 @@ -// Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) -// Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesASNWHOISApi } = pkg; -// or: const { ApiClient, DatabasesASNWHOISApi } = require("whoisfreaks-js"); +// ASN WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbAsnWhoisStatus.js +const { ApiClient, DatabasesASNWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesASNWHOISApi(client); -api.dbAsnWhoisStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbAsnWhoisStatus() takes no parameters. +async function main() { + const result = await api.dbAsnWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbDnsDaily.js b/examples/javascript/DbDnsDaily.js index 37e8da0..e6f0627 100644 --- a/examples/javascript/DbDnsDaily.js +++ b/examples/javascript/DbDnsDaily.js @@ -1,15 +1,25 @@ -// Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) -// Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesDNSApi } = pkg; -// or: const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// DNS Database Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/dns +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDnsDaily.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesDNSApi(client); -api.dbDnsDaily(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDnsDaily(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDnsDaily({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDnsDaily.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbDnsMonthly.js b/examples/javascript/DbDnsMonthly.js index 93cb476..554e22c 100644 --- a/examples/javascript/DbDnsMonthly.js +++ b/examples/javascript/DbDnsMonthly.js @@ -1,15 +1,25 @@ -// Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) -// Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesDNSApi } = pkg; -// or: const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// DNS Database Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDnsMonthly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesDNSApi(client); -api.dbDnsMonthly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDnsMonthly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDnsMonthly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDnsMonthly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbDnsWeekly.js b/examples/javascript/DbDnsWeekly.js index 3d9a9f2..bf05056 100644 --- a/examples/javascript/DbDnsWeekly.js +++ b/examples/javascript/DbDnsWeekly.js @@ -1,15 +1,25 @@ -// Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) -// Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesDNSApi } = pkg; -// or: const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// DNS Database Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDnsWeekly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesDNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesDNSApi(client); -api.dbDnsWeekly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDnsWeekly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDnsWeekly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDnsWeekly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbDropped.js b/examples/javascript/DbDropped.js index 744a1ca..6a22e14 100644 --- a/examples/javascript/DbDropped.js +++ b/examples/javascript/DbDropped.js @@ -1,16 +1,26 @@ -// Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) -// Parameters for dbDropped (GET /v3.1/download/domainer/dropped): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Dropped Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDropped.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbDropped(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDropped(whois, opts) +// whois (boolean, required) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDropped(true, { date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDropped.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbDroppedBacklinks.js b/examples/javascript/DbDroppedBacklinks.js index a1256e8..33edf71 100644 --- a/examples/javascript/DbDroppedBacklinks.js +++ b/examples/javascript/DbDroppedBacklinks.js @@ -1,16 +1,26 @@ -// Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) -// Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): -// - whois (boolean, optional) -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Dropped With Backlinks: GET https://files.whoisfreaks.com/v3.3/download/domainer/dropped/backlinks +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDroppedBacklinks.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbDroppedBacklinks(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDroppedBacklinks(opts) +// opts.whois (boolean, optional) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbDroppedBacklinks({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbDroppedBacklinks.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbDroppedJson.js b/examples/javascript/DbDroppedJson.js index 013b7c5..1ad05f1 100644 --- a/examples/javascript/DbDroppedJson.js +++ b/examples/javascript/DbDroppedJson.js @@ -1,16 +1,23 @@ -// Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) -// Parameters for dbDroppedJson (GET /v3.1/domains/dropped): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Dropped Domains (JSON): GET https://files.whoisfreaks.com/v3.1/domains/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key node DbDroppedJson.js +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbDroppedJson(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbDroppedJson(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const domains = await api.dbDroppedJson({ date: "2026-10-01" }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbExpired.js b/examples/javascript/DbExpired.js index eca24da..0e01de9 100644 --- a/examples/javascript/DbExpired.js +++ b/examples/javascript/DbExpired.js @@ -1,16 +1,26 @@ -// Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) -// Parameters for dbExpired (GET /v3.1/download/domainer/expired): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Expiring Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired +// Run: WHOISFREAKS_API_KEY=your_api_key node DbExpired.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbExpired(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbExpired(whois, opts) +// whois (boolean, required) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbExpired(true, { date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbExpired.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbExpiredCleaned.js b/examples/javascript/DbExpiredCleaned.js index 36773d1..ae789bd 100644 --- a/examples/javascript/DbExpiredCleaned.js +++ b/examples/javascript/DbExpiredCleaned.js @@ -1,15 +1,25 @@ -// Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) -// Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesExpiringDroppedApi } = pkg; -// or: const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Expiring Cleaned WHOIS: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key node DbExpiredCleaned.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesExpiringDroppedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesExpiringDroppedApi(client); -api.dbExpiredCleaned(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbExpiredCleaned(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbExpiredCleaned({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbExpiredCleaned.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbIpCity.js b/examples/javascript/DbIpCity.js index 1869a68..2e5c5c6 100644 --- a/examples/javascript/DbIpCity.js +++ b/examples/javascript/DbIpCity.js @@ -1,15 +1,25 @@ -// Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) -// Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPGeolocationApi } = pkg; -// or: const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// IP to City Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpCity.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPGeolocationApi(client); -api.dbIpCity(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpCity(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbIpCity("2026-10-01"); // a Buffer with the file's bytes + const file = "DbIpCity.zip"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbIpCityStatus.js b/examples/javascript/DbIpCityStatus.js index 6b6d9d6..81a8f75 100644 --- a/examples/javascript/DbIpCityStatus.js +++ b/examples/javascript/DbIpCityStatus.js @@ -1,15 +1,20 @@ -// Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) -// Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPGeolocationApi } = pkg; -// or: const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// IP to City Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpCityStatus.js +const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPGeolocationApi(client); -api.dbIpCityStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpCityStatus() takes no parameters. +async function main() { + const result = await api.dbIpCityStatus(); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbIpCountry.js b/examples/javascript/DbIpCountry.js index d3b8cd5..3740173 100644 --- a/examples/javascript/DbIpCountry.js +++ b/examples/javascript/DbIpCountry.js @@ -1,15 +1,25 @@ -// Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) -// Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPGeolocationApi } = pkg; -// or: const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// IP to Country Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpCountry.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPGeolocationApi(client); -api.dbIpCountry(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpCountry(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbIpCountry("2026-10-01"); // a Buffer with the file's bytes + const file = "DbIpCountry.zip"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbIpCountryStatus.js b/examples/javascript/DbIpCountryStatus.js index f062c5e..db440cc 100644 --- a/examples/javascript/DbIpCountryStatus.js +++ b/examples/javascript/DbIpCountryStatus.js @@ -1,15 +1,20 @@ -// Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) -// Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPGeolocationApi } = pkg; -// or: const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// IP to Country Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpCountryStatus.js +const { ApiClient, DatabasesIPGeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPGeolocationApi(client); -api.dbIpCountryStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpCountryStatus() takes no parameters. +async function main() { + const result = await api.dbIpCountryStatus(); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbIpSecurity.js b/examples/javascript/DbIpSecurity.js index 712697a..0f9c3ca 100644 --- a/examples/javascript/DbIpSecurity.js +++ b/examples/javascript/DbIpSecurity.js @@ -1,15 +1,25 @@ -// Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) -// Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPSecurityApi } = pkg; -// or: const { ApiClient, DatabasesIPSecurityApi } = require("whoisfreaks-js"); +// IP Security Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpSecurity.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesIPSecurityApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPSecurityApi(client); -api.dbIpSecurity(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpSecurity(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbIpSecurity("2026-10-01"); // a Buffer with the file's bytes + const file = "DbIpSecurity.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbIpSecurityStatus.js b/examples/javascript/DbIpSecurityStatus.js index 3c2395b..2402db7 100644 --- a/examples/javascript/DbIpSecurityStatus.js +++ b/examples/javascript/DbIpSecurityStatus.js @@ -1,15 +1,20 @@ -// Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) -// Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPSecurityApi } = pkg; -// or: const { ApiClient, DatabasesIPSecurityApi } = require("whoisfreaks-js"); +// IP Security Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpSecurityStatus.js +const { ApiClient, DatabasesIPSecurityApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPSecurityApi(client); -api.dbIpSecurityStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpSecurityStatus() takes no parameters. +async function main() { + const result = await api.dbIpSecurityStatus(); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbIpWhois.js b/examples/javascript/DbIpWhois.js index 827a675..48d234b 100644 --- a/examples/javascript/DbIpWhois.js +++ b/examples/javascript/DbIpWhois.js @@ -1,15 +1,25 @@ -// Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) -// Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): -// - date (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPWHOISApi } = pkg; -// or: const { ApiClient, DatabasesIPWHOISApi } = require("whoisfreaks-js"); +// IP WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpWhois.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesIPWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPWHOISApi(client); -api.dbIpWhois(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpWhois(date) +// date (string, "yyyy-MM-dd", required) +async function main() { + const data = await api.dbIpWhois("2026-10-01"); // a Buffer with the file's bytes + const file = "DbIpWhois.json.gz"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbIpWhoisStatus.js b/examples/javascript/DbIpWhoisStatus.js index 36628b8..c505655 100644 --- a/examples/javascript/DbIpWhoisStatus.js +++ b/examples/javascript/DbIpWhoisStatus.js @@ -1,15 +1,20 @@ -// Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) -// Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesIPWHOISApi } = pkg; -// or: const { ApiClient, DatabasesIPWHOISApi } = require("whoisfreaks-js"); +// IP WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbIpWhoisStatus.js +const { ApiClient, DatabasesIPWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesIPWHOISApi(client); -api.dbIpWhoisStatus() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbIpWhoisStatus() takes no parameters. +async function main() { + const result = await api.dbIpWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbNewlyCctld.js b/examples/javascript/DbNewlyCctld.js index b64dd4f..d455050 100644 --- a/examples/javascript/DbNewlyCctld.js +++ b/examples/javascript/DbNewlyCctld.js @@ -1,17 +1,27 @@ -// Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) -// Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered ccTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyCctld.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyCctld(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyCctld(whois, opts) +// whois (boolean, required) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const data = await api.dbNewlyCctld(true, { date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyCctld.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbNewlyCctldCleaned.js b/examples/javascript/DbNewlyCctldCleaned.js index 43c7d87..3ff9a2d 100644 --- a/examples/javascript/DbNewlyCctldCleaned.js +++ b/examples/javascript/DbNewlyCctldCleaned.js @@ -1,15 +1,25 @@ -// Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) -// Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered ccTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyCctldCleaned.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyCctldCleaned(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyCctldCleaned(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbNewlyCctldCleaned({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyCctldCleaned.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbNewlyCctldJson.js b/examples/javascript/DbNewlyCctldJson.js index 855bf10..1bb0b0f 100644 --- a/examples/javascript/DbNewlyCctldJson.js +++ b/examples/javascript/DbNewlyCctldJson.js @@ -1,16 +1,23 @@ -// Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) -// Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered ccTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyCctldJson.js +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyCctldJson(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyCctldJson(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const domains = await api.dbNewlyCctldJson({ date: "2026-10-01" }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbNewlyDns.js b/examples/javascript/DbNewlyDns.js index 440ecd4..22e9be6 100644 --- a/examples/javascript/DbNewlyDns.js +++ b/examples/javascript/DbNewlyDns.js @@ -1,15 +1,25 @@ -// Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) -// Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered With DNS: GET https://files.whoisfreaks.com/v3.1/download/domainer/newly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyDns.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyDns(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyDns(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbNewlyDns({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyDns.json"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbNewlyGtld.js b/examples/javascript/DbNewlyGtld.js index ebfd777..50d4c09 100644 --- a/examples/javascript/DbNewlyGtld.js +++ b/examples/javascript/DbNewlyGtld.js @@ -1,17 +1,27 @@ -// Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) -// Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered gTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyGtld.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyGtld(false, new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyGtld(whois, opts) +// whois (boolean, required) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const data = await api.dbNewlyGtld(true, { date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyGtld.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbNewlyGtldCleaned.js b/examples/javascript/DbNewlyGtldCleaned.js index f205b9c..602b010 100644 --- a/examples/javascript/DbNewlyGtldCleaned.js +++ b/examples/javascript/DbNewlyGtldCleaned.js @@ -1,15 +1,25 @@ -// Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) -// Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered gTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyGtldCleaned.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyGtldCleaned(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyGtldCleaned(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbNewlyGtldCleaned({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbNewlyGtldCleaned.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbNewlyGtldJson.js b/examples/javascript/DbNewlyGtldJson.js index b4884da..4e98e3f 100644 --- a/examples/javascript/DbNewlyGtldJson.js +++ b/examples/javascript/DbNewlyGtldJson.js @@ -1,16 +1,23 @@ -// Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) -// Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesNewlyRegisteredApi } = pkg; -// or: const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Newly Registered gTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key node DbNewlyGtldJson.js +const { ApiClient, DatabasesNewlyRegisteredApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesNewlyRegisteredApi(client); -api.dbNewlyGtldJson(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbNewlyGtldJson(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +// opts.tlds (string, optional) +async function main() { + const domains = await api.dbNewlyGtldJson({ date: "2026-10-01" }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbSubdomainsDaily.js b/examples/javascript/DbSubdomainsDaily.js index e7ce6ce..74c8c0b 100644 --- a/examples/javascript/DbSubdomainsDaily.js +++ b/examples/javascript/DbSubdomainsDaily.js @@ -1,15 +1,25 @@ -// Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) -// Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesSubdomainsApi } = pkg; -// or: const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Subdomains Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key node DbSubdomainsDaily.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesSubdomainsApi(client); -api.dbSubdomainsDaily(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbSubdomainsDaily(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbSubdomainsDaily({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbSubdomainsDaily.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbSubdomainsMonthly.js b/examples/javascript/DbSubdomainsMonthly.js index bdcfe13..69c480b 100644 --- a/examples/javascript/DbSubdomainsMonthly.js +++ b/examples/javascript/DbSubdomainsMonthly.js @@ -1,15 +1,25 @@ -// Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) -// Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesSubdomainsApi } = pkg; -// or: const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Subdomains Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key node DbSubdomainsMonthly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesSubdomainsApi(client); -api.dbSubdomainsMonthly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbSubdomainsMonthly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbSubdomainsMonthly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbSubdomainsMonthly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbSubdomainsWeekly.js b/examples/javascript/DbSubdomainsWeekly.js index 9871d2f..e23e497 100644 --- a/examples/javascript/DbSubdomainsWeekly.js +++ b/examples/javascript/DbSubdomainsWeekly.js @@ -1,15 +1,25 @@ -// Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) -// Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesSubdomainsApi } = pkg; -// or: const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Subdomains Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key node DbSubdomainsWeekly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesSubdomainsApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesSubdomainsApi(client); -api.dbSubdomainsWeekly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbSubdomainsWeekly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbSubdomainsWeekly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbSubdomainsWeekly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbWhoisDaily.js b/examples/javascript/DbWhoisDaily.js index f15f4f0..41bf5fd 100644 --- a/examples/javascript/DbWhoisDaily.js +++ b/examples/javascript/DbWhoisDaily.js @@ -1,15 +1,25 @@ -// Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) -// Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesWHOISApi } = pkg; -// or: const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// WHOIS Database Daily: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/daily/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbWhoisDaily.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesWHOISApi(client); -api.dbWhoisDaily(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbWhoisDaily(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbWhoisDaily({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbWhoisDaily.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbWhoisMonthly.js b/examples/javascript/DbWhoisMonthly.js index d0521ed..f4985ba 100644 --- a/examples/javascript/DbWhoisMonthly.js +++ b/examples/javascript/DbWhoisMonthly.js @@ -1,15 +1,25 @@ -// Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) -// Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesWHOISApi } = pkg; -// or: const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// WHOIS Database Monthly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/monthly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbWhoisMonthly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesWHOISApi(client); -api.dbWhoisMonthly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbWhoisMonthly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbWhoisMonthly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbWhoisMonthly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DbWhoisWeekly.js b/examples/javascript/DbWhoisWeekly.js index 64eb939..3df550e 100644 --- a/examples/javascript/DbWhoisWeekly.js +++ b/examples/javascript/DbWhoisWeekly.js @@ -1,15 +1,25 @@ -// Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) -// Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesWHOISApi } = pkg; -// or: const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// WHOIS Database Weekly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/weekly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key node DbWhoisWeekly.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesWHOISApi(client); -api.dbWhoisWeekly(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dbWhoisWeekly(opts) +// opts.date (string, "yyyy-MM-dd", optional): yyyy-MM-dd; omit for latest +async function main() { + const data = await api.dbWhoisWeekly({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DbWhoisWeekly.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DnsBulk.js b/examples/javascript/DnsBulk.js index adb64d7..96ba45c 100644 --- a/examples/javascript/DnsBulk.js +++ b/examples/javascript/DnsBulk.js @@ -1,17 +1,24 @@ -// Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) -// Parameters for dnsBulk (POST /v2.0/dns/bulk/live): -// - type (string, required) -// - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DNSApi } = pkg; -// or: const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Bulk DNS Lookup: POST https://api.whoisfreaks.com/v2.0/dns/bulk/live +// Run: WHOISFREAKS_API_KEY=your_api_key node DnsBulk.js +const { ApiClient, DNSApi, DnsBulkRequest } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DNSApi(client); -api.dnsBulk("value", {}) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dnsBulk(type, dnsBulkRequest, opts) +// type (string, required): default "all" +// dnsBulkRequest (DnsBulkRequest, required): request body +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const body = DnsBulkRequest.constructFromObject({ domainNames: ["whoisfreaks.com", "example.com"] }); + const result = await api.dnsBulk("A,MX,TXT", body); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DnsHistorical.js b/examples/javascript/DnsHistorical.js index f6935f9..caf630f 100644 --- a/examples/javascript/DnsHistorical.js +++ b/examples/javascript/DnsHistorical.js @@ -1,18 +1,24 @@ -// Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) -// Parameters for dnsHistorical (GET /v2.0/dns/historical): -// - domainName (string, required) -// - type (string, required) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DNSApi } = pkg; -// or: const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Historical DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/historical +// Run: WHOISFREAKS_API_KEY=your_api_key node DnsHistorical.js +const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DNSApi(client); -api.dnsHistorical("example.com", "value") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dnsHistorical(domainName, type, opts) +// domainName (string, required) +// type (string, required): default "all" +// opts.page (number, optional): default 1 +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.dnsHistorical("whoisfreaks.com", "A,MX,TXT", { page: 1 }); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DnsLive.js b/examples/javascript/DnsLive.js index e727730..7bcc3fb 100644 --- a/examples/javascript/DnsLive.js +++ b/examples/javascript/DnsLive.js @@ -1,18 +1,24 @@ -// Runnable example: Live DNS Lookup (GET /v2.0/dns/live) -// Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups -// - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DNSApi } = pkg; -// or: const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Live DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/live +// Run: WHOISFREAKS_API_KEY=your_api_key node DnsLive.js +const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DNSApi(client); -api.dnsLive("example.com", "8.8.8.8", "value") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dnsLive(type, opts) +// type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME; default "all" +// opts.domainName (string, optional) +// opts.ipAddress (string, optional): Use for PTR lookups +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.dnsLive("A,MX,TXT", { domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DnsReverse.js b/examples/javascript/DnsReverse.js index 091bda7..62c3ead 100644 --- a/examples/javascript/DnsReverse.js +++ b/examples/javascript/DnsReverse.js @@ -1,19 +1,25 @@ -// Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) -// Parameters for dnsReverse (GET /v2.1/dns/reverse): -// - value (string, required): IP, CIDR, or record value -// - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DNSApi } = pkg; -// or: const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Reverse DNS Lookup: GET https://api.whoisfreaks.com/v2.1/dns/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key node DnsReverse.js +const { ApiClient, DNSApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DNSApi(client); -api.dnsReverse("value", "a", true) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// dnsReverse(value, type, opts) +// value (string, required): IP, CIDR, or record value +// type (string, required): one of a, mx, cname, ns, aaaa, txt, soa +// opts.exact (boolean, optional): default true +// opts.page (number, optional): default 1 +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.dnsReverse("8.8.8.8", "a", { page: 1 }); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DomainAvailabilityV2.js b/examples/javascript/DomainAvailabilityV2.js index 32e9d98..1adb0ee 100644 --- a/examples/javascript/DomainAvailabilityV2.js +++ b/examples/javascript/DomainAvailabilityV2.js @@ -1,18 +1,24 @@ -// Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) -// Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): -// - domain (string, required): The domain name to check -// - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. -// - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DomainAvailabilityApi } = pkg; -// or: const { ApiClient, DomainAvailabilityApi } = require("whoisfreaks-js"); +// Domain Availability Check with Suggestions: GET https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key node DomainAvailabilityV2.js +const { ApiClient, DomainAvailabilityApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DomainAvailabilityApi(client); -api.domainAvailabilityV2("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// domainAvailabilityV2(domain, opts) +// domain (string, required): The domain name to check +// opts.sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain; default false +// opts.count (number, optional): Number of TLD suggestions to return when sug=true. Maximum is 100; default 5 +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.domainAvailabilityV2("google.com", { sug: true, count: 5 }); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DomainReputation.js b/examples/javascript/DomainReputation.js index c4f2f4f..3500481 100644 --- a/examples/javascript/DomainReputation.js +++ b/examples/javascript/DomainReputation.js @@ -1,16 +1,22 @@ -// Runnable example: Domain Reputation Lookup (GET /v1/domain/security) -// Parameters for domainReputation (GET /v1/domain/security): -// - domainName (string, required): The domain name to assess -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DomainReputationApi } = pkg; -// or: const { ApiClient, DomainReputationApi } = require("whoisfreaks-js"); +// Domain Reputation Lookup: GET https://api.whoisfreaks.com/v1/domain/security +// Run: WHOISFREAKS_API_KEY=your_api_key node DomainReputation.js +const { ApiClient, DomainReputationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DomainReputationApi(client); -api.domainReputation("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// domainReputation(domainName, opts) +// domainName (string, required): The domain name to assess +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.domainReputation("amazon.com"); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DownloadThreatFeedMalware.js b/examples/javascript/DownloadThreatFeedMalware.js index 6b0997d..03a7179 100644 --- a/examples/javascript/DownloadThreatFeedMalware.js +++ b/examples/javascript/DownloadThreatFeedMalware.js @@ -1,15 +1,25 @@ -// Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) -// Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download the daily malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedMalware.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedMalware(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedMalware(opts) +// opts.date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main() { + const data = await api.downloadThreatFeedMalware({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DownloadThreatFeedMalware.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DownloadThreatFeedMalwareSample.js b/examples/javascript/DownloadThreatFeedMalwareSample.js index bc0866f..63ba965 100644 --- a/examples/javascript/DownloadThreatFeedMalwareSample.js +++ b/examples/javascript/DownloadThreatFeedMalwareSample.js @@ -1,15 +1,24 @@ -// Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) -// Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download a sample of the malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware/sample +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedMalwareSample.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedMalwareSample() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedMalwareSample() takes no parameters. +async function main() { + const data = await api.downloadThreatFeedMalwareSample(); // a Buffer with the file's bytes + const file = "DownloadThreatFeedMalwareSample.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DownloadThreatFeedPhishing.js b/examples/javascript/DownloadThreatFeedPhishing.js index 4038403..719404a 100644 --- a/examples/javascript/DownloadThreatFeedPhishing.js +++ b/examples/javascript/DownloadThreatFeedPhishing.js @@ -1,15 +1,25 @@ -// Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) -// Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download the daily phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedPhishing.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedPhishing(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedPhishing(opts) +// opts.date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main() { + const data = await api.downloadThreatFeedPhishing({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DownloadThreatFeedPhishing.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DownloadThreatFeedPhishingSample.js b/examples/javascript/DownloadThreatFeedPhishingSample.js index 3a5fca3..333ab95 100644 --- a/examples/javascript/DownloadThreatFeedPhishingSample.js +++ b/examples/javascript/DownloadThreatFeedPhishingSample.js @@ -1,15 +1,24 @@ -// Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) -// Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download a sample of the phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing/sample +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedPhishingSample.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedPhishingSample() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedPhishingSample() takes no parameters. +async function main() { + const data = await api.downloadThreatFeedPhishingSample(); // a Buffer with the file's bytes + const file = "DownloadThreatFeedPhishingSample.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DownloadThreatFeedSpam.js b/examples/javascript/DownloadThreatFeedSpam.js index f084a93..d525240 100644 --- a/examples/javascript/DownloadThreatFeedSpam.js +++ b/examples/javascript/DownloadThreatFeedSpam.js @@ -1,15 +1,25 @@ -// Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) -// Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download the daily spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedSpam.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedSpam(new Date(Date.now()-86400000).toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedSpam(opts) +// opts.date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main() { + const data = await api.downloadThreatFeedSpam({ date: "2026-10-01" }); // a Buffer with the file's bytes + const file = "DownloadThreatFeedSpam.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/DownloadThreatFeedSpamSample.js b/examples/javascript/DownloadThreatFeedSpamSample.js index 98e4592..d62d73a 100644 --- a/examples/javascript/DownloadThreatFeedSpamSample.js +++ b/examples/javascript/DownloadThreatFeedSpamSample.js @@ -1,15 +1,24 @@ -// Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) -// Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, DatabasesThreatFeedApi } = pkg; -// or: const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Download a sample of the spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam/sample +// Run: WHOISFREAKS_API_KEY=your_api_key node DownloadThreatFeedSpamSample.js +const fs = require("node:fs"); +const path = require("node:path"); +const { ApiClient, DatabasesThreatFeedApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new DatabasesThreatFeedApi(client); -api.downloadThreatFeedSpamSample() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// downloadThreatFeedSpamSample() takes no parameters. +async function main() { + const data = await api.downloadThreatFeedSpamSample(); // a Buffer with the file's bytes + const file = "DownloadThreatFeedSpamSample.csv"; + fs.writeFileSync(file, data); + console.log(`Saved ${data.length} bytes to ${path.resolve(file)}`); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/Geolocation.js b/examples/javascript/Geolocation.js index 36d9e3f..c72f0ee 100644 --- a/examples/javascript/Geolocation.js +++ b/examples/javascript/Geolocation.js @@ -1,15 +1,21 @@ -// Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) -// Parameters for geolocation (GET /v1.0/geolocation): -// - ip (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, GeolocationApi } = pkg; -// or: const { ApiClient, GeolocationApi } = require("whoisfreaks-js"); +// IP Geolocation Lookup: GET https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key node Geolocation.js +const { ApiClient, GeolocationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new GeolocationApi(client); -api.geolocation("8.8.8.8") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// geolocation(ip) +// ip (string, required) +async function main() { + const result = await api.geolocation("8.8.8.8"); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/IpReputation.js b/examples/javascript/IpReputation.js index 50a6da6..d325131 100644 --- a/examples/javascript/IpReputation.js +++ b/examples/javascript/IpReputation.js @@ -1,15 +1,21 @@ -// Runnable example: IP Reputation Lookup (GET /v1.0/security) -// Parameters for ipReputation (GET /v1.0/security): -// - ip (string, required) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, IPReputationApi } = pkg; -// or: const { ApiClient, IPReputationApi } = require("whoisfreaks-js"); +// IP Reputation Lookup: GET https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key node IpReputation.js +const { ApiClient, IPReputationApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new IPReputationApi(client); -api.ipReputation("8.8.8.8") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// ipReputation(ip) +// ip (string, required) +async function main() { + const result = await api.ipReputation("8.8.8.8"); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/IpWhois.js b/examples/javascript/IpWhois.js index 6d8e61f..cf0a580 100644 --- a/examples/javascript/IpWhois.js +++ b/examples/javascript/IpWhois.js @@ -1,16 +1,22 @@ -// Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) -// Parameters for ipWhois (GET /v1.0/ip-whois): -// - ip (string, required) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, IPWHOISApi } = pkg; -// or: const { ApiClient, IPWHOISApi } = require("whoisfreaks-js"); +// IP WHOIS Lookup: GET https://api.whoisfreaks.com/v1.0/ip-whois +// Run: WHOISFREAKS_API_KEY=your_api_key node IpWhois.js +const { ApiClient, IPWHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new IPWHOISApi(client); -api.ipWhois("8.8.8.8") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// ipWhois(ip, opts) +// ip (string, required) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.ipWhois("8.8.8.8"); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/README.md b/examples/javascript/README.md index 48c3b75..4c57d9b 100644 --- a/examples/javascript/README.md +++ b/examples/javascript/README.md @@ -1,107 +1,107 @@ -# JavaScript — Runnable Examples +# JavaScript Runnable Examples -Install: see the [JavaScript guide](../../docs/languages/javascript.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [JavaScript guide](../../docs/languages/javascript.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.js`](WhoisLive.js) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.js`](BulkWhois.js) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.js`](WhoisHistory.js) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.js`](WhoisReverse.js) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.js`](WhoisLive.js): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.js`](BulkWhois.js): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.js`](WhoisHistory.js): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.js`](WhoisReverse.js): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.js`](DnsLive.js) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.js`](DnsHistorical.js) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.js`](DnsReverse.js) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.js`](DnsBulk.js) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.js`](DnsLive.js): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.js`](DnsHistorical.js): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.js`](DnsReverse.js): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.js`](DnsBulk.js): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.js`](DomainAvailabilityV2.js) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.js`](BulkDomainAvailabilityV2.js) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.js`](DomainAvailabilityV2.js): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.js`](BulkDomainAvailabilityV2.js): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.js`](Typosquatting.js) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.js`](Typosquatting.js): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.js`](SslLookup.js) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.js`](SslLookup.js): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.js`](Geolocation.js) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.js`](BulkGeolocation.js) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.js`](Geolocation.js): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.js`](BulkGeolocation.js): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.js`](Subdomains.js) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.js`](Subdomains.js): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.js`](IpReputation.js) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.js`](BulkIpReputation.js) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.js`](IpReputation.js): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.js`](BulkIpReputation.js): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.js`](DomainReputation.js) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.js`](DomainReputation.js): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.js`](AsnWhois.js) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.js`](AsnWhois.js): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.js`](IpWhois.js) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.js`](IpWhois.js): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.js`](RotateApiKey.js) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.js`](AccountUsage.js) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.js`](DatabaseFileStatus.js) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.js`](RotateApiKey.js): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.js`](AccountUsage.js): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.js`](DatabaseFileStatus.js): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.js`](DbNewlyGtld.js) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.js`](DbNewlyCctld.js) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.js`](DbNewlyGtldCleaned.js) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.js`](DbNewlyCctldCleaned.js) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.js`](DbNewlyGtldJson.js) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.js`](DbNewlyCctldJson.js) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.js`](DbNewlyDns.js) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.js`](DbNewlyGtld.js): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.js`](DbNewlyCctld.js): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.js`](DbNewlyGtldCleaned.js): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.js`](DbNewlyCctldCleaned.js): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.js`](DbNewlyGtldJson.js): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.js`](DbNewlyCctldJson.js): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.js`](DbNewlyDns.js): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.js`](DbExpired.js) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.js`](DbExpiredCleaned.js) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.js`](DbDropped.js) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.js`](DbDroppedJson.js) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.js`](DbDroppedBacklinks.js) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.js`](DbExpired.js): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.js`](DbExpiredCleaned.js): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.js`](DbDropped.js): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.js`](DbDroppedJson.js): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.js`](DbDroppedBacklinks.js): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.js`](DbWhoisDaily.js) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.js`](DbWhoisWeekly.js) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.js`](DbWhoisMonthly.js) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.js`](DbWhoisDaily.js): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.js`](DbWhoisWeekly.js): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.js`](DbWhoisMonthly.js): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.js`](DbDnsDaily.js) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.js`](DbDnsWeekly.js) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.js`](DbDnsMonthly.js) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.js`](DbDnsDaily.js): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.js`](DbDnsWeekly.js): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.js`](DbDnsMonthly.js): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.js`](DbSubdomainsDaily.js) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.js`](DbSubdomainsWeekly.js) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.js`](DbSubdomainsMonthly.js) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.js`](DbSubdomainsDaily.js): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.js`](DbSubdomainsWeekly.js): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.js`](DbSubdomainsMonthly.js): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.js`](DbIpCountryStatus.js) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.js`](DbIpCountry.js) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.js`](DbIpCityStatus.js) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.js`](DbIpCity.js) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.js`](DbIpCountryStatus.js): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.js`](DbIpCountry.js): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.js`](DbIpCityStatus.js): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.js`](DbIpCity.js): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.js`](DbAsnWhois.js) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.js`](DbAsnWhoisStatus.js) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.js`](DbAsnWhois.js): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.js`](DbAsnWhoisStatus.js): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.js`](DbIpWhois.js) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.js`](DbIpWhoisStatus.js) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.js`](DbIpWhois.js): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.js`](DbIpWhoisStatus.js): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.js`](DbIpSecurity.js) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.js`](DbIpSecurityStatus.js) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.js`](DbIpSecurity.js): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.js`](DbIpSecurityStatus.js): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.js`](DownloadThreatFeedPhishing.js) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.js`](DownloadThreatFeedPhishingSample.js) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.js`](DownloadThreatFeedMalware.js) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.js`](DownloadThreatFeedMalwareSample.js) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.js`](DownloadThreatFeedSpam.js) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.js`](DownloadThreatFeedSpamSample.js) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.js`](DownloadThreatFeedPhishing.js): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.js`](DownloadThreatFeedPhishingSample.js): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.js`](DownloadThreatFeedMalware.js): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.js`](DownloadThreatFeedMalwareSample.js): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.js`](DownloadThreatFeedSpam.js): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.js`](DownloadThreatFeedSpamSample.js): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/javascript/RotateApiKey.js b/examples/javascript/RotateApiKey.js index 8d0e278..ebbfd24 100644 --- a/examples/javascript/RotateApiKey.js +++ b/examples/javascript/RotateApiKey.js @@ -1,15 +1,20 @@ -// Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) -// Parameters for rotateApiKey (GET /v1.0/api-key/rotate): -// (no parameters; the API key is set on the client) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, AccountApi } = pkg; -// or: const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Rotate API Key: GET https://api.whoisfreaks.com/v1.0/api-key/rotate +// Run: WHOISFREAKS_API_KEY=your_api_key node RotateApiKey.js +const { ApiClient, AccountApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new AccountApi(client); -api.rotateApiKey() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// rotateApiKey() takes no parameters. +async function main() { + const newKey = await api.rotateApiKey(); // use this key from now on + console.log("New API key:", newKey); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/SslLookup.js b/examples/javascript/SslLookup.js index ec16c3c..10f45d2 100644 --- a/examples/javascript/SslLookup.js +++ b/examples/javascript/SslLookup.js @@ -1,18 +1,24 @@ -// Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) -// Parameters for sslLookup (GET /v1.0/ssl/live): -// - domainName (string, required) -// - chain (boolean, optional) -// - sslRaw (boolean, optional) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, SSLApi } = pkg; -// or: const { ApiClient, SSLApi } = require("whoisfreaks-js"); +// SSL Certificate Lookup: GET https://api.whoisfreaks.com/v1.0/ssl/live +// Run: WHOISFREAKS_API_KEY=your_api_key node SslLookup.js +const { ApiClient, SSLApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new SSLApi(client); -api.sslLookup("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// sslLookup(domainName, opts) +// domainName (string, required) +// opts.chain (boolean, optional): default false +// opts.sslRaw (boolean, optional): default false +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.sslLookup("whoisfreaks.com"); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/Subdomains.js b/examples/javascript/Subdomains.js index dfa0c8f..4aff309 100644 --- a/examples/javascript/Subdomains.js +++ b/examples/javascript/Subdomains.js @@ -1,20 +1,26 @@ -// Runnable example: Subdomains Lookup (GET /v1.0/subdomains) -// Parameters for subdomains (GET /v1.0/subdomains): -// - domain (string, required) -// - after (string, optional) -// - before (string, optional) -// - status (string (one of: active, inactive), optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, SubdomainsApi } = pkg; -// or: const { ApiClient, SubdomainsApi } = require("whoisfreaks-js"); +// Subdomains Lookup: GET https://api.whoisfreaks.com/v1.0/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key node Subdomains.js +const { ApiClient, SubdomainsApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new SubdomainsApi(client); -api.subdomains("example.com", "2000-01-01", new Date().toISOString().slice(0,10)) - .then(data => console.log(data)) - .catch(err => console.error(err)); +// subdomains(domain, opts) +// domain (string, required) +// opts.after (string, "yyyy-MM-dd", optional) +// opts.before (string, "yyyy-MM-dd", optional) +// opts.status (string, optional): one of active, inactive +// opts.page (number, optional): default 1 +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.subdomains("whoisfreaks.com", { page: 1 }); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/Typosquatting.js b/examples/javascript/Typosquatting.js index 13726fe..35521a8 100644 --- a/examples/javascript/Typosquatting.js +++ b/examples/javascript/Typosquatting.js @@ -1,17 +1,23 @@ -// Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) -// Parameters for typosquatting (GET /v3.0/domain/typos): -// - keyword (string, optional) -// - pattern (string, optional) -// - pageToken (string, optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, TyposquattingApi } = pkg; -// or: const { ApiClient, TyposquattingApi } = require("whoisfreaks-js"); +// Typosquatting Lookup: GET https://api.whoisfreaks.com/v3.0/domain/typos +// Run: WHOISFREAKS_API_KEY=your_api_key node Typosquatting.js +const { ApiClient, TyposquattingApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new TyposquattingApi(client); -api.typosquatting() - .then(data => console.log(data)) - .catch(err => console.error(err)); +// typosquatting(opts) +// opts.keyword (string, optional) +// opts.pattern (string, optional) +// opts.pageToken (string, optional) +async function main() { + const result = await api.typosquatting({ keyword: "whoisfreaks" }); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/WhoisHistoricalOrReverse.js b/examples/javascript/WhoisHistoricalOrReverse.js deleted file mode 100644 index 5e2e505..0000000 --- a/examples/javascript/WhoisHistoricalOrReverse.js +++ /dev/null @@ -1,23 +0,0 @@ -// Runnable example: WHOIS Historical or Reverse Lookup (GET /v1.0/whois) -// Parameters for whoisHistoricalOrReverse (GET /v1.0/whois): -// - apiKey (string, required): Your WHOISFreaks API key -// - whois (string (one of: historical, reverse), required) -// - domainName (string, required): Required for historical lookup -// - keyword (string, optional): For reverse — domain keyword search -// - email (string, optional): For reverse — registrant email search -// - owner (string, optional): For reverse — registrant name search -// - company (string, optional): For reverse — company name search -// - mode (string (one of: default, mini), optional) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS (no Configuration class; apiKey is positional) -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); - -const api = new WHOISApi(); // uses ApiClient.instance - -api.whoisHistoricalOrReverse("YOUR_API_KEY", "historical", "example.com", true) - .then(data => console.log(data)) - .catch(err => console.error(err)); diff --git a/examples/javascript/WhoisHistory.js b/examples/javascript/WhoisHistory.js index 7171e2d..49b84d8 100644 --- a/examples/javascript/WhoisHistory.js +++ b/examples/javascript/WhoisHistory.js @@ -1,17 +1,22 @@ -// Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) -// Parameters for whoisHistory (GET /v2.0/whois/history): -// - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Historical WHOIS records for a domain: GET https://api.whoisfreaks.com/v2.0/whois/history +// Run: WHOISFREAKS_API_KEY=your_api_key node WhoisHistory.js +const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.whoisHistory("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// whoisHistory(domainName, opts) +// domainName (string, required): Domain to fetch historical WHOIS records for +// opts.format (string, optional): one of json, xml +async function main() { + const result = await api.whoisHistory("whoisfreaks.com"); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/WhoisLive.js b/examples/javascript/WhoisLive.js index 158fc4a..8bd66a9 100644 --- a/examples/javascript/WhoisLive.js +++ b/examples/javascript/WhoisLive.js @@ -1,16 +1,22 @@ -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) -// Parameters for whoisLive (GET /v2.0/whois/live): -// - domainName (string, required) -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live +// Run: WHOISFREAKS_API_KEY=your_api_key node WhoisLive.js +const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.whoisLive("example.com") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// whoisLive(domainName, opts) +// domainName (string, required) +// opts.format (string, optional): one of json, xml; default "json" +async function main() { + const result = await api.whoisLive("whoisfreaks.com"); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/javascript/WhoisReverse.js b/examples/javascript/WhoisReverse.js index e034165..6f2b4a9 100644 --- a/examples/javascript/WhoisReverse.js +++ b/examples/javascript/WhoisReverse.js @@ -1,17 +1,23 @@ -// Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) -// Parameters for whoisReverse (GET /v2.0/whois/reverse): -// - keyword (string, required): Keyword to search across WHOIS records -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient -import pkg from "whoisfreaks-js"; -const { ApiClient, WHOISApi } = pkg; -// or: const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Reverse WHOIS lookup by keyword: GET https://api.whoisfreaks.com/v2.0/whois/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key node WhoisReverse.js +const { ApiClient, WHOISApi } = require("whoisfreaks-js"); +// Set the API key once; the client adds it to every request. const client = ApiClient.instance; -client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once +client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY; const api = new WHOISApi(client); -api.whoisReverse("value") - .then(data => console.log(data)) - .catch(err => console.error(err)); +// whoisReverse(keyword, opts) +// keyword (string, required): Keyword to search across WHOIS records +// opts.page (number, optional): Page number +// opts.format (string, optional): one of json, xml +async function main() { + const result = await api.whoisReverse("whoisfreaks", { page: 1 }); + console.log(JSON.stringify(result, null, 2)); +} + +main().catch((err) => { + // API errors carry the HTTP status and the parsed error body + console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err); + process.exitCode = 1; +}); diff --git a/examples/kotlin/AccountUsage.kt b/examples/kotlin/AccountUsage.kt index 3d29cc8..dc44c3d 100644 --- a/examples/kotlin/AccountUsage.kt +++ b/examples/kotlin/AccountUsage.kt @@ -1,12 +1,14 @@ // Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Run it from the Getting Started project: gradle run -PmainClass=AccountUsageKt // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.AccountApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = AccountApi() + val result = api.accountUsage() println(result) } diff --git a/examples/kotlin/AsnWhois.kt b/examples/kotlin/AsnWhois.kt index e748d75..207c9cb 100644 --- a/examples/kotlin/AsnWhois.kt +++ b/examples/kotlin/AsnWhois.kt @@ -1,4 +1,5 @@ // Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// Run it from the Getting Started project: gradle run -PmainClass=AsnWhoisKt // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) @@ -6,8 +7,9 @@ import com.whoisfreaks.client.apis.ASNWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = ASNWHOISApi() - val result = api.asnWhois("AS15169", null) + + val result = api.asnWhois("as15169") println(result) } diff --git a/examples/kotlin/BulkDomainAvailabilityV2.kt b/examples/kotlin/BulkDomainAvailabilityV2.kt index a063ae9..adc5de9 100644 --- a/examples/kotlin/BulkDomainAvailabilityV2.kt +++ b/examples/kotlin/BulkDomainAvailabilityV2.kt @@ -1,15 +1,18 @@ // Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Run it from the Getting Started project: gradle run -PmainClass=BulkDomainAvailabilityV2Kt // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object import com.whoisfreaks.client.apis.DomainAvailabilityApi import com.whoisfreaks.client.infrastructure.ApiClient import com.whoisfreaks.client.models.BulkDomainAvailabilityRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DomainAvailabilityApi() - val result = api.bulkDomainAvailabilityV2(BulkDomainAvailabilityRequest(), null, null) + + val body = BulkDomainAvailabilityRequest(domainNames = listOf("whoisfreaks.com", "example.com")) + val result = api.bulkDomainAvailabilityV2(body) println(result) } diff --git a/examples/kotlin/BulkGeolocation.kt b/examples/kotlin/BulkGeolocation.kt index c203480..74524ec 100644 --- a/examples/kotlin/BulkGeolocation.kt +++ b/examples/kotlin/BulkGeolocation.kt @@ -1,13 +1,16 @@ // Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Run it from the Getting Started project: gradle run -PmainClass=BulkGeolocationKt // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object import com.whoisfreaks.client.apis.GeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient import com.whoisfreaks.client.models.BulkGeolocationRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = GeolocationApi() - val result = api.bulkGeolocation(BulkGeolocationRequest()) + + val body = BulkGeolocationRequest(ips = listOf("8.8.8.8", "1.1.1.1")) + val result = api.bulkGeolocation(body) println(result) } diff --git a/examples/kotlin/BulkIpReputation.kt b/examples/kotlin/BulkIpReputation.kt index 0c5b232..45a7a25 100644 --- a/examples/kotlin/BulkIpReputation.kt +++ b/examples/kotlin/BulkIpReputation.kt @@ -1,13 +1,16 @@ // Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Run it from the Getting Started project: gradle run -PmainClass=BulkIpReputationKt // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object import com.whoisfreaks.client.apis.IPReputationApi import com.whoisfreaks.client.infrastructure.ApiClient -import com.whoisfreaks.client.models.BulkIpReputationRequest +import com.whoisfreaks.client.models.BulkGeolocationRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = IPReputationApi() - val result = api.bulkIpReputation(BulkIpReputationRequest()) + + val body = BulkGeolocationRequest(ips = listOf("8.8.8.8", "1.1.1.1")) + val result = api.bulkIpReputation(body) println(result) } diff --git a/examples/kotlin/BulkWhois.kt b/examples/kotlin/BulkWhois.kt index 238fc2f..39a891f 100644 --- a/examples/kotlin/BulkWhois.kt +++ b/examples/kotlin/BulkWhois.kt @@ -1,14 +1,17 @@ // Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Run it from the Getting Started project: gradle run -PmainClass=BulkWhoisKt // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient import com.whoisfreaks.client.models.BulkWhoisRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.bulkWhois(BulkWhoisRequest(), null) + + val body = BulkWhoisRequest(domainNames = listOf("whoisfreaks.com", "jfreaks.com")) + val result = api.bulkWhois(body) println(result) } diff --git a/examples/kotlin/DatabaseFileStatus.kt b/examples/kotlin/DatabaseFileStatus.kt index 8a75437..e509ecd 100644 --- a/examples/kotlin/DatabaseFileStatus.kt +++ b/examples/kotlin/DatabaseFileStatus.kt @@ -1,12 +1,13 @@ // Runnable example: Database File Status (Public) (GET /v3.4/status) +// Run it from the Getting Started project: gradle run -PmainClass=DatabaseFileStatusKt // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) import com.whoisfreaks.client.apis.AccountApi -import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + // Public endpoint: no API key needed. val api = AccountApi() + val result = api.databaseFileStatus() println(result) } diff --git a/examples/kotlin/DbAsnWhois.kt b/examples/kotlin/DbAsnWhois.kt index 791037f..b76cdf1 100644 --- a/examples/kotlin/DbAsnWhois.kt +++ b/examples/kotlin/DbAsnWhois.kt @@ -1,12 +1,18 @@ // Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbAsnWhoisKt // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesASNWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesASNWHOISApi() - val result = api.dbAsnWhois(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbAsnWhois(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbAsnWhois.json.gz"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbAsnWhoisStatus.kt b/examples/kotlin/DbAsnWhoisStatus.kt index 2a5c876..7c44c68 100644 --- a/examples/kotlin/DbAsnWhoisStatus.kt +++ b/examples/kotlin/DbAsnWhoisStatus.kt @@ -1,12 +1,14 @@ // Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbAsnWhoisStatusKt // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesASNWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesASNWHOISApi() + val result = api.dbAsnWhoisStatus() println(result) } diff --git a/examples/kotlin/DbDnsDaily.kt b/examples/kotlin/DbDnsDaily.kt index bfb1623..d6805a9 100644 --- a/examples/kotlin/DbDnsDaily.kt +++ b/examples/kotlin/DbDnsDaily.kt @@ -1,12 +1,18 @@ // Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// Run it from the Getting Started project: gradle run -PmainClass=DbDnsDailyKt // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesDNSApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesDNSApi() - val result = api.dbDnsDaily(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDnsDaily(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDnsDaily.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbDnsMonthly.kt b/examples/kotlin/DbDnsMonthly.kt index cbfd2ab..240f16d 100644 --- a/examples/kotlin/DbDnsMonthly.kt +++ b/examples/kotlin/DbDnsMonthly.kt @@ -1,12 +1,18 @@ // Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// Run it from the Getting Started project: gradle run -PmainClass=DbDnsMonthlyKt // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesDNSApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesDNSApi() - val result = api.dbDnsMonthly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDnsMonthly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDnsMonthly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbDnsWeekly.kt b/examples/kotlin/DbDnsWeekly.kt index 88c3753..2e08cfb 100644 --- a/examples/kotlin/DbDnsWeekly.kt +++ b/examples/kotlin/DbDnsWeekly.kt @@ -1,12 +1,18 @@ // Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// Run it from the Getting Started project: gradle run -PmainClass=DbDnsWeeklyKt // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesDNSApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesDNSApi() - val result = api.dbDnsWeekly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDnsWeekly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDnsWeekly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbDropped.kt b/examples/kotlin/DbDropped.kt index 865d5b2..18e0b8c 100644 --- a/examples/kotlin/DbDropped.kt +++ b/examples/kotlin/DbDropped.kt @@ -1,13 +1,19 @@ // Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Run it from the Getting Started project: gradle run -PmainClass=DbDroppedKt // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbDropped(false, java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDropped(true, date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDropped.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbDroppedBacklinks.kt b/examples/kotlin/DbDroppedBacklinks.kt index 8e1c099..f768456 100644 --- a/examples/kotlin/DbDroppedBacklinks.kt +++ b/examples/kotlin/DbDroppedBacklinks.kt @@ -1,13 +1,19 @@ // Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Run it from the Getting Started project: gradle run -PmainClass=DbDroppedBacklinksKt // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbDroppedBacklinks(false, java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbDroppedBacklinks(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbDroppedBacklinks.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbDroppedJson.kt b/examples/kotlin/DbDroppedJson.kt index 87b4246..d6ebdd5 100644 --- a/examples/kotlin/DbDroppedJson.kt +++ b/examples/kotlin/DbDroppedJson.kt @@ -1,13 +1,16 @@ // Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Run it from the Getting Started project: gradle run -PmainClass=DbDroppedJsonKt // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbDroppedJson(java.time.LocalDate.now().minusDays(1).toString(), null) + + val result = api.dbDroppedJson(date = LocalDate.of(2026, 10, 1)) println(result) } diff --git a/examples/kotlin/DbExpired.kt b/examples/kotlin/DbExpired.kt index 122cb59..5175458 100644 --- a/examples/kotlin/DbExpired.kt +++ b/examples/kotlin/DbExpired.kt @@ -1,13 +1,19 @@ // Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Run it from the Getting Started project: gradle run -PmainClass=DbExpiredKt // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbExpired(false, java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbExpired(true, date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbExpired.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbExpiredCleaned.kt b/examples/kotlin/DbExpiredCleaned.kt index 2e6dd6c..313159c 100644 --- a/examples/kotlin/DbExpiredCleaned.kt +++ b/examples/kotlin/DbExpiredCleaned.kt @@ -1,12 +1,18 @@ // Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Run it from the Getting Started project: gradle run -PmainClass=DbExpiredCleanedKt // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesExpiringDroppedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesExpiringDroppedApi() - val result = api.dbExpiredCleaned(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbExpiredCleaned(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbExpiredCleaned.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbIpCity.kt b/examples/kotlin/DbIpCity.kt index 928d7e9..4fcfb8f 100644 --- a/examples/kotlin/DbIpCity.kt +++ b/examples/kotlin/DbIpCity.kt @@ -1,12 +1,18 @@ // Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpCityKt // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesIPGeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPGeolocationApi() - val result = api.dbIpCity(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbIpCity(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbIpCity.zip"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbIpCityStatus.kt b/examples/kotlin/DbIpCityStatus.kt index 0bf0f33..81e7431 100644 --- a/examples/kotlin/DbIpCityStatus.kt +++ b/examples/kotlin/DbIpCityStatus.kt @@ -1,12 +1,14 @@ // Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpCityStatusKt // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesIPGeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPGeolocationApi() + val result = api.dbIpCityStatus() println(result) } diff --git a/examples/kotlin/DbIpCountry.kt b/examples/kotlin/DbIpCountry.kt index 5c64e3d..eb00d9b 100644 --- a/examples/kotlin/DbIpCountry.kt +++ b/examples/kotlin/DbIpCountry.kt @@ -1,12 +1,18 @@ // Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpCountryKt // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesIPGeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPGeolocationApi() - val result = api.dbIpCountry(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbIpCountry(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbIpCountry.zip"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbIpCountryStatus.kt b/examples/kotlin/DbIpCountryStatus.kt index 457b467..c85b41c 100644 --- a/examples/kotlin/DbIpCountryStatus.kt +++ b/examples/kotlin/DbIpCountryStatus.kt @@ -1,12 +1,14 @@ // Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpCountryStatusKt // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesIPGeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPGeolocationApi() + val result = api.dbIpCountryStatus() println(result) } diff --git a/examples/kotlin/DbIpSecurity.kt b/examples/kotlin/DbIpSecurity.kt index 89aa398..56d44bf 100644 --- a/examples/kotlin/DbIpSecurity.kt +++ b/examples/kotlin/DbIpSecurity.kt @@ -1,12 +1,18 @@ // Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpSecurityKt // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesIPSecurityApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPSecurityApi() - val result = api.dbIpSecurity(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbIpSecurity(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbIpSecurity.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbIpSecurityStatus.kt b/examples/kotlin/DbIpSecurityStatus.kt index 6d0b10c..151a615 100644 --- a/examples/kotlin/DbIpSecurityStatus.kt +++ b/examples/kotlin/DbIpSecurityStatus.kt @@ -1,12 +1,14 @@ // Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpSecurityStatusKt // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesIPSecurityApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPSecurityApi() + val result = api.dbIpSecurityStatus() println(result) } diff --git a/examples/kotlin/DbIpWhois.kt b/examples/kotlin/DbIpWhois.kt index d63f714..cb5d863 100644 --- a/examples/kotlin/DbIpWhois.kt +++ b/examples/kotlin/DbIpWhois.kt @@ -1,12 +1,18 @@ // Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpWhoisKt // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) import com.whoisfreaks.client.apis.DatabasesIPWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPWHOISApi() - val result = api.dbIpWhois(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbIpWhois(LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbIpWhois.json.gz"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbIpWhoisStatus.kt b/examples/kotlin/DbIpWhoisStatus.kt index 45f3e1c..5592d50 100644 --- a/examples/kotlin/DbIpWhoisStatus.kt +++ b/examples/kotlin/DbIpWhoisStatus.kt @@ -1,12 +1,14 @@ // Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbIpWhoisStatusKt // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesIPWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesIPWHOISApi() + val result = api.dbIpWhoisStatus() println(result) } diff --git a/examples/kotlin/DbNewlyCctld.kt b/examples/kotlin/DbNewlyCctld.kt index 70dfd38..d74af8d 100644 --- a/examples/kotlin/DbNewlyCctld.kt +++ b/examples/kotlin/DbNewlyCctld.kt @@ -1,14 +1,20 @@ // Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyCctldKt // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyCctld(false, java.time.LocalDate.now().minusDays(1).toString(), null) - println(result) + + val download = api.dbNewlyCctld(true, date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyCctld.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbNewlyCctldCleaned.kt b/examples/kotlin/DbNewlyCctldCleaned.kt index d6268f5..8a0897d 100644 --- a/examples/kotlin/DbNewlyCctldCleaned.kt +++ b/examples/kotlin/DbNewlyCctldCleaned.kt @@ -1,12 +1,18 @@ // Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyCctldCleanedKt // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyCctldCleaned(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbNewlyCctldCleaned(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyCctldCleaned.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbNewlyCctldJson.kt b/examples/kotlin/DbNewlyCctldJson.kt index 5665c51..feed8f7 100644 --- a/examples/kotlin/DbNewlyCctldJson.kt +++ b/examples/kotlin/DbNewlyCctldJson.kt @@ -1,13 +1,16 @@ // Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyCctldJsonKt // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyCctldJson(java.time.LocalDate.now().minusDays(1).toString(), null) + + val result = api.dbNewlyCctldJson(date = LocalDate.of(2026, 10, 1)) println(result) } diff --git a/examples/kotlin/DbNewlyDns.kt b/examples/kotlin/DbNewlyDns.kt index c811161..942bef2 100644 --- a/examples/kotlin/DbNewlyDns.kt +++ b/examples/kotlin/DbNewlyDns.kt @@ -1,12 +1,18 @@ // Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyDnsKt // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyDns(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbNewlyDns(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyDns.json"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbNewlyGtld.kt b/examples/kotlin/DbNewlyGtld.kt index f5f7274..5ce7a3f 100644 --- a/examples/kotlin/DbNewlyGtld.kt +++ b/examples/kotlin/DbNewlyGtld.kt @@ -1,14 +1,20 @@ // Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyGtldKt // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyGtld(false, java.time.LocalDate.now().minusDays(1).toString(), null) - println(result) + + val download = api.dbNewlyGtld(true, date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyGtld.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbNewlyGtldCleaned.kt b/examples/kotlin/DbNewlyGtldCleaned.kt index 86d8bf1..ae1d898 100644 --- a/examples/kotlin/DbNewlyGtldCleaned.kt +++ b/examples/kotlin/DbNewlyGtldCleaned.kt @@ -1,12 +1,18 @@ // Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyGtldCleanedKt // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyGtldCleaned(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbNewlyGtldCleaned(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbNewlyGtldCleaned.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbNewlyGtldJson.kt b/examples/kotlin/DbNewlyGtldJson.kt index 5694c53..67cf534 100644 --- a/examples/kotlin/DbNewlyGtldJson.kt +++ b/examples/kotlin/DbNewlyGtldJson.kt @@ -1,13 +1,16 @@ // Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Run it from the Getting Started project: gradle run -PmainClass=DbNewlyGtldJsonKt // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) import com.whoisfreaks.client.apis.DatabasesNewlyRegisteredApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesNewlyRegisteredApi() - val result = api.dbNewlyGtldJson(java.time.LocalDate.now().minusDays(1).toString(), null) + + val result = api.dbNewlyGtldJson(date = LocalDate.of(2026, 10, 1)) println(result) } diff --git a/examples/kotlin/DbSubdomainsDaily.kt b/examples/kotlin/DbSubdomainsDaily.kt index e20e471..1bc3940 100644 --- a/examples/kotlin/DbSubdomainsDaily.kt +++ b/examples/kotlin/DbSubdomainsDaily.kt @@ -1,12 +1,18 @@ // Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Run it from the Getting Started project: gradle run -PmainClass=DbSubdomainsDailyKt // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesSubdomainsApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesSubdomainsApi() - val result = api.dbSubdomainsDaily(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbSubdomainsDaily(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbSubdomainsDaily.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbSubdomainsMonthly.kt b/examples/kotlin/DbSubdomainsMonthly.kt index 3cbd283..470b5df 100644 --- a/examples/kotlin/DbSubdomainsMonthly.kt +++ b/examples/kotlin/DbSubdomainsMonthly.kt @@ -1,12 +1,18 @@ // Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Run it from the Getting Started project: gradle run -PmainClass=DbSubdomainsMonthlyKt // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesSubdomainsApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesSubdomainsApi() - val result = api.dbSubdomainsMonthly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbSubdomainsMonthly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbSubdomainsMonthly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbSubdomainsWeekly.kt b/examples/kotlin/DbSubdomainsWeekly.kt index 9efa9fd..86fa9c3 100644 --- a/examples/kotlin/DbSubdomainsWeekly.kt +++ b/examples/kotlin/DbSubdomainsWeekly.kt @@ -1,12 +1,18 @@ // Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Run it from the Getting Started project: gradle run -PmainClass=DbSubdomainsWeeklyKt // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesSubdomainsApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesSubdomainsApi() - val result = api.dbSubdomainsWeekly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbSubdomainsWeekly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbSubdomainsWeekly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbWhoisDaily.kt b/examples/kotlin/DbWhoisDaily.kt index 411acd8..ea610d5 100644 --- a/examples/kotlin/DbWhoisDaily.kt +++ b/examples/kotlin/DbWhoisDaily.kt @@ -1,12 +1,18 @@ // Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbWhoisDailyKt // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesWHOISApi() - val result = api.dbWhoisDaily(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbWhoisDaily(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbWhoisDaily.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbWhoisMonthly.kt b/examples/kotlin/DbWhoisMonthly.kt index 9442bba..674d960 100644 --- a/examples/kotlin/DbWhoisMonthly.kt +++ b/examples/kotlin/DbWhoisMonthly.kt @@ -1,12 +1,18 @@ // Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbWhoisMonthlyKt // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesWHOISApi() - val result = api.dbWhoisMonthly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbWhoisMonthly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbWhoisMonthly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DbWhoisWeekly.kt b/examples/kotlin/DbWhoisWeekly.kt index 49afa70..cc3356b 100644 --- a/examples/kotlin/DbWhoisWeekly.kt +++ b/examples/kotlin/DbWhoisWeekly.kt @@ -1,12 +1,18 @@ // Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// Run it from the Getting Started project: gradle run -PmainClass=DbWhoisWeeklyKt // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest import com.whoisfreaks.client.apis.DatabasesWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File +import java.time.LocalDate fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesWHOISApi() - val result = api.dbWhoisWeekly(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.dbWhoisWeekly(date = LocalDate.of(2026, 10, 1)) + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DbWhoisWeekly.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DnsBulk.kt b/examples/kotlin/DnsBulk.kt index 1c7034e..2ed44df 100644 --- a/examples/kotlin/DnsBulk.kt +++ b/examples/kotlin/DnsBulk.kt @@ -1,15 +1,18 @@ // Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Run it from the Getting Started project: gradle run -PmainClass=DnsBulkKt // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object import com.whoisfreaks.client.apis.DNSApi import com.whoisfreaks.client.infrastructure.ApiClient import com.whoisfreaks.client.models.DnsBulkRequest fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DNSApi() - val result = api.dnsBulk("value", DnsBulkRequest(), null) + + val body = DnsBulkRequest(domainNames = listOf("whoisfreaks.com", "example.com")) + val result = api.dnsBulk("A,MX,TXT", body) println(result) } diff --git a/examples/kotlin/DnsHistorical.kt b/examples/kotlin/DnsHistorical.kt index 7ce0458..e7dee08 100644 --- a/examples/kotlin/DnsHistorical.kt +++ b/examples/kotlin/DnsHistorical.kt @@ -1,4 +1,5 @@ // Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Run it from the Getting Started project: gradle run -PmainClass=DnsHistoricalKt // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) @@ -8,8 +9,9 @@ import com.whoisfreaks.client.apis.DNSApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DNSApi() - val result = api.dnsHistorical("example.com", "value", null, null) + + val result = api.dnsHistorical("whoisfreaks.com", "A,MX,TXT", page = 1) println(result) } diff --git a/examples/kotlin/DnsLive.kt b/examples/kotlin/DnsLive.kt index 1fd5358..9b076a0 100644 --- a/examples/kotlin/DnsLive.kt +++ b/examples/kotlin/DnsLive.kt @@ -1,15 +1,17 @@ // Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Run it from the Getting Started project: gradle run -PmainClass=DnsLiveKt // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.apis.DNSApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DNSApi() - val result = api.dnsLive("example.com", "8.8.8.8", "value", null) + + val result = api.dnsLive("A,MX,TXT", domainName = "whoisfreaks.com") println(result) } diff --git a/examples/kotlin/DnsReverse.kt b/examples/kotlin/DnsReverse.kt index 913bb2c..4d4b08f 100644 --- a/examples/kotlin/DnsReverse.kt +++ b/examples/kotlin/DnsReverse.kt @@ -1,4 +1,5 @@ // Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Run it from the Getting Started project: gradle run -PmainClass=DnsReverseKt // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) @@ -9,8 +10,9 @@ import com.whoisfreaks.client.apis.DNSApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DNSApi() - val result = api.dnsReverse("value", "a", true, null, null) + + val result = api.dnsReverse("8.8.8.8", DNSApi.TypeDnsReverse.a, page = 1) println(result) } diff --git a/examples/kotlin/DomainAvailabilityV2.kt b/examples/kotlin/DomainAvailabilityV2.kt index 9b13918..0818124 100644 --- a/examples/kotlin/DomainAvailabilityV2.kt +++ b/examples/kotlin/DomainAvailabilityV2.kt @@ -1,4 +1,5 @@ // Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Run it from the Getting Started project: gradle run -PmainClass=DomainAvailabilityV2Kt // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. @@ -8,8 +9,9 @@ import com.whoisfreaks.client.apis.DomainAvailabilityApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DomainAvailabilityApi() - val result = api.domainAvailabilityV2("example.com", null, null, null) + + val result = api.domainAvailabilityV2("google.com", sug = true, count = 5) println(result) } diff --git a/examples/kotlin/DomainReputation.kt b/examples/kotlin/DomainReputation.kt index 9f85692..e9b6de5 100644 --- a/examples/kotlin/DomainReputation.kt +++ b/examples/kotlin/DomainReputation.kt @@ -1,4 +1,5 @@ // Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Run it from the Getting Started project: gradle run -PmainClass=DomainReputationKt // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) @@ -6,8 +7,9 @@ import com.whoisfreaks.client.apis.DomainReputationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DomainReputationApi() - val result = api.domainReputation("example.com", null) + + val result = api.domainReputation("amazon.com") println(result) } diff --git a/examples/kotlin/DownloadThreatFeedMalware.kt b/examples/kotlin/DownloadThreatFeedMalware.kt index bd720d3..5cea0ef 100644 --- a/examples/kotlin/DownloadThreatFeedMalware.kt +++ b/examples/kotlin/DownloadThreatFeedMalware.kt @@ -1,12 +1,17 @@ // Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedMalwareKt // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedMalware(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.downloadThreatFeedMalware(date = "2026-10-01") + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedMalware.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DownloadThreatFeedMalwareSample.kt b/examples/kotlin/DownloadThreatFeedMalwareSample.kt index 964879a..d503e38 100644 --- a/examples/kotlin/DownloadThreatFeedMalwareSample.kt +++ b/examples/kotlin/DownloadThreatFeedMalwareSample.kt @@ -1,12 +1,17 @@ // Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedMalwareSampleKt // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedMalwareSample() - println(result) + + val download = api.downloadThreatFeedMalwareSample() + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedMalwareSample.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DownloadThreatFeedPhishing.kt b/examples/kotlin/DownloadThreatFeedPhishing.kt index e53f432..f91b335 100644 --- a/examples/kotlin/DownloadThreatFeedPhishing.kt +++ b/examples/kotlin/DownloadThreatFeedPhishing.kt @@ -1,12 +1,17 @@ // Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedPhishingKt // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedPhishing(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.downloadThreatFeedPhishing(date = "2026-10-01") + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedPhishing.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DownloadThreatFeedPhishingSample.kt b/examples/kotlin/DownloadThreatFeedPhishingSample.kt index d06f166..9ecf9b9 100644 --- a/examples/kotlin/DownloadThreatFeedPhishingSample.kt +++ b/examples/kotlin/DownloadThreatFeedPhishingSample.kt @@ -1,12 +1,17 @@ // Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedPhishingSampleKt // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedPhishingSample() - println(result) + + val download = api.downloadThreatFeedPhishingSample() + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedPhishingSample.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DownloadThreatFeedSpam.kt b/examples/kotlin/DownloadThreatFeedSpam.kt index 096f60b..dc0ba2a 100644 --- a/examples/kotlin/DownloadThreatFeedSpam.kt +++ b/examples/kotlin/DownloadThreatFeedSpam.kt @@ -1,12 +1,17 @@ // Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedSpamKt // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedSpam(java.time.LocalDate.now().minusDays(1).toString()) - println(result) + + val download = api.downloadThreatFeedSpam(date = "2026-10-01") + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedSpam.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/DownloadThreatFeedSpamSample.kt b/examples/kotlin/DownloadThreatFeedSpamSample.kt index d88e881..cfdc684 100644 --- a/examples/kotlin/DownloadThreatFeedSpamSample.kt +++ b/examples/kotlin/DownloadThreatFeedSpamSample.kt @@ -1,12 +1,17 @@ // Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Run it from the Getting Started project: gradle run -PmainClass=DownloadThreatFeedSpamSampleKt // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.DatabasesThreatFeedApi import com.whoisfreaks.client.infrastructure.ApiClient +import java.io.File fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = DatabasesThreatFeedApi() - val result = api.downloadThreatFeedSpamSample() - println(result) + + val download = api.downloadThreatFeedSpamSample() + // The SDK saves the response to a temporary file that is deleted on exit: copy it. + val target = download.copyTo(File("DownloadThreatFeedSpamSample.csv"), overwrite = true) + println("Saved ${target.length()} bytes to ${target.absolutePath}") } diff --git a/examples/kotlin/Geolocation.kt b/examples/kotlin/Geolocation.kt index e4d3f8e..d34d0bd 100644 --- a/examples/kotlin/Geolocation.kt +++ b/examples/kotlin/Geolocation.kt @@ -1,12 +1,14 @@ // Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// Run it from the Getting Started project: gradle run -PmainClass=GeolocationKt // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) import com.whoisfreaks.client.apis.GeolocationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = GeolocationApi() + val result = api.geolocation("8.8.8.8") println(result) } diff --git a/examples/kotlin/IpReputation.kt b/examples/kotlin/IpReputation.kt index a683108..744f9b6 100644 --- a/examples/kotlin/IpReputation.kt +++ b/examples/kotlin/IpReputation.kt @@ -1,12 +1,14 @@ // Runnable example: IP Reputation Lookup (GET /v1.0/security) +// Run it from the Getting Started project: gradle run -PmainClass=IpReputationKt // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) import com.whoisfreaks.client.apis.IPReputationApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = IPReputationApi() + val result = api.ipReputation("8.8.8.8") println(result) } diff --git a/examples/kotlin/IpWhois.kt b/examples/kotlin/IpWhois.kt index 7b1e7a4..512326e 100644 --- a/examples/kotlin/IpWhois.kt +++ b/examples/kotlin/IpWhois.kt @@ -1,4 +1,5 @@ // Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// Run it from the Getting Started project: gradle run -PmainClass=IpWhoisKt // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) @@ -6,8 +7,9 @@ import com.whoisfreaks.client.apis.IPWHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = IPWHOISApi() - val result = api.ipWhois("8.8.8.8", null) + + val result = api.ipWhois("8.8.8.8") println(result) } diff --git a/examples/kotlin/README.md b/examples/kotlin/README.md index 649bef1..69064d1 100644 --- a/examples/kotlin/README.md +++ b/examples/kotlin/README.md @@ -1,107 +1,107 @@ -# Kotlin — Runnable Examples +# Kotlin Runnable Examples -Install: see the [Kotlin guide](../../docs/languages/kotlin.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [Kotlin guide](../../docs/languages/kotlin.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.kt`](WhoisLive.kt) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.kt`](BulkWhois.kt) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.kt`](WhoisHistory.kt) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.kt`](WhoisReverse.kt) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.kt`](WhoisLive.kt): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.kt`](BulkWhois.kt): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.kt`](WhoisHistory.kt): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.kt`](WhoisReverse.kt): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.kt`](DnsLive.kt) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.kt`](DnsHistorical.kt) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.kt`](DnsReverse.kt) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.kt`](DnsBulk.kt) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.kt`](DnsLive.kt): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.kt`](DnsHistorical.kt): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.kt`](DnsReverse.kt): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.kt`](DnsBulk.kt): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.kt`](DomainAvailabilityV2.kt) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.kt`](BulkDomainAvailabilityV2.kt) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.kt`](DomainAvailabilityV2.kt): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.kt`](BulkDomainAvailabilityV2.kt): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.kt`](Typosquatting.kt) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.kt`](Typosquatting.kt): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.kt`](SslLookup.kt) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.kt`](SslLookup.kt): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.kt`](Geolocation.kt) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.kt`](BulkGeolocation.kt) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.kt`](Geolocation.kt): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.kt`](BulkGeolocation.kt): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.kt`](Subdomains.kt) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.kt`](Subdomains.kt): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.kt`](IpReputation.kt) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.kt`](BulkIpReputation.kt) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.kt`](IpReputation.kt): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.kt`](BulkIpReputation.kt): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.kt`](DomainReputation.kt) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.kt`](DomainReputation.kt): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.kt`](AsnWhois.kt) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.kt`](AsnWhois.kt): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.kt`](IpWhois.kt) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.kt`](IpWhois.kt): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.kt`](RotateApiKey.kt) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.kt`](AccountUsage.kt) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.kt`](DatabaseFileStatus.kt) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.kt`](RotateApiKey.kt): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.kt`](AccountUsage.kt): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.kt`](DatabaseFileStatus.kt): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.kt`](DbNewlyGtld.kt) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.kt`](DbNewlyCctld.kt) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.kt`](DbNewlyGtldCleaned.kt) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.kt`](DbNewlyCctldCleaned.kt) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.kt`](DbNewlyGtldJson.kt) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.kt`](DbNewlyCctldJson.kt) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.kt`](DbNewlyDns.kt) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.kt`](DbNewlyGtld.kt): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.kt`](DbNewlyCctld.kt): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.kt`](DbNewlyGtldCleaned.kt): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.kt`](DbNewlyCctldCleaned.kt): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.kt`](DbNewlyGtldJson.kt): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.kt`](DbNewlyCctldJson.kt): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.kt`](DbNewlyDns.kt): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.kt`](DbExpired.kt) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.kt`](DbExpiredCleaned.kt) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.kt`](DbDropped.kt) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.kt`](DbDroppedJson.kt) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.kt`](DbDroppedBacklinks.kt) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.kt`](DbExpired.kt): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.kt`](DbExpiredCleaned.kt): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.kt`](DbDropped.kt): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.kt`](DbDroppedJson.kt): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.kt`](DbDroppedBacklinks.kt): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.kt`](DbWhoisDaily.kt) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.kt`](DbWhoisWeekly.kt) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.kt`](DbWhoisMonthly.kt) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.kt`](DbWhoisDaily.kt): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.kt`](DbWhoisWeekly.kt): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.kt`](DbWhoisMonthly.kt): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.kt`](DbDnsDaily.kt) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.kt`](DbDnsWeekly.kt) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.kt`](DbDnsMonthly.kt) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.kt`](DbDnsDaily.kt): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.kt`](DbDnsWeekly.kt): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.kt`](DbDnsMonthly.kt): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.kt`](DbSubdomainsDaily.kt) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.kt`](DbSubdomainsWeekly.kt) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.kt`](DbSubdomainsMonthly.kt) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.kt`](DbSubdomainsDaily.kt): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.kt`](DbSubdomainsWeekly.kt): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.kt`](DbSubdomainsMonthly.kt): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.kt`](DbIpCountryStatus.kt) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.kt`](DbIpCountry.kt) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.kt`](DbIpCityStatus.kt) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.kt`](DbIpCity.kt) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.kt`](DbIpCountryStatus.kt): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.kt`](DbIpCountry.kt): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.kt`](DbIpCityStatus.kt): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.kt`](DbIpCity.kt): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.kt`](DbAsnWhois.kt) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.kt`](DbAsnWhoisStatus.kt) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.kt`](DbAsnWhois.kt): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.kt`](DbAsnWhoisStatus.kt): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.kt`](DbIpWhois.kt) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.kt`](DbIpWhoisStatus.kt) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.kt`](DbIpWhois.kt): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.kt`](DbIpWhoisStatus.kt): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.kt`](DbIpSecurity.kt) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.kt`](DbIpSecurityStatus.kt) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.kt`](DbIpSecurity.kt): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.kt`](DbIpSecurityStatus.kt): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.kt`](DownloadThreatFeedPhishing.kt) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.kt`](DownloadThreatFeedPhishingSample.kt) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.kt`](DownloadThreatFeedMalware.kt) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.kt`](DownloadThreatFeedMalwareSample.kt) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.kt`](DownloadThreatFeedSpam.kt) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.kt`](DownloadThreatFeedSpamSample.kt) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.kt`](DownloadThreatFeedPhishing.kt): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.kt`](DownloadThreatFeedPhishingSample.kt): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.kt`](DownloadThreatFeedMalware.kt): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.kt`](DownloadThreatFeedMalwareSample.kt): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.kt`](DownloadThreatFeedSpam.kt): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.kt`](DownloadThreatFeedSpamSample.kt): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/kotlin/RotateApiKey.kt b/examples/kotlin/RotateApiKey.kt index b6772c4..71f2864 100644 --- a/examples/kotlin/RotateApiKey.kt +++ b/examples/kotlin/RotateApiKey.kt @@ -1,12 +1,15 @@ // Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Run it from the Getting Started project: gradle run -PmainClass=RotateApiKeyKt // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) import com.whoisfreaks.client.apis.AccountApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = AccountApi() - val result = api.rotateApiKey() - println(result) + + val newKey = api.rotateApiKey() + // The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY. + println("New API key: $newKey") } diff --git a/examples/kotlin/SslLookup.kt b/examples/kotlin/SslLookup.kt index f949d85..f0c7f8b 100644 --- a/examples/kotlin/SslLookup.kt +++ b/examples/kotlin/SslLookup.kt @@ -1,4 +1,5 @@ // Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// Run it from the Getting Started project: gradle run -PmainClass=SslLookupKt // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) @@ -8,8 +9,9 @@ import com.whoisfreaks.client.apis.SSLApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = SSLApi() - val result = api.sslLookup("example.com", null, null, null) + + val result = api.sslLookup("whoisfreaks.com") println(result) } diff --git a/examples/kotlin/Subdomains.kt b/examples/kotlin/Subdomains.kt index c518fca..c9580ab 100644 --- a/examples/kotlin/Subdomains.kt +++ b/examples/kotlin/Subdomains.kt @@ -1,4 +1,5 @@ // Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Run it from the Getting Started project: gradle run -PmainClass=SubdomainsKt // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -10,8 +11,9 @@ import com.whoisfreaks.client.apis.SubdomainsApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = SubdomainsApi() - val result = api.subdomains("example.com", "2000-01-01", java.time.LocalDate.now().toString(), null, null, null) + + val result = api.subdomains("whoisfreaks.com", page = 1) println(result) } diff --git a/examples/kotlin/Typosquatting.kt b/examples/kotlin/Typosquatting.kt index 21305a6..30c5bf0 100644 --- a/examples/kotlin/Typosquatting.kt +++ b/examples/kotlin/Typosquatting.kt @@ -1,4 +1,5 @@ // Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Run it from the Getting Started project: gradle run -PmainClass=TyposquattingKt // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) @@ -7,8 +8,9 @@ import com.whoisfreaks.client.apis.TyposquattingApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = TyposquattingApi() - val result = api.typosquatting(null, null, null) + + val result = api.typosquatting(keyword = "whoisfreaks") println(result) } diff --git a/examples/kotlin/WhoisHistoricalOrReverse.kt b/examples/kotlin/WhoisHistoricalOrReverse.kt deleted file mode 100644 index 7686244..0000000 --- a/examples/kotlin/WhoisHistoricalOrReverse.kt +++ /dev/null @@ -1,20 +0,0 @@ -// Runnable example: WHOIS Historical or Reverse Lookup (GET /v1.0/whois) -// Parameters for whoisHistoricalOrReverse (GET /v1.0/whois): -// - apiKey (string, required): Your WHOISFreaks API key -// - whois (string (one of: historical, reverse), required) -// - domainName (string, required): Required for historical lookup -// - keyword (string, optional): For reverse — domain keyword search -// - email (string, optional): For reverse — registrant email search -// - owner (string, optional): For reverse — registrant name search -// - company (string, optional): For reverse — company name search -// - mode (string (one of: default, mini), optional) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import com.whoisfreaks.api.WHOISApi - -fun main() { - val api = WHOISApi(basePath = "https://api.whoisfreaks.com") - val result = api.whoisHistoricalOrReverse("YOUR_API_KEY", "historical", "example.com", true, null, null, null, null, null, null, null) - println(result) // status via api.whoisHistoricalOrReverseWithHttpInfo(...).statusCode -} diff --git a/examples/kotlin/WhoisHistory.kt b/examples/kotlin/WhoisHistory.kt index c5df412..d89846a 100644 --- a/examples/kotlin/WhoisHistory.kt +++ b/examples/kotlin/WhoisHistory.kt @@ -1,14 +1,15 @@ // Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Run it from the Getting Started project: gradle run -PmainClass=WhoisHistoryKt // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.whoisHistory("example.com", null, null) + + val result = api.whoisHistory("whoisfreaks.com") println(result) } diff --git a/examples/kotlin/WhoisLive.kt b/examples/kotlin/WhoisLive.kt index 1b76560..38caf5e 100644 --- a/examples/kotlin/WhoisLive.kt +++ b/examples/kotlin/WhoisLive.kt @@ -1,4 +1,5 @@ // Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Run it from the Getting Started project: gradle run -PmainClass=WhoisLiveKt // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) @@ -6,8 +7,9 @@ import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.whoisLive("example.com", null) + + val result = api.whoisLive("whoisfreaks.com") println(result) } diff --git a/examples/kotlin/WhoisReverse.kt b/examples/kotlin/WhoisReverse.kt index 9897bc5..1402d3b 100644 --- a/examples/kotlin/WhoisReverse.kt +++ b/examples/kotlin/WhoisReverse.kt @@ -1,4 +1,5 @@ // Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Run it from the Getting Started project: gradle run -PmainClass=WhoisReverseKt // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number @@ -7,8 +8,9 @@ import com.whoisfreaks.client.apis.WHOISApi import com.whoisfreaks.client.infrastructure.ApiClient fun main() { - ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once + ApiClient.apiKey["apiKey"] = System.getenv("WHOISFREAKS_API_KEY") // set once, sent with every call val api = WHOISApi() - val result = api.whoisReverse("value", null, null) + + val result = api.whoisReverse("whoisfreaks", page = 1) println(result) } diff --git a/examples/php/AccountUsage.php b/examples/php/AccountUsage.php index 27e4f1c..954c07b 100644 --- a/examples/php/AccountUsage.php +++ b/examples/php/AccountUsage.php @@ -1,11 +1,26 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\AccountApi(new GuzzleHttp\Client(), $config); -$result = $api->accountUsage(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\AccountApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new AccountApi(new Client(), $config); + +try { + $result = $api->accountUsage(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/AsnWhois.php b/examples/php/AsnWhois.php index d1ee338..e9e15b9 100644 --- a/examples/php/AsnWhois.php +++ b/examples/php/AsnWhois.php @@ -1,12 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\ASNWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->asnWhois("AS15169", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\ASNWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new ASNWHOISApi(new Client(), $config); + +try { + $result = $api->asnWhois('as15169'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/BulkDomainAvailabilityV2.php b/examples/php/BulkDomainAvailabilityV2.php index 4a23a35..1686dfc 100644 --- a/examples/php/BulkDomainAvailabilityV2.php +++ b/examples/php/BulkDomainAvailabilityV2.php @@ -1,13 +1,33 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DomainAvailabilityApi(new GuzzleHttp\Client(), $config); -$result = $api->bulkDomainAvailabilityV2(new WhoisFreaks\Model\BulkDomainAvailabilityRequest(), null, null); -print_r($result); +// - body: BulkDomainAvailabilityRequest (required): request body object + +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DomainAvailabilityApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; +use WhoisFreaks\Model\BulkDomainAvailabilityRequest; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DomainAvailabilityApi(new Client(), $config); + +$request = new BulkDomainAvailabilityRequest([ + 'domainNames' => ['whoisfreaks.com', 'example.com'], +]); + +try { + $result = $api->bulkDomainAvailabilityV2($request); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/BulkGeolocation.php b/examples/php/BulkGeolocation.php index 7c8e89f..36c9c62 100644 --- a/examples/php/BulkGeolocation.php +++ b/examples/php/BulkGeolocation.php @@ -1,11 +1,33 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\GeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->bulkGeolocation(new WhoisFreaks\Model\BulkGeolocationRequest()); -print_r($result); +// - body: BulkGeolocationRequest (required): request body object + +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\GeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; +use WhoisFreaks\Model\BulkGeolocationRequest; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new GeolocationApi(new Client(), $config); + +$request = new BulkGeolocationRequest([ + 'ips' => ['8.8.8.8', '1.1.1.1'], +]); + +try { + $results = $api->bulkGeolocation($request); + foreach ($results as $result) { + echo $result, PHP_EOL; // models print as JSON + } +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/BulkIpReputation.php b/examples/php/BulkIpReputation.php index 7ae212a..211fe58 100644 --- a/examples/php/BulkIpReputation.php +++ b/examples/php/BulkIpReputation.php @@ -1,11 +1,33 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\IPReputationApi(new GuzzleHttp\Client(), $config); -$result = $api->bulkIpReputation(new WhoisFreaks\Model\BulkIpReputationRequest()); -print_r($result); +// - body: BulkGeolocationRequest (required): request body object + +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\IPReputationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; +use WhoisFreaks\Model\BulkGeolocationRequest; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new IPReputationApi(new Client(), $config); + +$request = new BulkGeolocationRequest([ + 'ips' => ['8.8.8.8', '1.1.1.1'], +]); + +try { + $results = $api->bulkIpReputation($request); + foreach ($results as $result) { + echo $result, PHP_EOL; // models print as JSON + } +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/BulkWhois.php b/examples/php/BulkWhois.php index e3dcf42..c0157e2 100644 --- a/examples/php/BulkWhois.php +++ b/examples/php/BulkWhois.php @@ -1,12 +1,32 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->bulkWhois(new WhoisFreaks\Model\BulkWhoisRequest(), null); -print_r($result); +// - body: BulkWhoisRequest (required): request body object + +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\WHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; +use WhoisFreaks\Model\BulkWhoisRequest; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new WHOISApi(new Client(), $config); + +$request = new BulkWhoisRequest([ + 'domainNames' => ['whoisfreaks.com', 'jfreaks.com'], +]); + +try { + $result = $api->bulkWhois($request); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DatabaseFileStatus.php b/examples/php/DatabaseFileStatus.php index 0b31695..6fea1d5 100644 --- a/examples/php/DatabaseFileStatus.php +++ b/examples/php/DatabaseFileStatus.php @@ -1,11 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\AccountApi(new GuzzleHttp\Client(), $config); -$result = $api->databaseFileStatus(); -print_r($result); +// (no parameters; no API key required) + +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\AccountApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +// (This endpoint is public, so the key is not sent with this request.) +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new AccountApi(new Client(), $config); + +try { + $result = $api->databaseFileStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbAsnWhois.php b/examples/php/DbAsnWhois.php index c9227fc..147c36e 100644 --- a/examples/php/DbAsnWhois.php +++ b/examples/php/DbAsnWhois.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesASNWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbAsnWhois((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesASNWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesASNWHOISApi(new Client(), $config); + +try { + $file = $api->dbAsnWhois('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbAsnWhois.json.gz'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbAsnWhoisStatus.php b/examples/php/DbAsnWhoisStatus.php index 84c76c8..011b365 100644 --- a/examples/php/DbAsnWhoisStatus.php +++ b/examples/php/DbAsnWhoisStatus.php @@ -1,11 +1,26 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesASNWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbAsnWhoisStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesASNWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesASNWHOISApi(new Client(), $config); + +try { + $result = $api->dbAsnWhoisStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbDnsDaily.php b/examples/php/DbDnsDaily.php index 26d49eb..65aa60d 100644 --- a/examples/php/DbDnsDaily.php +++ b/examples/php/DbDnsDaily.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesDNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDnsDaily((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesDNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesDNSApi(new Client(), $config); + +try { + $file = $api->dbDnsDaily('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDnsDaily.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbDnsMonthly.php b/examples/php/DbDnsMonthly.php index 7c459b8..443161c 100644 --- a/examples/php/DbDnsMonthly.php +++ b/examples/php/DbDnsMonthly.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesDNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDnsMonthly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesDNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesDNSApi(new Client(), $config); + +try { + $file = $api->dbDnsMonthly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDnsMonthly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbDnsWeekly.php b/examples/php/DbDnsWeekly.php index b3a7718..d7350e3 100644 --- a/examples/php/DbDnsWeekly.php +++ b/examples/php/DbDnsWeekly.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesDNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDnsWeekly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesDNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesDNSApi(new Client(), $config); + +try { + $file = $api->dbDnsWeekly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDnsWeekly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbDropped.php b/examples/php/DbDropped.php index e25ee46..c2c146e 100644 --- a/examples/php/DbDropped.php +++ b/examples/php/DbDropped.php @@ -1,12 +1,30 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDropped(false, (new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $file = $api->dbDropped(true, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDropped.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbDroppedBacklinks.php b/examples/php/DbDroppedBacklinks.php index 9dbe7fe..df5d7b8 100644 --- a/examples/php/DbDroppedBacklinks.php +++ b/examples/php/DbDroppedBacklinks.php @@ -1,12 +1,30 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDroppedBacklinks(false, (new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $file = $api->dbDroppedBacklinks(null, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbDroppedBacklinks.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbDroppedJson.php b/examples/php/DbDroppedJson.php index 79997d5..f7fef61 100644 --- a/examples/php/DbDroppedJson.php +++ b/examples/php/DbDroppedJson.php @@ -1,12 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbDroppedJson((new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $domains = $api->dbDroppedJson('2026-10-01'); + echo implode(PHP_EOL, $domains), PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbExpired.php b/examples/php/DbExpired.php index 66d633a..c29b473 100644 --- a/examples/php/DbExpired.php +++ b/examples/php/DbExpired.php @@ -1,12 +1,30 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbExpired(false, (new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $file = $api->dbExpired(true, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbExpired.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbExpiredCleaned.php b/examples/php/DbExpiredCleaned.php index 92d6e00..decedc7 100644 --- a/examples/php/DbExpiredCleaned.php +++ b/examples/php/DbExpiredCleaned.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesExpiringDroppedApi(new GuzzleHttp\Client(), $config); -$result = $api->dbExpiredCleaned((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesExpiringDroppedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesExpiringDroppedApi(new Client(), $config); + +try { + $file = $api->dbExpiredCleaned('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbExpiredCleaned.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbIpCity.php b/examples/php/DbIpCity.php index d92bb62..f31aab8 100644 --- a/examples/php/DbIpCity.php +++ b/examples/php/DbIpCity.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPGeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpCity((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPGeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPGeolocationApi(new Client(), $config); + +try { + $file = $api->dbIpCity('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbIpCity.zip'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbIpCityStatus.php b/examples/php/DbIpCityStatus.php index 3c113d8..cd33b46 100644 --- a/examples/php/DbIpCityStatus.php +++ b/examples/php/DbIpCityStatus.php @@ -1,11 +1,26 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPGeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpCityStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPGeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPGeolocationApi(new Client(), $config); + +try { + $result = $api->dbIpCityStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbIpCountry.php b/examples/php/DbIpCountry.php index ec1ca4a..bd3cb04 100644 --- a/examples/php/DbIpCountry.php +++ b/examples/php/DbIpCountry.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPGeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpCountry((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPGeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPGeolocationApi(new Client(), $config); + +try { + $file = $api->dbIpCountry('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbIpCountry.zip'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbIpCountryStatus.php b/examples/php/DbIpCountryStatus.php index f68d474..0688d6b 100644 --- a/examples/php/DbIpCountryStatus.php +++ b/examples/php/DbIpCountryStatus.php @@ -1,11 +1,26 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPGeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpCountryStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPGeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPGeolocationApi(new Client(), $config); + +try { + $result = $api->dbIpCountryStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbIpSecurity.php b/examples/php/DbIpSecurity.php index 768ecc0..ad03d42 100644 --- a/examples/php/DbIpSecurity.php +++ b/examples/php/DbIpSecurity.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPSecurityApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpSecurity((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPSecurityApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPSecurityApi(new Client(), $config); + +try { + $file = $api->dbIpSecurity('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbIpSecurity.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbIpSecurityStatus.php b/examples/php/DbIpSecurityStatus.php index c8dba6a..1bbbb25 100644 --- a/examples/php/DbIpSecurityStatus.php +++ b/examples/php/DbIpSecurityStatus.php @@ -1,11 +1,26 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPSecurityApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpSecurityStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPSecurityApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPSecurityApi(new Client(), $config); + +try { + $result = $api->dbIpSecurityStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbIpWhois.php b/examples/php/DbIpWhois.php index 43b5237..e5aa539 100644 --- a/examples/php/DbIpWhois.php +++ b/examples/php/DbIpWhois.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpWhois((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPWHOISApi(new Client(), $config); + +try { + $file = $api->dbIpWhois('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbIpWhois.json.gz'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbIpWhoisStatus.php b/examples/php/DbIpWhoisStatus.php index bc19403..e9a4e8b 100644 --- a/examples/php/DbIpWhoisStatus.php +++ b/examples/php/DbIpWhoisStatus.php @@ -1,11 +1,26 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesIPWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbIpWhoisStatus(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesIPWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesIPWHOISApi(new Client(), $config); + +try { + $result = $api->dbIpWhoisStatus(); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbNewlyCctld.php b/examples/php/DbNewlyCctld.php index f750a2d..435191b 100644 --- a/examples/php/DbNewlyCctld.php +++ b/examples/php/DbNewlyCctld.php @@ -1,13 +1,31 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyCctld(false, (new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyCctld(true, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyCctld.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbNewlyCctldCleaned.php b/examples/php/DbNewlyCctldCleaned.php index 8b1cbc7..5ed0f19 100644 --- a/examples/php/DbNewlyCctldCleaned.php +++ b/examples/php/DbNewlyCctldCleaned.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyCctldCleaned((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyCctldCleaned('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyCctldCleaned.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbNewlyCctldJson.php b/examples/php/DbNewlyCctldJson.php index 624dbb5..102b5cb 100644 --- a/examples/php/DbNewlyCctldJson.php +++ b/examples/php/DbNewlyCctldJson.php @@ -1,12 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyCctldJson((new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $domains = $api->dbNewlyCctldJson('2026-10-01'); + echo implode(PHP_EOL, $domains), PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbNewlyDns.php b/examples/php/DbNewlyDns.php index 601b263..d0a9563 100644 --- a/examples/php/DbNewlyDns.php +++ b/examples/php/DbNewlyDns.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyDns((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyDns('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyDns.json'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbNewlyGtld.php b/examples/php/DbNewlyGtld.php index e4062b6..209ffa7 100644 --- a/examples/php/DbNewlyGtld.php +++ b/examples/php/DbNewlyGtld.php @@ -1,13 +1,31 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyGtld(false, (new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyGtld(true, '2026-10-01'); // whois, date + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyGtld.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbNewlyGtldCleaned.php b/examples/php/DbNewlyGtldCleaned.php index dd452b2..7dd0189 100644 --- a/examples/php/DbNewlyGtldCleaned.php +++ b/examples/php/DbNewlyGtldCleaned.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyGtldCleaned((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $file = $api->dbNewlyGtldCleaned('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbNewlyGtldCleaned.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbNewlyGtldJson.php b/examples/php/DbNewlyGtldJson.php index 0d89437..68b35ff 100644 --- a/examples/php/DbNewlyGtldJson.php +++ b/examples/php/DbNewlyGtldJson.php @@ -1,12 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesNewlyRegisteredApi(new GuzzleHttp\Client(), $config); -$result = $api->dbNewlyGtldJson((new DateTime("yesterday"))->format("Y-m-d"), null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesNewlyRegisteredApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesNewlyRegisteredApi(new Client(), $config); + +try { + $domains = $api->dbNewlyGtldJson('2026-10-01'); + echo implode(PHP_EOL, $domains), PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbSubdomainsDaily.php b/examples/php/DbSubdomainsDaily.php index f245206..bcf511f 100644 --- a/examples/php/DbSubdomainsDaily.php +++ b/examples/php/DbSubdomainsDaily.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesSubdomainsApi(new GuzzleHttp\Client(), $config); -$result = $api->dbSubdomainsDaily((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesSubdomainsApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesSubdomainsApi(new Client(), $config); + +try { + $file = $api->dbSubdomainsDaily('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbSubdomainsDaily.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbSubdomainsMonthly.php b/examples/php/DbSubdomainsMonthly.php index 227a38a..6c89a6f 100644 --- a/examples/php/DbSubdomainsMonthly.php +++ b/examples/php/DbSubdomainsMonthly.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesSubdomainsApi(new GuzzleHttp\Client(), $config); -$result = $api->dbSubdomainsMonthly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesSubdomainsApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesSubdomainsApi(new Client(), $config); + +try { + $file = $api->dbSubdomainsMonthly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbSubdomainsMonthly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbSubdomainsWeekly.php b/examples/php/DbSubdomainsWeekly.php index d41d8ef..99243b7 100644 --- a/examples/php/DbSubdomainsWeekly.php +++ b/examples/php/DbSubdomainsWeekly.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesSubdomainsApi(new GuzzleHttp\Client(), $config); -$result = $api->dbSubdomainsWeekly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesSubdomainsApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesSubdomainsApi(new Client(), $config); + +try { + $file = $api->dbSubdomainsWeekly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbSubdomainsWeekly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbWhoisDaily.php b/examples/php/DbWhoisDaily.php index fde3843..b70d840 100644 --- a/examples/php/DbWhoisDaily.php +++ b/examples/php/DbWhoisDaily.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbWhoisDaily((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesWHOISApi(new Client(), $config); + +try { + $file = $api->dbWhoisDaily('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbWhoisDaily.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbWhoisMonthly.php b/examples/php/DbWhoisMonthly.php index 0f1afec..645513c 100644 --- a/examples/php/DbWhoisMonthly.php +++ b/examples/php/DbWhoisMonthly.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbWhoisMonthly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesWHOISApi(new Client(), $config); + +try { + $file = $api->dbWhoisMonthly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbWhoisMonthly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DbWhoisWeekly.php b/examples/php/DbWhoisWeekly.php index 4c68634..e02b14f 100644 --- a/examples/php/DbWhoisWeekly.php +++ b/examples/php/DbWhoisWeekly.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->dbWhoisWeekly((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesWHOISApi(new Client(), $config); + +try { + $file = $api->dbWhoisWeekly('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DbWhoisWeekly.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DnsBulk.php b/examples/php/DnsBulk.php index 69bd88f..6dd855a 100644 --- a/examples/php/DnsBulk.php +++ b/examples/php/DnsBulk.php @@ -1,13 +1,33 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dnsBulk("value", new WhoisFreaks\Model\DnsBulkRequest(), null); -print_r($result); +// - body: DnsBulkRequest (required): request body object + +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; +use WhoisFreaks\Model\DnsBulkRequest; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DNSApi(new Client(), $config); + +$request = new DnsBulkRequest([ + 'domainNames' => ['whoisfreaks.com', 'example.com'], +]); + +try { + $result = $api->dnsBulk('A,MX,TXT', $request); // type, dnsBulkRequest + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DnsHistorical.php b/examples/php/DnsHistorical.php index 4e14ab9..35d5354 100644 --- a/examples/php/DnsHistorical.php +++ b/examples/php/DnsHistorical.php @@ -1,14 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dnsHistorical("example.com", "value", null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DNSApi(new Client(), $config); + +try { + $result = $api->dnsHistorical('whoisfreaks.com', 'A,MX,TXT', 1); // domainName, type, page + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DnsLive.php b/examples/php/DnsLive.php index f8fe782..17c4d46 100644 --- a/examples/php/DnsLive.php +++ b/examples/php/DnsLive.php @@ -1,14 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dnsLive("example.com", "8.8.8.8", "value", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DNSApi(new Client(), $config); + +try { + $result = $api->dnsLive('A,MX,TXT', 'whoisfreaks.com'); // type, domainName + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DnsReverse.php b/examples/php/DnsReverse.php index 195bb12..d7bb77c 100644 --- a/examples/php/DnsReverse.php +++ b/examples/php/DnsReverse.php @@ -1,15 +1,30 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DNSApi(new GuzzleHttp\Client(), $config); -$result = $api->dnsReverse("value", "a", true, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DNSApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DNSApi(new Client(), $config); + +try { + $result = $api->dnsReverse('8.8.8.8', 'a', true, 1); // value, type, exact, page + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DomainAvailabilityV2.php b/examples/php/DomainAvailabilityV2.php index db3dd0d..9c57723 100644 --- a/examples/php/DomainAvailabilityV2.php +++ b/examples/php/DomainAvailabilityV2.php @@ -1,14 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DomainAvailabilityApi(new GuzzleHttp\Client(), $config); -$result = $api->domainAvailabilityV2("example.com", null, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DomainAvailabilityApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DomainAvailabilityApi(new Client(), $config); + +try { + $result = $api->domainAvailabilityV2('google.com', true, 5); // domain, sug, count + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DomainReputation.php b/examples/php/DomainReputation.php index 5dcbc9b..c0db3fc 100644 --- a/examples/php/DomainReputation.php +++ b/examples/php/DomainReputation.php @@ -1,12 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DomainReputationApi(new GuzzleHttp\Client(), $config); -$result = $api->domainReputation("example.com", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DomainReputationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DomainReputationApi(new Client(), $config); + +try { + $result = $api->domainReputation('amazon.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DownloadThreatFeedMalware.php b/examples/php/DownloadThreatFeedMalware.php index 0e75cd0..f46986b 100644 --- a/examples/php/DownloadThreatFeedMalware.php +++ b/examples/php/DownloadThreatFeedMalware.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedMalware((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedMalware('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedMalware.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DownloadThreatFeedMalwareSample.php b/examples/php/DownloadThreatFeedMalwareSample.php index 74e35dd..ae846c5 100644 --- a/examples/php/DownloadThreatFeedMalwareSample.php +++ b/examples/php/DownloadThreatFeedMalwareSample.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedMalwareSample(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedMalwareSample(); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedMalwareSample.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DownloadThreatFeedPhishing.php b/examples/php/DownloadThreatFeedPhishing.php index f4d0f66..e1550c8 100644 --- a/examples/php/DownloadThreatFeedPhishing.php +++ b/examples/php/DownloadThreatFeedPhishing.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedPhishing((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedPhishing('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedPhishing.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DownloadThreatFeedPhishingSample.php b/examples/php/DownloadThreatFeedPhishingSample.php index 246553a..db2ba9f 100644 --- a/examples/php/DownloadThreatFeedPhishingSample.php +++ b/examples/php/DownloadThreatFeedPhishingSample.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedPhishingSample(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedPhishingSample(); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedPhishingSample.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DownloadThreatFeedSpam.php b/examples/php/DownloadThreatFeedSpam.php index 2ac971a..9ae2a3e 100644 --- a/examples/php/DownloadThreatFeedSpam.php +++ b/examples/php/DownloadThreatFeedSpam.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedSpam((new DateTime("yesterday"))->format("Y-m-d")); -print_r($result); +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed + +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedSpam('2026-10-01'); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedSpam.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/DownloadThreatFeedSpamSample.php b/examples/php/DownloadThreatFeedSpamSample.php index 1f22a43..6c29798 100644 --- a/examples/php/DownloadThreatFeedSpamSample.php +++ b/examples/php/DownloadThreatFeedSpamSample.php @@ -1,11 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\DatabasesThreatFeedApi(new GuzzleHttp\Client(), $config); -$result = $api->downloadThreatFeedSpamSample(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\DatabasesThreatFeedApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new DatabasesThreatFeedApi(new Client(), $config); + +try { + $file = $api->downloadThreatFeedSpamSample(); + // The SDK streams the download into a temporary file: copy it somewhere permanent. + $saveAs = 'DownloadThreatFeedSpamSample.csv'; + copy($file->getPathname(), $saveAs); + echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/Geolocation.php b/examples/php/Geolocation.php index e1dad76..e00244f 100644 --- a/examples/php/Geolocation.php +++ b/examples/php/Geolocation.php @@ -1,11 +1,26 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\GeolocationApi(new GuzzleHttp\Client(), $config); -$result = $api->geolocation("8.8.8.8"); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\GeolocationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new GeolocationApi(new Client(), $config); + +try { + $result = $api->geolocation('8.8.8.8'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/IpReputation.php b/examples/php/IpReputation.php index 428c5c5..009de82 100644 --- a/examples/php/IpReputation.php +++ b/examples/php/IpReputation.php @@ -1,11 +1,26 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\IPReputationApi(new GuzzleHttp\Client(), $config); -$result = $api->ipReputation("8.8.8.8"); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\IPReputationApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new IPReputationApi(new Client(), $config); + +try { + $result = $api->ipReputation('8.8.8.8'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/IpWhois.php b/examples/php/IpWhois.php index de4be49..9402477 100644 --- a/examples/php/IpWhois.php +++ b/examples/php/IpWhois.php @@ -1,12 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\IPWHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->ipWhois("8.8.8.8", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\IPWHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new IPWHOISApi(new Client(), $config); + +try { + $result = $api->ipWhois('8.8.8.8'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/README.md b/examples/php/README.md index eb4e237..0437272 100644 --- a/examples/php/README.md +++ b/examples/php/README.md @@ -1,107 +1,107 @@ -# PHP — Runnable Examples +# PHP Runnable Examples -Install: see the [PHP guide](../../docs/languages/php.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [PHP guide](../../docs/languages/php.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.php`](WhoisLive.php) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.php`](BulkWhois.php) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.php`](WhoisHistory.php) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.php`](WhoisReverse.php) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.php`](WhoisLive.php): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.php`](BulkWhois.php): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.php`](WhoisHistory.php): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.php`](WhoisReverse.php): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.php`](DnsLive.php) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.php`](DnsHistorical.php) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.php`](DnsReverse.php) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.php`](DnsBulk.php) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.php`](DnsLive.php): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.php`](DnsHistorical.php): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.php`](DnsReverse.php): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.php`](DnsBulk.php): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.php`](DomainAvailabilityV2.php) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.php`](BulkDomainAvailabilityV2.php) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.php`](DomainAvailabilityV2.php): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.php`](BulkDomainAvailabilityV2.php): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.php`](Typosquatting.php) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.php`](Typosquatting.php): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.php`](SslLookup.php) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.php`](SslLookup.php): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.php`](Geolocation.php) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.php`](BulkGeolocation.php) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.php`](Geolocation.php): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.php`](BulkGeolocation.php): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.php`](Subdomains.php) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.php`](Subdomains.php): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.php`](IpReputation.php) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.php`](BulkIpReputation.php) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.php`](IpReputation.php): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.php`](BulkIpReputation.php): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.php`](DomainReputation.php) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.php`](DomainReputation.php): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.php`](AsnWhois.php) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.php`](AsnWhois.php): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.php`](IpWhois.php) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.php`](IpWhois.php): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.php`](RotateApiKey.php) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.php`](AccountUsage.php) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.php`](DatabaseFileStatus.php) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.php`](RotateApiKey.php): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.php`](AccountUsage.php): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.php`](DatabaseFileStatus.php): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.php`](DbNewlyGtld.php) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.php`](DbNewlyCctld.php) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.php`](DbNewlyGtldCleaned.php) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.php`](DbNewlyCctldCleaned.php) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.php`](DbNewlyGtldJson.php) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.php`](DbNewlyCctldJson.php) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.php`](DbNewlyDns.php) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.php`](DbNewlyGtld.php): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.php`](DbNewlyCctld.php): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.php`](DbNewlyGtldCleaned.php): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.php`](DbNewlyCctldCleaned.php): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.php`](DbNewlyGtldJson.php): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.php`](DbNewlyCctldJson.php): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.php`](DbNewlyDns.php): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.php`](DbExpired.php) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.php`](DbExpiredCleaned.php) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.php`](DbDropped.php) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.php`](DbDroppedJson.php) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.php`](DbDroppedBacklinks.php) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.php`](DbExpired.php): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.php`](DbExpiredCleaned.php): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.php`](DbDropped.php): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.php`](DbDroppedJson.php): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.php`](DbDroppedBacklinks.php): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.php`](DbWhoisDaily.php) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.php`](DbWhoisWeekly.php) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.php`](DbWhoisMonthly.php) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.php`](DbWhoisDaily.php): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.php`](DbWhoisWeekly.php): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.php`](DbWhoisMonthly.php): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.php`](DbDnsDaily.php) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.php`](DbDnsWeekly.php) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.php`](DbDnsMonthly.php) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.php`](DbDnsDaily.php): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.php`](DbDnsWeekly.php): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.php`](DbDnsMonthly.php): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.php`](DbSubdomainsDaily.php) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.php`](DbSubdomainsWeekly.php) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.php`](DbSubdomainsMonthly.php) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.php`](DbSubdomainsDaily.php): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.php`](DbSubdomainsWeekly.php): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.php`](DbSubdomainsMonthly.php): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.php`](DbIpCountryStatus.php) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.php`](DbIpCountry.php) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.php`](DbIpCityStatus.php) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.php`](DbIpCity.php) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.php`](DbIpCountryStatus.php): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.php`](DbIpCountry.php): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.php`](DbIpCityStatus.php): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.php`](DbIpCity.php): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.php`](DbAsnWhois.php) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.php`](DbAsnWhoisStatus.php) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.php`](DbAsnWhois.php): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.php`](DbAsnWhoisStatus.php): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.php`](DbIpWhois.php) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.php`](DbIpWhoisStatus.php) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.php`](DbIpWhois.php): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.php`](DbIpWhoisStatus.php): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.php`](DbIpSecurity.php) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.php`](DbIpSecurityStatus.php) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.php`](DbIpSecurity.php): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.php`](DbIpSecurityStatus.php): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.php`](DownloadThreatFeedPhishing.php) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.php`](DownloadThreatFeedPhishingSample.php) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.php`](DownloadThreatFeedMalware.php) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.php`](DownloadThreatFeedMalwareSample.php) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.php`](DownloadThreatFeedSpam.php) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.php`](DownloadThreatFeedSpamSample.php) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.php`](DownloadThreatFeedPhishing.php): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.php`](DownloadThreatFeedPhishingSample.php): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.php`](DownloadThreatFeedMalware.php): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.php`](DownloadThreatFeedMalwareSample.php): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.php`](DownloadThreatFeedSpam.php): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.php`](DownloadThreatFeedSpamSample.php): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/php/RotateApiKey.php b/examples/php/RotateApiKey.php index 474bc01..7298c93 100644 --- a/examples/php/RotateApiKey.php +++ b/examples/php/RotateApiKey.php @@ -1,11 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\AccountApi(new GuzzleHttp\Client(), $config); -$result = $api->rotateApiKey(); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\AccountApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new AccountApi(new Client(), $config); + +try { + $newKey = $api->rotateApiKey(); + // The old key stops working now: store the new one before making more calls. + echo 'New API key: ', $newKey, PHP_EOL; +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/SslLookup.php b/examples/php/SslLookup.php index d543ffb..b1a1a65 100644 --- a/examples/php/SslLookup.php +++ b/examples/php/SslLookup.php @@ -1,14 +1,29 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\SSLApi(new GuzzleHttp\Client(), $config); -$result = $api->sslLookup("example.com", null, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\SSLApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new SSLApi(new Client(), $config); + +try { + $result = $api->sslLookup('whoisfreaks.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/Subdomains.php b/examples/php/Subdomains.php index 7dda5bf..ffe23da 100644 --- a/examples/php/Subdomains.php +++ b/examples/php/Subdomains.php @@ -1,5 +1,6 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\SubdomainsApi(new GuzzleHttp\Client(), $config); -$result = $api->subdomains("example.com", "2000-01-01", (new DateTime("today"))->format("Y-m-d"), null, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\SubdomainsApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new SubdomainsApi(new Client(), $config); + +try { + $result = $api->subdomains('whoisfreaks.com', null, null, null, 1); // domain, after, before, status, page + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/Typosquatting.php b/examples/php/Typosquatting.php index dd726f8..cb1828b 100644 --- a/examples/php/Typosquatting.php +++ b/examples/php/Typosquatting.php @@ -1,13 +1,28 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\TyposquattingApi(new GuzzleHttp\Client(), $config); -$result = $api->typosquatting(null, null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\TyposquattingApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new TyposquattingApi(new Client(), $config); + +try { + $result = $api->typosquatting('whoisfreaks'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/WhoisHistoricalOrReverse.php b/examples/php/WhoisHistoricalOrReverse.php deleted file mode 100644 index fcf2746..0000000 --- a/examples/php/WhoisHistoricalOrReverse.php +++ /dev/null @@ -1,21 +0,0 @@ -whoisHistoricalOrReverseWithHttpInfo("YOUR_API_KEY", "historical", "example.com", true, null, null, null, null, null, null, null); -echo "status: " . $statusCode . PHP_EOL; -print_r($data); diff --git a/examples/php/WhoisHistory.php b/examples/php/WhoisHistory.php index dcdb6cb..c90f23f 100644 --- a/examples/php/WhoisHistory.php +++ b/examples/php/WhoisHistory.php @@ -1,13 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->whoisHistory("example.com", null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\WHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new WHOISApi(new Client(), $config); + +try { + $result = $api->whoisHistory('whoisfreaks.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/WhoisLive.php b/examples/php/WhoisLive.php index 68f6c05..77f3964 100644 --- a/examples/php/WhoisLive.php +++ b/examples/php/WhoisLive.php @@ -1,12 +1,27 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->whoisLive("example.com", null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\WHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new WHOISApi(new Client(), $config); + +try { + $result = $api->whoisLive('whoisfreaks.com'); + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/php/WhoisReverse.php b/examples/php/WhoisReverse.php index 0cf7805..376ecd9 100644 --- a/examples/php/WhoisReverse.php +++ b/examples/php/WhoisReverse.php @@ -1,13 +1,28 @@ setApiKey("apiKey", "YOUR_API_KEY"); // set once -$api = new WhoisFreaks\Api\WHOISApi(new GuzzleHttp\Client(), $config); -$result = $api->whoisReverse("value", null, null); -print_r($result); +require __DIR__ . '/vendor/autoload.php'; + +use GuzzleHttp\Client; +use WhoisFreaks\Api\WHOISApi; +use WhoisFreaks\ApiException; +use WhoisFreaks\Configuration; + +// Read the API key from the environment and set it once. +$config = Configuration::getDefaultConfiguration() + ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY')); + +$api = new WHOISApi(new Client(), $config); + +try { + $result = $api->whoisReverse('whoisfreaks', 1); // keyword, page + echo $result, PHP_EOL; // models print as JSON +} catch (ApiException $e) { + fwrite(STDERR, 'Request failed: HTTP ' . $e->getCode() . ' ' . $e->getResponseBody() . PHP_EOL); + exit(1); +} diff --git a/examples/python/AccountUsage.py b/examples/python/AccountUsage.py index cef93f6..fe22f50 100644 --- a/examples/python/AccountUsage.py +++ b/examples/python/AccountUsage.py @@ -1,12 +1,19 @@ -"""Runnable example: Account Usage (GET /v1.0/whoisapi/usage).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.account_api import AccountApi - -# Parameters for accountUsage (GET /v1.0/whoisapi/usage): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = AccountApi(ApiClient(config)) - -result = api.account_usage() -print(result) +"""Account Usage: GET https://api.whoisfreaks.com/v1.0/whoisapi/usage + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python AccountUsage.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.AccountApi(client) + + # account_usage takes no parameters. + result = api.account_usage() + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/AsnWhois.py b/examples/python/AsnWhois.py index d4b7396..87b9077 100644 --- a/examples/python/AsnWhois.py +++ b/examples/python/AsnWhois.py @@ -1,13 +1,21 @@ -"""Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.asnwhois_api import ASNWHOISApi - -# Parameters for asnWhois (GET /v2.0/asn-whois): -# - asn (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = ASNWHOISApi(ApiClient(config)) - -result = api.asn_whois(asn="AS15169") -print(result) +"""ASN WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/asn-whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python AsnWhois.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.ASNWHOISApi(client) + + # asn_whois parameters: + # asn (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.asn_whois("as15169") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/BulkDomainAvailabilityV2.py b/examples/python/BulkDomainAvailabilityV2.py index 817af3d..faccf9e 100644 --- a/examples/python/BulkDomainAvailabilityV2.py +++ b/examples/python/BulkDomainAvailabilityV2.py @@ -1,16 +1,23 @@ -"""Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.domain_availability_api import DomainAvailabilityApi -from whoisfreaks.models.bulk_domain_availability_request import BulkDomainAvailabilityRequest +"""Bulk Domain Availability Check: POST https://api.whoisfreaks.com/v2.0/domain/availability -# Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): -# - domain (string, optional): Required for TLD-mode bulk check (base domain). -# - format (string (one of: json, xml), optional) -# - body: BulkDomainAvailabilityRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DomainAvailabilityApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkDomainAvailabilityV2.py +""" +import json +import os -bulk_domain_availability_request = BulkDomainAvailabilityRequest() # populate fields as needed -result = api.bulk_domain_availability_v2(bulk_domain_availability_request=bulk_domain_availability_request) -print(result) +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DomainAvailabilityApi(client) + + # bulk_domain_availability_v2 parameters: + # bulk_domain_availability_request (BulkDomainAvailabilityRequest, required): request body + # domain (str, optional, keyword): Required for TLD-mode bulk check (base domain) + # format (str, optional, keyword): one of json, xml; default "json" + body = whoisfreaks.BulkDomainAvailabilityRequest(domain_names=["whoisfreaks.com", "example.com"]) + result = api.bulk_domain_availability_v2(body) + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/BulkGeolocation.py b/examples/python/BulkGeolocation.py index 569f094..b01bd3f 100644 --- a/examples/python/BulkGeolocation.py +++ b/examples/python/BulkGeolocation.py @@ -1,14 +1,21 @@ -"""Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.geolocation_api import GeolocationApi -from whoisfreaks.models.bulk_geolocation_request import BulkGeolocationRequest - -# Parameters for bulkGeolocation (POST /v1.0/geolocation): -# - body: BulkGeolocationRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = GeolocationApi(ApiClient(config)) - -bulk_geolocation_request = BulkGeolocationRequest() # populate fields as needed -result = api.bulk_geolocation(bulk_geolocation_request=bulk_geolocation_request) -print(result) +"""Bulk IP Geolocation: POST https://api.whoisfreaks.com/v1.0/geolocation + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkGeolocation.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.GeolocationApi(client) + + # bulk_geolocation parameters: + # bulk_geolocation_request (BulkGeolocationRequest, required): request body + body = whoisfreaks.BulkGeolocationRequest(ips=["8.8.8.8", "1.1.1.1"]) + results = api.bulk_geolocation(body) + print(json.dumps([item.to_dict() for item in results], indent=2)) diff --git a/examples/python/BulkIpReputation.py b/examples/python/BulkIpReputation.py index 4c47352..a820ffd 100644 --- a/examples/python/BulkIpReputation.py +++ b/examples/python/BulkIpReputation.py @@ -1,14 +1,21 @@ -"""Runnable example: Bulk IP Reputation (POST /v1.0/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ip_reputation_api import IPReputationApi -from whoisfreaks.models.bulk_ip_reputation_request import BulkIpReputationRequest - -# Parameters for bulkIpReputation (POST /v1.0/security): -# - body: BulkIpReputationRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = IPReputationApi(ApiClient(config)) - -bulk_ip_reputation_request = BulkIpReputationRequest() # populate fields as needed -result = api.bulk_ip_reputation(bulk_ip_reputation_request=bulk_ip_reputation_request) -print(result) +"""Bulk IP Reputation: POST https://api.whoisfreaks.com/v1.0/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkIpReputation.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.IPReputationApi(client) + + # bulk_ip_reputation parameters: + # bulk_geolocation_request (BulkGeolocationRequest, required): request body + body = whoisfreaks.BulkGeolocationRequest(ips=["8.8.8.8", "1.1.1.1"]) + results = api.bulk_ip_reputation(body) + print(json.dumps([item.to_dict() for item in results], indent=2)) diff --git a/examples/python/BulkWhois.py b/examples/python/BulkWhois.py index 992798a..b6db440 100644 --- a/examples/python/BulkWhois.py +++ b/examples/python/BulkWhois.py @@ -1,15 +1,22 @@ -"""Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi -from whoisfreaks.models.bulk_whois_request import BulkWhoisRequest - -# Parameters for bulkWhois (POST /v2.0/bulkwhois/live): -# - format (string (one of: json, xml), optional) -# - body: BulkWhoisRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) - -bulk_whois_request = BulkWhoisRequest() # populate fields as needed -result = api.bulk_whois(bulk_whois_request=bulk_whois_request) -print(result) +"""Bulk WHOIS Lookup: POST https://api.whoisfreaks.com/v2.0/bulkwhois/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python BulkWhois.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + + # bulk_whois parameters: + # bulk_whois_request (BulkWhoisRequest, required): request body + # format (str, optional, keyword): one of json, xml; default "json" + body = whoisfreaks.BulkWhoisRequest(domain_names=["whoisfreaks.com", "jfreaks.com"]) + result = api.bulk_whois(body) + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DatabaseFileStatus.py b/examples/python/DatabaseFileStatus.py index 04a4446..87511ac 100644 --- a/examples/python/DatabaseFileStatus.py +++ b/examples/python/DatabaseFileStatus.py @@ -1,12 +1,18 @@ -"""Runnable example: Database File Status (Public) (GET /v3.4/status).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.account_api import AccountApi - -# Parameters for databaseFileStatus (GET /v3.4/status): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = AccountApi(ApiClient(config)) - -result = api.database_file_status() -print(result) +"""Database File Status (Public): GET https://files.whoisfreaks.com/v3.4/status + +Run it (public endpoint, no API key needed): + python DatabaseFileStatus.py +""" +import json + +import whoisfreaks + +config = whoisfreaks.Configuration() +# Public endpoint: no API key needed. + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.AccountApi(client) + + # database_file_status takes no parameters. + result = api.database_file_status() + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DbAsnWhois.py b/examples/python/DbAsnWhois.py index 8ae5ba6..2c5e44d 100644 --- a/examples/python/DbAsnWhois.py +++ b/examples/python/DbAsnWhois.py @@ -1,16 +1,23 @@ -"""Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_asnwhois_api import DatabasesASNWHOISApi +"""ASN WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/asn/whois -# Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesASNWHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbAsnWhois.py +""" +import os +from datetime import date -data = api.db_asn_whois(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbAsnWhois.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbAsnWhois.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesASNWHOISApi(client) + + # db_asn_whois parameters: + # var_date (datetime.date, required) + data = api.db_asn_whois(date(2026, 10, 1)) # the file's raw bytes + path = "DbAsnWhois.json.gz" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbAsnWhoisStatus.py b/examples/python/DbAsnWhoisStatus.py index a9a9f8b..64b0652 100644 --- a/examples/python/DbAsnWhoisStatus.py +++ b/examples/python/DbAsnWhoisStatus.py @@ -1,12 +1,19 @@ -"""Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_asnwhois_api import DatabasesASNWHOISApi - -# Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesASNWHOISApi(ApiClient(config)) - -result = api.db_asn_whois_status() -print(result) +"""ASN WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/asn/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbAsnWhoisStatus.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesASNWHOISApi(client) + + # db_asn_whois_status takes no parameters. + result = api.db_asn_whois_status() + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DbDnsDaily.py b/examples/python/DbDnsDaily.py index 5cf18ed..7a0ba70 100644 --- a/examples/python/DbDnsDaily.py +++ b/examples/python/DbDnsDaily.py @@ -1,16 +1,23 @@ -"""Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_dns_api import DatabasesDNSApi +"""DNS Database Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/dns -# Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesDNSApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDnsDaily.py +""" +import os +from datetime import date -data = api.db_dns_daily(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDnsDaily.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDnsDaily.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesDNSApi(client) + + # db_dns_daily parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dns_daily(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDnsDaily.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbDnsMonthly.py b/examples/python/DbDnsMonthly.py index c8299cb..86a45e2 100644 --- a/examples/python/DbDnsMonthly.py +++ b/examples/python/DbDnsMonthly.py @@ -1,16 +1,23 @@ -"""Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_dns_api import DatabasesDNSApi +"""DNS Database Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/dns -# Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesDNSApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDnsMonthly.py +""" +import os +from datetime import date -data = api.db_dns_monthly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDnsMonthly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDnsMonthly.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesDNSApi(client) + + # db_dns_monthly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dns_monthly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDnsMonthly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbDnsWeekly.py b/examples/python/DbDnsWeekly.py index 58edde4..c9955d5 100644 --- a/examples/python/DbDnsWeekly.py +++ b/examples/python/DbDnsWeekly.py @@ -1,16 +1,23 @@ -"""Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_dns_api import DatabasesDNSApi +"""DNS Database Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/dns -# Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesDNSApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDnsWeekly.py +""" +import os +from datetime import date -data = api.db_dns_weekly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDnsWeekly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDnsWeekly.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesDNSApi(client) + + # db_dns_weekly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dns_weekly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDnsWeekly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbDropped.py b/examples/python/DbDropped.py index a1d7a18..cb3c1d1 100644 --- a/examples/python/DbDropped.py +++ b/examples/python/DbDropped.py @@ -1,17 +1,24 @@ -"""Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Dropped Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/dropped -# Parameters for dbDropped (GET /v3.1/download/domainer/dropped): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDropped.py +""" +import os +from datetime import date -data = api.db_dropped(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDropped.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDropped.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_dropped parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dropped(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDropped.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbDroppedBacklinks.py b/examples/python/DbDroppedBacklinks.py index afb521f..c073616 100644 --- a/examples/python/DbDroppedBacklinks.py +++ b/examples/python/DbDroppedBacklinks.py @@ -1,17 +1,24 @@ -"""Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Dropped With Backlinks: GET https://files.whoisfreaks.com/v3.3/download/domainer/dropped/backlinks -# Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): -# - whois (boolean, optional) -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDroppedBacklinks.py +""" +import os +from datetime import date -data = api.db_dropped_backlinks(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbDroppedBacklinks.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbDroppedBacklinks.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_dropped_backlinks parameters: + # whois (bool, optional, keyword) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_dropped_backlinks(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbDroppedBacklinks.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbDroppedJson.py b/examples/python/DbDroppedJson.py index 24345b6..6f5f6c2 100644 --- a/examples/python/DbDroppedJson.py +++ b/examples/python/DbDroppedJson.py @@ -1,14 +1,22 @@ -"""Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi - -# Parameters for dbDroppedJson (GET /v3.1/domains/dropped): -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) - -result = api.db_dropped_json(var_date=str(date.today() - timedelta(days=1))) -print(result) +"""Dropped Domains (JSON): GET https://files.whoisfreaks.com/v3.1/domains/dropped + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbDroppedJson.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_dropped_json parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + domains = api.db_dropped_json(var_date=date(2026, 10, 1)) + print(f"{len(domains)} domains") + print("\n".join(domains[:10])) diff --git a/examples/python/DbExpired.py b/examples/python/DbExpired.py index d4666f0..b0c7c16 100644 --- a/examples/python/DbExpired.py +++ b/examples/python/DbExpired.py @@ -1,17 +1,24 @@ -"""Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Expiring Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired -# Parameters for dbExpired (GET /v3.1/download/domainer/expired): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbExpired.py +""" +import os +from datetime import date -data = api.db_expired(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbExpired.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbExpired.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_expired parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_expired(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbExpired.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbExpiredCleaned.py b/examples/python/DbExpiredCleaned.py index c6c22f3..7cbf0c7 100644 --- a/examples/python/DbExpiredCleaned.py +++ b/examples/python/DbExpiredCleaned.py @@ -1,16 +1,23 @@ -"""Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_expiring_dropped_api import DatabasesExpiringDroppedApi +"""Expiring Cleaned WHOIS: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired/cleaned -# Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesExpiringDroppedApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbExpiredCleaned.py +""" +import os +from datetime import date -data = api.db_expired_cleaned(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbExpiredCleaned.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbExpiredCleaned.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesExpiringDroppedApi(client) + + # db_expired_cleaned parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_expired_cleaned(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbExpiredCleaned.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbIpCity.py b/examples/python/DbIpCity.py index 91b5c93..2dbd007 100644 --- a/examples/python/DbIpCity.py +++ b/examples/python/DbIpCity.py @@ -1,16 +1,23 @@ -"""Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi +"""IP to City Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/city -# Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCity.py +""" +import os +from datetime import date -data = api.db_ip_city(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpCity.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpCity.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_city parameters: + # var_date (datetime.date, required) + data = api.db_ip_city(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpCity.zip" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbIpCityStatus.py b/examples/python/DbIpCityStatus.py index 2be2c3d..b1f892a 100644 --- a/examples/python/DbIpCityStatus.py +++ b/examples/python/DbIpCityStatus.py @@ -1,12 +1,19 @@ -"""Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi - -# Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) - -result = api.db_ip_city_status() -print(result) +"""IP to City Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/city + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCityStatus.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_city_status takes no parameters. + result = api.db_ip_city_status() + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DbIpCountry.py b/examples/python/DbIpCountry.py index e8eba46..a223a55 100644 --- a/examples/python/DbIpCountry.py +++ b/examples/python/DbIpCountry.py @@ -1,16 +1,23 @@ -"""Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi +"""IP to Country Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/country -# Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCountry.py +""" +import os +from datetime import date -data = api.db_ip_country(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpCountry.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpCountry.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_country parameters: + # var_date (datetime.date, required) + data = api.db_ip_country(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpCountry.zip" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbIpCountryStatus.py b/examples/python/DbIpCountryStatus.py index ee7586d..5e0de6d 100644 --- a/examples/python/DbIpCountryStatus.py +++ b/examples/python/DbIpCountryStatus.py @@ -1,12 +1,19 @@ -"""Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_geolocation_api import DatabasesIPGeolocationApi - -# Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPGeolocationApi(ApiClient(config)) - -result = api.db_ip_country_status() -print(result) +"""IP to Country Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/country + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpCountryStatus.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPGeolocationApi(client) + + # db_ip_country_status takes no parameters. + result = api.db_ip_country_status() + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DbIpSecurity.py b/examples/python/DbIpSecurity.py index 115c5d4..402bcc3 100644 --- a/examples/python/DbIpSecurity.py +++ b/examples/python/DbIpSecurity.py @@ -1,16 +1,23 @@ -"""Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_security_api import DatabasesIPSecurityApi +"""IP Security Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/security -# Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPSecurityApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpSecurity.py +""" +import os +from datetime import date -data = api.db_ip_security(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpSecurity.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpSecurity.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPSecurityApi(client) + + # db_ip_security parameters: + # var_date (datetime.date, required) + data = api.db_ip_security(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpSecurity.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbIpSecurityStatus.py b/examples/python/DbIpSecurityStatus.py index e369f4c..28a63d5 100644 --- a/examples/python/DbIpSecurityStatus.py +++ b/examples/python/DbIpSecurityStatus.py @@ -1,12 +1,19 @@ -"""Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ip_security_api import DatabasesIPSecurityApi - -# Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPSecurityApi(ApiClient(config)) - -result = api.db_ip_security_status() -print(result) +"""IP Security Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpSecurityStatus.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPSecurityApi(client) + + # db_ip_security_status takes no parameters. + result = api.db_ip_security_status() + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DbIpWhois.py b/examples/python/DbIpWhois.py index 851e0d8..e502bb4 100644 --- a/examples/python/DbIpWhois.py +++ b/examples/python/DbIpWhois.py @@ -1,16 +1,23 @@ -"""Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ipwhois_api import DatabasesIPWHOISApi +"""IP WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/whois -# Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): -# - date (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPWHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpWhois.py +""" +import os +from datetime import date -data = api.db_ip_whois(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbIpWhois.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbIpWhois.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPWHOISApi(client) + + # db_ip_whois parameters: + # var_date (datetime.date, required) + data = api.db_ip_whois(date(2026, 10, 1)) # the file's raw bytes + path = "DbIpWhois.json.gz" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbIpWhoisStatus.py b/examples/python/DbIpWhoisStatus.py index a3b7bb3..c40e6ea 100644 --- a/examples/python/DbIpWhoisStatus.py +++ b/examples/python/DbIpWhoisStatus.py @@ -1,12 +1,19 @@ -"""Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_ipwhois_api import DatabasesIPWHOISApi - -# Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesIPWHOISApi(ApiClient(config)) - -result = api.db_ip_whois_status() -print(result) +"""IP WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbIpWhoisStatus.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesIPWHOISApi(client) + + # db_ip_whois_status takes no parameters. + result = api.db_ip_whois_status() + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DbNewlyCctld.py b/examples/python/DbNewlyCctld.py index dc74214..668a5ea 100644 --- a/examples/python/DbNewlyCctld.py +++ b/examples/python/DbNewlyCctld.py @@ -1,18 +1,25 @@ -"""Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered ccTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld -# Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyCctld.py +""" +import os +from datetime import date -data = api.db_newly_cctld(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyCctld.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyCctld.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_cctld parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + data = api.db_newly_cctld(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyCctld.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbNewlyCctldCleaned.py b/examples/python/DbNewlyCctldCleaned.py index e93a6ff..da4d12a 100644 --- a/examples/python/DbNewlyCctldCleaned.py +++ b/examples/python/DbNewlyCctldCleaned.py @@ -1,16 +1,23 @@ -"""Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered ccTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld/cleaned -# Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyCctldCleaned.py +""" +import os +from datetime import date -data = api.db_newly_cctld_cleaned(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyCctldCleaned.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyCctldCleaned.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_cctld_cleaned parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_newly_cctld_cleaned(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyCctldCleaned.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbNewlyCctldJson.py b/examples/python/DbNewlyCctldJson.py index 52fcf18..ab8ca4f 100644 --- a/examples/python/DbNewlyCctldJson.py +++ b/examples/python/DbNewlyCctldJson.py @@ -1,14 +1,22 @@ -"""Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi - -# Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) - -result = api.db_newly_cctld_json(var_date=str(date.today() - timedelta(days=1))) -print(result) +"""Newly Registered ccTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/cctld + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyCctldJson.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_cctld_json parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + domains = api.db_newly_cctld_json(var_date=date(2026, 10, 1)) + print(f"{len(domains)} domains") + print("\n".join(domains[:10])) diff --git a/examples/python/DbNewlyDns.py b/examples/python/DbNewlyDns.py index 134bb20..94ce016 100644 --- a/examples/python/DbNewlyDns.py +++ b/examples/python/DbNewlyDns.py @@ -1,16 +1,23 @@ -"""Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered With DNS: GET https://files.whoisfreaks.com/v3.1/download/domainer/newly/dns -# Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyDns.py +""" +import os +from datetime import date -data = api.db_newly_dns(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyDns.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyDns.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_dns parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_newly_dns(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyDns.json" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbNewlyGtld.py b/examples/python/DbNewlyGtld.py index 2874707..ccfc874 100644 --- a/examples/python/DbNewlyGtld.py +++ b/examples/python/DbNewlyGtld.py @@ -1,18 +1,25 @@ -"""Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered gTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld -# Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): -# - whois (boolean, required) -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyGtld.py +""" +import os +from datetime import date -data = api.db_newly_gtld(whois=False, var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyGtld.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyGtld.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_gtld parameters: + # whois (bool, required) + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + data = api.db_newly_gtld(True, var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyGtld.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbNewlyGtldCleaned.py b/examples/python/DbNewlyGtldCleaned.py index 4cc4134..188b95f 100644 --- a/examples/python/DbNewlyGtldCleaned.py +++ b/examples/python/DbNewlyGtldCleaned.py @@ -1,16 +1,23 @@ -"""Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi +"""Newly Registered gTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld/cleaned -# Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyGtldCleaned.py +""" +import os +from datetime import date -data = api.db_newly_gtld_cleaned(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbNewlyGtldCleaned.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbNewlyGtldCleaned.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_gtld_cleaned parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_newly_gtld_cleaned(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbNewlyGtldCleaned.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbNewlyGtldJson.py b/examples/python/DbNewlyGtldJson.py index 5462081..c7d7fe8 100644 --- a/examples/python/DbNewlyGtldJson.py +++ b/examples/python/DbNewlyGtldJson.py @@ -1,14 +1,22 @@ -"""Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_newly_registered_api import DatabasesNewlyRegisteredApi - -# Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): -# - date (string, optional): yyyy-MM-dd; omit for latest -# - tlds (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesNewlyRegisteredApi(ApiClient(config)) - -result = api.db_newly_gtld_json(var_date=str(date.today() - timedelta(days=1))) -print(result) +"""Newly Registered gTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/gtld + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbNewlyGtldJson.py +""" +import os +from datetime import date + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesNewlyRegisteredApi(client) + + # db_newly_gtld_json parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + # tlds (str, optional, keyword) + domains = api.db_newly_gtld_json(var_date=date(2026, 10, 1)) + print(f"{len(domains)} domains") + print("\n".join(domains[:10])) diff --git a/examples/python/DbSubdomainsDaily.py b/examples/python/DbSubdomainsDaily.py index 39ab9b7..4ba387a 100644 --- a/examples/python/DbSubdomainsDaily.py +++ b/examples/python/DbSubdomainsDaily.py @@ -1,16 +1,23 @@ -"""Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_subdomains_api import DatabasesSubdomainsApi +"""Subdomains Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/subdomains -# Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesSubdomainsApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbSubdomainsDaily.py +""" +import os +from datetime import date -data = api.db_subdomains_daily(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbSubdomainsDaily.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbSubdomainsDaily.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesSubdomainsApi(client) + + # db_subdomains_daily parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_subdomains_daily(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbSubdomainsDaily.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbSubdomainsMonthly.py b/examples/python/DbSubdomainsMonthly.py index 1fe096a..246d9a2 100644 --- a/examples/python/DbSubdomainsMonthly.py +++ b/examples/python/DbSubdomainsMonthly.py @@ -1,16 +1,23 @@ -"""Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_subdomains_api import DatabasesSubdomainsApi +"""Subdomains Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/subdomains -# Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesSubdomainsApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbSubdomainsMonthly.py +""" +import os +from datetime import date -data = api.db_subdomains_monthly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbSubdomainsMonthly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbSubdomainsMonthly.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesSubdomainsApi(client) + + # db_subdomains_monthly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_subdomains_monthly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbSubdomainsMonthly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbSubdomainsWeekly.py b/examples/python/DbSubdomainsWeekly.py index d83d130..1ccbf4d 100644 --- a/examples/python/DbSubdomainsWeekly.py +++ b/examples/python/DbSubdomainsWeekly.py @@ -1,16 +1,23 @@ -"""Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_subdomains_api import DatabasesSubdomainsApi +"""Subdomains Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/subdomains -# Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesSubdomainsApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbSubdomainsWeekly.py +""" +import os +from datetime import date -data = api.db_subdomains_weekly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbSubdomainsWeekly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbSubdomainsWeekly.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesSubdomainsApi(client) + + # db_subdomains_weekly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_subdomains_weekly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbSubdomainsWeekly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbWhoisDaily.py b/examples/python/DbWhoisDaily.py index ff25449..f10164a 100644 --- a/examples/python/DbWhoisDaily.py +++ b/examples/python/DbWhoisDaily.py @@ -1,16 +1,23 @@ -"""Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_whois_api import DatabasesWHOISApi +"""WHOIS Database Daily: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/daily/domains/whois -# Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesWHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbWhoisDaily.py +""" +import os +from datetime import date -data = api.db_whois_daily(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbWhoisDaily.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbWhoisDaily.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesWHOISApi(client) + + # db_whois_daily parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_whois_daily(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbWhoisDaily.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbWhoisMonthly.py b/examples/python/DbWhoisMonthly.py index bbfc995..f421338 100644 --- a/examples/python/DbWhoisMonthly.py +++ b/examples/python/DbWhoisMonthly.py @@ -1,16 +1,23 @@ -"""Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_whois_api import DatabasesWHOISApi +"""WHOIS Database Monthly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/monthly/domains/whois -# Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesWHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbWhoisMonthly.py +""" +import os +from datetime import date -data = api.db_whois_monthly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbWhoisMonthly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbWhoisMonthly.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesWHOISApi(client) + + # db_whois_monthly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_whois_monthly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbWhoisMonthly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DbWhoisWeekly.py b/examples/python/DbWhoisWeekly.py index 72bfd17..a3d428f 100644 --- a/examples/python/DbWhoisWeekly.py +++ b/examples/python/DbWhoisWeekly.py @@ -1,16 +1,23 @@ -"""Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_whois_api import DatabasesWHOISApi +"""WHOIS Database Weekly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/weekly/domains/whois -# Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): -# - date (string, optional): yyyy-MM-dd; omit for latest -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesWHOISApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DbWhoisWeekly.py +""" +import os +from datetime import date -data = api.db_whois_weekly(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("dbWhoisWeekly.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to dbWhoisWeekly.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesWHOISApi(client) + + # db_whois_weekly parameters: + # var_date (datetime.date, optional, keyword): yyyy-MM-dd; omit for latest + data = api.db_whois_weekly(var_date=date(2026, 10, 1)) # the file's raw bytes + path = "DbWhoisWeekly.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DnsBulk.py b/examples/python/DnsBulk.py index bd51d58..5d36c42 100644 --- a/examples/python/DnsBulk.py +++ b/examples/python/DnsBulk.py @@ -1,16 +1,23 @@ -"""Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi -from whoisfreaks.models.dns_bulk_request import DnsBulkRequest +"""Bulk DNS Lookup: POST https://api.whoisfreaks.com/v2.0/dns/bulk/live -# Parameters for dnsBulk (POST /v2.0/dns/bulk/live): -# - type (string, required) -# - format (string (one of: json, xml), optional) -# - body: DnsBulkRequest (required) -- request body object -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsBulk.py +""" +import json +import os -dns_bulk_request = DnsBulkRequest() # populate fields as needed -result = api.dns_bulk(var_type="value", dns_bulk_request=dns_bulk_request) -print(result) +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + + # dns_bulk parameters: + # type (str, required): default "all" + # dns_bulk_request (DnsBulkRequest, required): request body + # format (str, optional, keyword): one of json, xml; default "json" + body = whoisfreaks.DnsBulkRequest(domain_names=["whoisfreaks.com", "example.com"]) + result = api.dns_bulk("A,MX,TXT", body) + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DnsHistorical.py b/examples/python/DnsHistorical.py index 8534d68..493f89f 100644 --- a/examples/python/DnsHistorical.py +++ b/examples/python/DnsHistorical.py @@ -1,15 +1,23 @@ -"""Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi - -# Parameters for dnsHistorical (GET /v2.0/dns/historical): -# - domainName (string, required) -# - type (string, required) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) - -result = api.dns_historical(domain_name="example.com", var_type="value") -print(result) +"""Historical DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/historical + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsHistorical.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + + # dns_historical parameters: + # domain_name (str, required) + # type (str, required): default "all" + # page (int, optional, keyword): default 1 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.dns_historical("whoisfreaks.com", "A,MX,TXT", page=1) + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DnsLive.py b/examples/python/DnsLive.py index 063d77e..30b6780 100644 --- a/examples/python/DnsLive.py +++ b/examples/python/DnsLive.py @@ -1,15 +1,23 @@ -"""Runnable example: Live DNS Lookup (GET /v2.0/dns/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi - -# Parameters for dnsLive (GET /v2.0/dns/live): -# - domainName (string, required) -# - ipAddress (string, required): Use for PTR lookups -# - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) - -result = api.dns_live(domain_name="example.com", ip_address="8.8.8.8", var_type="value") -print(result) +"""Live DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsLive.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + + # dns_live parameters: + # type (str, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME; default "all" + # domain_name (str, optional, keyword) + # ip_address (str, optional, keyword): Use for PTR lookups + # format (str, optional, keyword): one of json, xml; default "json" + result = api.dns_live("A,MX,TXT", domain_name="whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DnsReverse.py b/examples/python/DnsReverse.py index 697fff7..d443464 100644 --- a/examples/python/DnsReverse.py +++ b/examples/python/DnsReverse.py @@ -1,16 +1,24 @@ -"""Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.dns_api import DNSApi +"""Reverse DNS Lookup: GET https://api.whoisfreaks.com/v2.1/dns/reverse -# Parameters for dnsReverse (GET /v2.1/dns/reverse): -# - value (string, required): IP, CIDR, or record value -# - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) -# - exact (boolean, optional) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DNSApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DnsReverse.py +""" +import json +import os -result = api.dns_reverse(value="value", var_type="a", exact=True) -print(result) +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DNSApi(client) + + # dns_reverse parameters: + # value (str, required): IP, CIDR, or record value + # type (str, required): one of a, mx, cname, ns, aaaa, txt, soa + # exact (bool, optional, keyword): default True + # page (int, optional, keyword): default 1 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.dns_reverse("8.8.8.8", "a", page=1) + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DomainAvailabilityV2.py b/examples/python/DomainAvailabilityV2.py index 11da82a..819a388 100644 --- a/examples/python/DomainAvailabilityV2.py +++ b/examples/python/DomainAvailabilityV2.py @@ -1,15 +1,23 @@ -"""Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.domain_availability_api import DomainAvailabilityApi - -# Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): -# - domain (string, required): The domain name to check -# - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. -# - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DomainAvailabilityApi(ApiClient(config)) - -result = api.domain_availability_v2(domain="example.com") -print(result) +"""Domain Availability Check with Suggestions: GET https://api.whoisfreaks.com/v2.0/domain/availability + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DomainAvailabilityV2.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DomainAvailabilityApi(client) + + # domain_availability_v2 parameters: + # domain (str, required): The domain name to check + # sug (bool, optional, keyword): Whether to return TLD suggestions alongside the queried domain; default False + # count (int, optional, keyword): Number of TLD suggestions to return when sug=true. Maximum is 100; default 5 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.domain_availability_v2("google.com", sug=True, count=5) + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DomainReputation.py b/examples/python/DomainReputation.py index 845b3fc..2278cfd 100644 --- a/examples/python/DomainReputation.py +++ b/examples/python/DomainReputation.py @@ -1,13 +1,21 @@ -"""Runnable example: Domain Reputation Lookup (GET /v1/domain/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.domain_reputation_api import DomainReputationApi - -# Parameters for domainReputation (GET /v1/domain/security): -# - domainName (string, required): The domain name to assess -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DomainReputationApi(ApiClient(config)) - -result = api.domain_reputation(domain_name="example.com") -print(result) +"""Domain Reputation Lookup: GET https://api.whoisfreaks.com/v1/domain/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DomainReputation.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DomainReputationApi(client) + + # domain_reputation parameters: + # domain_name (str, required): The domain name to assess + # format (str, optional, keyword): one of json, xml; default "json" + result = api.domain_reputation("amazon.com") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/DownloadThreatFeedMalware.py b/examples/python/DownloadThreatFeedMalware.py index c7e1e04..6895490 100644 --- a/examples/python/DownloadThreatFeedMalware.py +++ b/examples/python/DownloadThreatFeedMalware.py @@ -1,16 +1,22 @@ -"""Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi +"""Download the daily malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware -# Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedMalware.py +""" +import os -data = api.download_threat_feed_malware(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("downloadThreatFeedMalware.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedMalware.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_malware parameters: + # var_date (str, optional, keyword): Feed date (yyyy-MM-dd); omit for the full dump of the feed + data = api.download_threat_feed_malware(var_date="2026-10-01") # the file's raw bytes + path = "DownloadThreatFeedMalware.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DownloadThreatFeedMalwareSample.py b/examples/python/DownloadThreatFeedMalwareSample.py index 220433f..f15bc6e 100644 --- a/examples/python/DownloadThreatFeedMalwareSample.py +++ b/examples/python/DownloadThreatFeedMalwareSample.py @@ -1,15 +1,21 @@ -"""Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_malware_sample() # bytes -with open("downloadThreatFeedMalwareSample.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedMalwareSample.gz") +"""Download a sample of the malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware/sample + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedMalwareSample.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_malware_sample takes no parameters. + data = api.download_threat_feed_malware_sample() # the file's raw bytes + path = "DownloadThreatFeedMalwareSample.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DownloadThreatFeedPhishing.py b/examples/python/DownloadThreatFeedPhishing.py index 2aa092b..339c778 100644 --- a/examples/python/DownloadThreatFeedPhishing.py +++ b/examples/python/DownloadThreatFeedPhishing.py @@ -1,16 +1,22 @@ -"""Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi +"""Download the daily phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing -# Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedPhishing.py +""" +import os -data = api.download_threat_feed_phishing(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("downloadThreatFeedPhishing.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedPhishing.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_phishing parameters: + # var_date (str, optional, keyword): Feed date (yyyy-MM-dd); omit for the full dump of the feed + data = api.download_threat_feed_phishing(var_date="2026-10-01") # the file's raw bytes + path = "DownloadThreatFeedPhishing.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DownloadThreatFeedPhishingSample.py b/examples/python/DownloadThreatFeedPhishingSample.py index 3fea89a..80f0ced 100644 --- a/examples/python/DownloadThreatFeedPhishingSample.py +++ b/examples/python/DownloadThreatFeedPhishingSample.py @@ -1,15 +1,21 @@ -"""Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_phishing_sample() # bytes -with open("downloadThreatFeedPhishingSample.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedPhishingSample.gz") +"""Download a sample of the phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing/sample + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedPhishingSample.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_phishing_sample takes no parameters. + data = api.download_threat_feed_phishing_sample() # the file's raw bytes + path = "DownloadThreatFeedPhishingSample.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DownloadThreatFeedSpam.py b/examples/python/DownloadThreatFeedSpam.py index d62f1a3..ef0e5d5 100644 --- a/examples/python/DownloadThreatFeedSpam.py +++ b/examples/python/DownloadThreatFeedSpam.py @@ -1,16 +1,22 @@ -"""Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi +"""Download the daily spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam -# Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedSpam.py +""" +import os -data = api.download_threat_feed_spam(var_date=str(date.today() - timedelta(days=1))) # bytes -with open("downloadThreatFeedSpam.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedSpam.gz") +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_spam parameters: + # var_date (str, optional, keyword): Feed date (yyyy-MM-dd); omit for the full dump of the feed + data = api.download_threat_feed_spam(var_date="2026-10-01") # the file's raw bytes + path = "DownloadThreatFeedSpam.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/DownloadThreatFeedSpamSample.py b/examples/python/DownloadThreatFeedSpamSample.py index e56b9ff..3eea154 100644 --- a/examples/python/DownloadThreatFeedSpamSample.py +++ b/examples/python/DownloadThreatFeedSpamSample.py @@ -1,15 +1,21 @@ -"""Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample). -Returns raw bytes (a compressed/binary file) -- write to disk, do not print.""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.databases_threat_feed_api import DatabasesThreatFeedApi - -# Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = DatabasesThreatFeedApi(ApiClient(config)) - -data = api.download_threat_feed_spam_sample() # bytes -with open("downloadThreatFeedSpamSample.gz", "wb") as f: - f.write(data) -print(f"saved {len(data)} bytes to downloadThreatFeedSpamSample.gz") +"""Download a sample of the spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam/sample + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python DownloadThreatFeedSpamSample.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.DatabasesThreatFeedApi(client) + + # download_threat_feed_spam_sample takes no parameters. + data = api.download_threat_feed_spam_sample() # the file's raw bytes + path = "DownloadThreatFeedSpamSample.csv" + with open(path, "wb") as f: + f.write(data) + print(f"Saved {len(data)} bytes to {os.path.abspath(path)}") diff --git a/examples/python/Geolocation.py b/examples/python/Geolocation.py index 8b5e8fc..ec4bc76 100644 --- a/examples/python/Geolocation.py +++ b/examples/python/Geolocation.py @@ -1,12 +1,20 @@ -"""Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.geolocation_api import GeolocationApi - -# Parameters for geolocation (GET /v1.0/geolocation): -# - ip (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = GeolocationApi(ApiClient(config)) - -result = api.geolocation(ip="8.8.8.8") -print(result) +"""IP Geolocation Lookup: GET https://api.whoisfreaks.com/v1.0/geolocation + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python Geolocation.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.GeolocationApi(client) + + # geolocation parameters: + # ip (str, required) + result = api.geolocation("8.8.8.8") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/IpReputation.py b/examples/python/IpReputation.py index 3db6ea0..c5d47ec 100644 --- a/examples/python/IpReputation.py +++ b/examples/python/IpReputation.py @@ -1,12 +1,20 @@ -"""Runnable example: IP Reputation Lookup (GET /v1.0/security).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ip_reputation_api import IPReputationApi - -# Parameters for ipReputation (GET /v1.0/security): -# - ip (string, required) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = IPReputationApi(ApiClient(config)) - -result = api.ip_reputation(ip="8.8.8.8") -print(result) +"""IP Reputation Lookup: GET https://api.whoisfreaks.com/v1.0/security + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python IpReputation.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.IPReputationApi(client) + + # ip_reputation parameters: + # ip (str, required) + result = api.ip_reputation("8.8.8.8") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/IpWhois.py b/examples/python/IpWhois.py index f8edf8c..44dde04 100644 --- a/examples/python/IpWhois.py +++ b/examples/python/IpWhois.py @@ -1,13 +1,21 @@ -"""Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ipwhois_api import IPWHOISApi - -# Parameters for ipWhois (GET /v1.0/ip-whois): -# - ip (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = IPWHOISApi(ApiClient(config)) - -result = api.ip_whois(ip="8.8.8.8") -print(result) +"""IP WHOIS Lookup: GET https://api.whoisfreaks.com/v1.0/ip-whois + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python IpWhois.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.IPWHOISApi(client) + + # ip_whois parameters: + # ip (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.ip_whois("8.8.8.8") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/README.md b/examples/python/README.md index 2fcb520..f546050 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -1,107 +1,107 @@ -# Python — Runnable Examples +# Python Runnable Examples -Install: see the [Python guide](../../docs/languages/python.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [Python guide](../../docs/languages/python.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.py`](WhoisLive.py) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.py`](BulkWhois.py) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.py`](WhoisHistory.py) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.py`](WhoisReverse.py) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.py`](WhoisLive.py): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.py`](BulkWhois.py): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.py`](WhoisHistory.py): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.py`](WhoisReverse.py): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.py`](DnsLive.py) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.py`](DnsHistorical.py) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.py`](DnsReverse.py) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.py`](DnsBulk.py) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.py`](DnsLive.py): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.py`](DnsHistorical.py): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.py`](DnsReverse.py): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.py`](DnsBulk.py): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.py`](DomainAvailabilityV2.py) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.py`](BulkDomainAvailabilityV2.py) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.py`](DomainAvailabilityV2.py): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.py`](BulkDomainAvailabilityV2.py): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.py`](Typosquatting.py) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.py`](Typosquatting.py): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.py`](SslLookup.py) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.py`](SslLookup.py): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.py`](Geolocation.py) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.py`](BulkGeolocation.py) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.py`](Geolocation.py): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.py`](BulkGeolocation.py): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.py`](Subdomains.py) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.py`](Subdomains.py): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.py`](IpReputation.py) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.py`](BulkIpReputation.py) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.py`](IpReputation.py): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.py`](BulkIpReputation.py): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.py`](DomainReputation.py) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.py`](DomainReputation.py): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.py`](AsnWhois.py) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.py`](AsnWhois.py): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.py`](IpWhois.py) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.py`](IpWhois.py): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.py`](RotateApiKey.py) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.py`](AccountUsage.py) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.py`](DatabaseFileStatus.py) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.py`](RotateApiKey.py): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.py`](AccountUsage.py): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.py`](DatabaseFileStatus.py): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.py`](DbNewlyGtld.py) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.py`](DbNewlyCctld.py) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.py`](DbNewlyGtldCleaned.py) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.py`](DbNewlyCctldCleaned.py) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.py`](DbNewlyGtldJson.py) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.py`](DbNewlyCctldJson.py) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.py`](DbNewlyDns.py) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.py`](DbNewlyGtld.py): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.py`](DbNewlyCctld.py): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.py`](DbNewlyGtldCleaned.py): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.py`](DbNewlyCctldCleaned.py): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.py`](DbNewlyGtldJson.py): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.py`](DbNewlyCctldJson.py): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.py`](DbNewlyDns.py): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.py`](DbExpired.py) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.py`](DbExpiredCleaned.py) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.py`](DbDropped.py) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.py`](DbDroppedJson.py) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.py`](DbDroppedBacklinks.py) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.py`](DbExpired.py): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.py`](DbExpiredCleaned.py): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.py`](DbDropped.py): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.py`](DbDroppedJson.py): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.py`](DbDroppedBacklinks.py): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.py`](DbWhoisDaily.py) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.py`](DbWhoisWeekly.py) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.py`](DbWhoisMonthly.py) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.py`](DbWhoisDaily.py): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.py`](DbWhoisWeekly.py): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.py`](DbWhoisMonthly.py): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.py`](DbDnsDaily.py) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.py`](DbDnsWeekly.py) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.py`](DbDnsMonthly.py) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.py`](DbDnsDaily.py): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.py`](DbDnsWeekly.py): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.py`](DbDnsMonthly.py): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.py`](DbSubdomainsDaily.py) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.py`](DbSubdomainsWeekly.py) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.py`](DbSubdomainsMonthly.py) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.py`](DbSubdomainsDaily.py): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.py`](DbSubdomainsWeekly.py): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.py`](DbSubdomainsMonthly.py): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.py`](DbIpCountryStatus.py) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.py`](DbIpCountry.py) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.py`](DbIpCityStatus.py) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.py`](DbIpCity.py) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.py`](DbIpCountryStatus.py): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.py`](DbIpCountry.py): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.py`](DbIpCityStatus.py): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.py`](DbIpCity.py): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.py`](DbAsnWhois.py) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.py`](DbAsnWhoisStatus.py) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.py`](DbAsnWhois.py): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.py`](DbAsnWhoisStatus.py): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.py`](DbIpWhois.py) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.py`](DbIpWhoisStatus.py) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.py`](DbIpWhois.py): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.py`](DbIpWhoisStatus.py): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.py`](DbIpSecurity.py) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.py`](DbIpSecurityStatus.py) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.py`](DbIpSecurity.py): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.py`](DbIpSecurityStatus.py): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.py`](DownloadThreatFeedPhishing.py) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.py`](DownloadThreatFeedPhishingSample.py) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.py`](DownloadThreatFeedMalware.py) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.py`](DownloadThreatFeedMalwareSample.py) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.py`](DownloadThreatFeedSpam.py) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.py`](DownloadThreatFeedSpamSample.py) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.py`](DownloadThreatFeedPhishing.py): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.py`](DownloadThreatFeedPhishingSample.py): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.py`](DownloadThreatFeedMalware.py): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.py`](DownloadThreatFeedMalwareSample.py): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.py`](DownloadThreatFeedSpam.py): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.py`](DownloadThreatFeedSpamSample.py): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/python/RotateApiKey.py b/examples/python/RotateApiKey.py index 883d0e7..d5e637c 100644 --- a/examples/python/RotateApiKey.py +++ b/examples/python/RotateApiKey.py @@ -1,12 +1,18 @@ -"""Runnable example: Rotate API Key (GET /v1.0/api-key/rotate).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.account_api import AccountApi - -# Parameters for rotateApiKey (GET /v1.0/api-key/rotate): -# (no parameters; the API key is set on the client) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = AccountApi(ApiClient(config)) - -result = api.rotate_api_key() -print(result) +"""Rotate API Key: GET https://api.whoisfreaks.com/v1.0/api-key/rotate + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python RotateApiKey.py +""" +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.AccountApi(client) + + # rotate_api_key takes no parameters. + new_key = api.rotate_api_key() # use this key from now on + print("New API key:", new_key) diff --git a/examples/python/SslLookup.py b/examples/python/SslLookup.py index 6c0e299..44cad6f 100644 --- a/examples/python/SslLookup.py +++ b/examples/python/SslLookup.py @@ -1,15 +1,23 @@ -"""Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.ssl_api import SSLApi - -# Parameters for sslLookup (GET /v1.0/ssl/live): -# - domainName (string, required) -# - chain (boolean, optional) -# - sslRaw (boolean, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = SSLApi(ApiClient(config)) - -result = api.ssl_lookup(domain_name="example.com") -print(result) +"""SSL Certificate Lookup: GET https://api.whoisfreaks.com/v1.0/ssl/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python SslLookup.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.SSLApi(client) + + # ssl_lookup parameters: + # domain_name (str, required) + # chain (bool, optional, keyword): default False + # ssl_raw (bool, optional, keyword): default False + # format (str, optional, keyword): one of json, xml; default "json" + result = api.ssl_lookup("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/Subdomains.py b/examples/python/Subdomains.py index 19686a5..d8b2a66 100644 --- a/examples/python/Subdomains.py +++ b/examples/python/Subdomains.py @@ -1,18 +1,25 @@ -"""Runnable example: Subdomains Lookup (GET /v1.0/subdomains).""" -from datetime import date, timedelta -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.subdomains_api import SubdomainsApi +"""Subdomains Lookup: GET https://api.whoisfreaks.com/v1.0/subdomains -# Parameters for subdomains (GET /v1.0/subdomains): -# - domain (string, required) -# - after (string, optional) -# - before (string, optional) -# - status (string (one of: active, inactive), optional) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = SubdomainsApi(ApiClient(config)) +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python Subdomains.py +""" +import json +import os -result = api.subdomains(domain="example.com", after="2000-01-01", before=str(date.today())) -print(result) +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.SubdomainsApi(client) + + # subdomains parameters: + # domain (str, required) + # after (datetime.date, optional, keyword) + # before (datetime.date, optional, keyword) + # status (str, optional, keyword): one of active, inactive + # page (int, optional, keyword): default 1 + # format (str, optional, keyword): one of json, xml; default "json" + result = api.subdomains("whoisfreaks.com", page=1) + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/Typosquatting.py b/examples/python/Typosquatting.py index 7c265cf..7b34c3a 100644 --- a/examples/python/Typosquatting.py +++ b/examples/python/Typosquatting.py @@ -1,14 +1,22 @@ -"""Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.typosquatting_api import TyposquattingApi - -# Parameters for typosquatting (GET /v3.0/domain/typos): -# - keyword (string, optional) -# - pattern (string, optional) -# - pageToken (string, optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = TyposquattingApi(ApiClient(config)) - -result = api.typosquatting() -print(result) +"""Typosquatting Lookup: GET https://api.whoisfreaks.com/v3.0/domain/typos + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python Typosquatting.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.TyposquattingApi(client) + + # typosquatting parameters: + # keyword (str, optional, keyword) + # pattern (str, optional, keyword) + # page_token (str, optional, keyword) + result = api.typosquatting(keyword="whoisfreaks") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/WhoisHistoricalOrReverse.py b/examples/python/WhoisHistoricalOrReverse.py deleted file mode 100644 index 2d6cef6..0000000 --- a/examples/python/WhoisHistoricalOrReverse.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Runnable example: WHOIS Historical or Reverse Lookup (GET /v1.0/whois).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi - -# Parameters for whoisHistoricalOrReverse (GET /v1.0/whois): -# - apiKey (string, required): Your WHOISFreaks API key -# - whois (string (one of: historical, reverse), required) -# - domainName (string, required): Required for historical lookup -# - keyword (string, optional): For reverse — domain keyword search -# - email (string, optional): For reverse — registrant email search -# - owner (string, optional): For reverse — registrant name search -# - company (string, optional): For reverse — company name search -# - mode (string (one of: default, mini), optional) -# - exact (boolean, optional) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -config = Configuration() -api = WHOISApi(ApiClient(config)) - -resp = api.whois_historical_or_reverse_with_http_info(api_key="YOUR_API_KEY", whois="historical", domain_name="example.com", exact=True) -print("status:", resp.status_code) -print(resp.data) diff --git a/examples/python/WhoisHistory.py b/examples/python/WhoisHistory.py index 7084226..b4bbacc 100644 --- a/examples/python/WhoisHistory.py +++ b/examples/python/WhoisHistory.py @@ -1,14 +1,21 @@ -"""Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi - -# Parameters for whoisHistory (GET /v2.0/whois/history): -# - domainName (string, required): Domain to fetch historical WHOIS records for -# - page (integer, optional): Page number -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) - -result = api.whois_history(domain_name="example.com") -print(result) +"""Historical WHOIS records for a domain: GET https://api.whoisfreaks.com/v2.0/whois/history + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisHistory.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + + # whois_history parameters: + # domain_name (str, required): Domain to fetch historical WHOIS records for + # format (str, optional, keyword): one of json, xml + result = api.whois_history("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/WhoisLive.py b/examples/python/WhoisLive.py index dac8cbf..8595e69 100644 --- a/examples/python/WhoisLive.py +++ b/examples/python/WhoisLive.py @@ -1,13 +1,21 @@ -"""Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi - -# Parameters for whoisLive (GET /v2.0/whois/live): -# - domainName (string, required) -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) - -result = api.whois_live(domain_name="example.com") -print(result) +"""Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisLive.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + + # whois_live parameters: + # domain_name (str, required) + # format (str, optional, keyword): one of json, xml; default "json" + result = api.whois_live("whoisfreaks.com") + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/python/WhoisReverse.py b/examples/python/WhoisReverse.py index d68bc8a..2d84b15 100644 --- a/examples/python/WhoisReverse.py +++ b/examples/python/WhoisReverse.py @@ -1,14 +1,22 @@ -"""Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse).""" -from whoisfreaks import Configuration, ApiClient -from whoisfreaks.api.whois_api import WHOISApi - -# Parameters for whoisReverse (GET /v2.0/whois/reverse): -# - keyword (string, required): Keyword to search across WHOIS records -# - page (integer, optional): Page number -# - format (string (one of: json, xml), optional) -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once -api = WHOISApi(ApiClient(config)) - -result = api.whois_reverse(keyword="value") -print(result) +"""Reverse WHOIS lookup by keyword: GET https://api.whoisfreaks.com/v2.0/whois/reverse + +Run it with your API key in the environment: + WHOISFREAKS_API_KEY=your_api_key python WhoisReverse.py +""" +import json +import os + +import whoisfreaks + +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request + +with whoisfreaks.ApiClient(config) as client: + api = whoisfreaks.WHOISApi(client) + + # whois_reverse parameters: + # keyword (str, required): Keyword to search across WHOIS records + # page (int, optional, keyword): Page number + # format (str, optional, keyword): one of json, xml + result = api.whois_reverse("whoisfreaks", page=1) + print(json.dumps(result.to_dict(), indent=2)) diff --git a/examples/ruby/AccountUsage.rb b/examples/ruby/AccountUsage.rb index 182a10a..bccab59 100644 --- a/examples/ruby/AccountUsage.rb +++ b/examples/ruby/AccountUsage.rb @@ -1,12 +1,22 @@ -# Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +# Account Usage +# # Parameters for accountUsage (GET /v1.0/whoisapi/usage): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::AccountApi.new -result = api.account_usage() -puts result + +begin + result = api.account_usage + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/AsnWhois.rb b/examples/ruby/AsnWhois.rb index 2524eeb..3fcd028 100644 --- a/examples/ruby/AsnWhois.rb +++ b/examples/ruby/AsnWhois.rb @@ -1,13 +1,23 @@ -# Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +# ASN WHOIS Lookup +# # Parameters for asnWhois (GET /v2.0/asn-whois): # - asn (string, required) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::ASNWHOISApi.new -result = api.asn_whois("AS15169") -puts result + +begin + result = api.asn_whois("as15169") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/BulkDomainAvailabilityV2.rb b/examples/ruby/BulkDomainAvailabilityV2.rb index a474d3a..87b1fd2 100644 --- a/examples/ruby/BulkDomainAvailabilityV2.rb +++ b/examples/ruby/BulkDomainAvailabilityV2.rb @@ -1,14 +1,26 @@ -# Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +# Bulk Domain Availability Check +# # Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): # - domain (string, optional): Required for TLD-mode bulk check (base domain). # - format (string (one of: json, xml), optional) -# - body: BulkDomainAvailabilityRequest (required) -- request body object -require 'whoisfreaks' +# - body: BulkDomainAvailabilityRequest (required): request body object +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DomainAvailabilityApi.new -result = api.bulk_domain_availability_v2(WhoisFreaks::BulkDomainAvailabilityRequest.new) -puts result + +request = WhoisFreaks::BulkDomainAvailabilityRequest.new(domain_names: ["whoisfreaks.com", "example.com"]) + +begin + result = api.bulk_domain_availability_v2(request) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/BulkGeolocation.rb b/examples/ruby/BulkGeolocation.rb index f9764ef..642ecb6 100644 --- a/examples/ruby/BulkGeolocation.rb +++ b/examples/ruby/BulkGeolocation.rb @@ -1,12 +1,24 @@ -# Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +# Bulk IP Geolocation +# # Parameters for bulkGeolocation (POST /v1.0/geolocation): -# - body: BulkGeolocationRequest (required) -- request body object -require 'whoisfreaks' +# - body: BulkGeolocationRequest (required): request body object +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::GeolocationApi.new -result = api.bulk_geolocation(WhoisFreaks::BulkGeolocationRequest.new) -puts result + +request = WhoisFreaks::BulkGeolocationRequest.new(ips: ["8.8.8.8", "1.1.1.1"]) + +begin + results = api.bulk_geolocation(request) + puts JSON.pretty_generate(results.map(&:to_hash)) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/BulkIpReputation.rb b/examples/ruby/BulkIpReputation.rb index 91b9f4d..1d9315a 100644 --- a/examples/ruby/BulkIpReputation.rb +++ b/examples/ruby/BulkIpReputation.rb @@ -1,12 +1,24 @@ -# Runnable example: Bulk IP Reputation (POST /v1.0/security) +# Bulk IP Reputation +# # Parameters for bulkIpReputation (POST /v1.0/security): -# - body: BulkIpReputationRequest (required) -- request body object -require 'whoisfreaks' +# - body: BulkGeolocationRequest (required): request body object +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::IPReputationApi.new -result = api.bulk_ip_reputation(WhoisFreaks::BulkIpReputationRequest.new) -puts result + +request = WhoisFreaks::BulkGeolocationRequest.new(ips: ["8.8.8.8", "1.1.1.1"]) + +begin + results = api.bulk_ip_reputation(request) + puts JSON.pretty_generate(results.map(&:to_hash)) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/BulkWhois.rb b/examples/ruby/BulkWhois.rb index b0166df..6c75786 100644 --- a/examples/ruby/BulkWhois.rb +++ b/examples/ruby/BulkWhois.rb @@ -1,13 +1,25 @@ -# Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +# Bulk WHOIS Lookup +# # Parameters for bulkWhois (POST /v2.0/bulkwhois/live): # - format (string (one of: json, xml), optional) -# - body: BulkWhoisRequest (required) -- request body object -require 'whoisfreaks' +# - body: BulkWhoisRequest (required): request body object +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.bulk_whois(WhoisFreaks::BulkWhoisRequest.new) -puts result + +request = WhoisFreaks::BulkWhoisRequest.new(domain_names: ["whoisfreaks.com", "jfreaks.com"]) + +begin + result = api.bulk_whois(request) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DatabaseFileStatus.rb b/examples/ruby/DatabaseFileStatus.rb index 3472b43..0187560 100644 --- a/examples/ruby/DatabaseFileStatus.rb +++ b/examples/ruby/DatabaseFileStatus.rb @@ -1,12 +1,23 @@ -# Runnable example: Database File Status (Public) (GET /v3.4/status) +# Database File Status (Public) +# # Parameters for databaseFileStatus (GET /v3.4/status): -# (no parameters; the API key is set on the client) -require 'whoisfreaks' +# (no parameters; no API key required) +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. +# (This endpoint is public, so the key is not sent with this request.) WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::AccountApi.new -result = api.database_file_status() -puts result + +begin + result = api.database_file_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbAsnWhois.rb b/examples/ruby/DbAsnWhois.rb index d141a8d..a7a5f65 100644 --- a/examples/ruby/DbAsnWhois.rb +++ b/examples/ruby/DbAsnWhois.rb @@ -1,13 +1,26 @@ -# Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +# ASN WHOIS Snapshot +# # Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesASNWHOISApi.new -result = api.db_asn_whois((Date.today - 1).to_s) -puts result + +begin + file = api.db_asn_whois(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbAsnWhois.json.gz" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbAsnWhoisStatus.rb b/examples/ruby/DbAsnWhoisStatus.rb index acfacbd..b9453eb 100644 --- a/examples/ruby/DbAsnWhoisStatus.rb +++ b/examples/ruby/DbAsnWhoisStatus.rb @@ -1,12 +1,22 @@ -# Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +# ASN WHOIS Snapshot Status +# # Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesASNWHOISApi.new -result = api.db_asn_whois_status() -puts result + +begin + result = api.db_asn_whois_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbDnsDaily.rb b/examples/ruby/DbDnsDaily.rb index 1a2e573..03df62b 100644 --- a/examples/ruby/DbDnsDaily.rb +++ b/examples/ruby/DbDnsDaily.rb @@ -1,13 +1,26 @@ -# Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +# DNS Database Daily +# # Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesDNSApi.new -result = api.db_dns_daily((Date.today - 1).to_s) -puts result + +begin + file = api.db_dns_daily(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDnsDaily.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbDnsMonthly.rb b/examples/ruby/DbDnsMonthly.rb index a6fc758..86a16c7 100644 --- a/examples/ruby/DbDnsMonthly.rb +++ b/examples/ruby/DbDnsMonthly.rb @@ -1,13 +1,26 @@ -# Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +# DNS Database Monthly +# # Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesDNSApi.new -result = api.db_dns_monthly((Date.today - 1).to_s) -puts result + +begin + file = api.db_dns_monthly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDnsMonthly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbDnsWeekly.rb b/examples/ruby/DbDnsWeekly.rb index 875a1f3..dd3f7db 100644 --- a/examples/ruby/DbDnsWeekly.rb +++ b/examples/ruby/DbDnsWeekly.rb @@ -1,13 +1,26 @@ -# Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +# DNS Database Weekly +# # Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesDNSApi.new -result = api.db_dns_weekly((Date.today - 1).to_s) -puts result + +begin + file = api.db_dns_weekly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDnsWeekly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbDropped.rb b/examples/ruby/DbDropped.rb index 5bcb05c..34f199f 100644 --- a/examples/ruby/DbDropped.rb +++ b/examples/ruby/DbDropped.rb @@ -1,14 +1,27 @@ -# Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +# Dropped Domains +# # Parameters for dbDropped (GET /v3.1/download/domainer/dropped): # - whois (boolean, required) # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_dropped(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_dropped(true, date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDropped.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbDroppedBacklinks.rb b/examples/ruby/DbDroppedBacklinks.rb index 7b4b535..73303dc 100644 --- a/examples/ruby/DbDroppedBacklinks.rb +++ b/examples/ruby/DbDroppedBacklinks.rb @@ -1,14 +1,27 @@ -# Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +# Dropped With Backlinks +# # Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): # - whois (boolean, optional) # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_dropped_backlinks(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_dropped_backlinks(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbDroppedBacklinks.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbDroppedJson.rb b/examples/ruby/DbDroppedJson.rb index 162422d..f83a2a6 100644 --- a/examples/ruby/DbDroppedJson.rb +++ b/examples/ruby/DbDroppedJson.rb @@ -1,14 +1,23 @@ -# Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +# Dropped Domains (JSON) +# # Parameters for dbDroppedJson (GET /v3.1/domains/dropped): # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_dropped_json((Date.today - 1).to_s) -puts result + +begin + domains = api.db_dropped_json(date: Date.parse("2026-10-01")) + puts domains +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbExpired.rb b/examples/ruby/DbExpired.rb index c0fc487..b270c77 100644 --- a/examples/ruby/DbExpired.rb +++ b/examples/ruby/DbExpired.rb @@ -1,14 +1,27 @@ -# Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +# Expiring Domains +# # Parameters for dbExpired (GET /v3.1/download/domainer/expired): # - whois (boolean, required) # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_expired(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_expired(true, date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbExpired.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbExpiredCleaned.rb b/examples/ruby/DbExpiredCleaned.rb index d2b6937..1c4c604 100644 --- a/examples/ruby/DbExpiredCleaned.rb +++ b/examples/ruby/DbExpiredCleaned.rb @@ -1,13 +1,26 @@ -# Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +# Expiring Cleaned WHOIS +# # Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesExpiringDroppedApi.new -result = api.db_expired_cleaned((Date.today - 1).to_s) -puts result + +begin + file = api.db_expired_cleaned(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbExpiredCleaned.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbIpCity.rb b/examples/ruby/DbIpCity.rb index a651074..6968864 100644 --- a/examples/ruby/DbIpCity.rb +++ b/examples/ruby/DbIpCity.rb @@ -1,13 +1,26 @@ -# Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +# IP to City Snapshot +# # Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPGeolocationApi.new -result = api.db_ip_city((Date.today - 1).to_s) -puts result + +begin + file = api.db_ip_city(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbIpCity.zip" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbIpCityStatus.rb b/examples/ruby/DbIpCityStatus.rb index b529c76..04d364e 100644 --- a/examples/ruby/DbIpCityStatus.rb +++ b/examples/ruby/DbIpCityStatus.rb @@ -1,12 +1,22 @@ -# Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +# IP to City Snapshot Status +# # Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPGeolocationApi.new -result = api.db_ip_city_status() -puts result + +begin + result = api.db_ip_city_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbIpCountry.rb b/examples/ruby/DbIpCountry.rb index d4297f3..aff1ed0 100644 --- a/examples/ruby/DbIpCountry.rb +++ b/examples/ruby/DbIpCountry.rb @@ -1,13 +1,26 @@ -# Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +# IP to Country Snapshot +# # Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPGeolocationApi.new -result = api.db_ip_country((Date.today - 1).to_s) -puts result + +begin + file = api.db_ip_country(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbIpCountry.zip" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbIpCountryStatus.rb b/examples/ruby/DbIpCountryStatus.rb index ff811f5..c9ca89f 100644 --- a/examples/ruby/DbIpCountryStatus.rb +++ b/examples/ruby/DbIpCountryStatus.rb @@ -1,12 +1,22 @@ -# Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +# IP to Country Snapshot Status +# # Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPGeolocationApi.new -result = api.db_ip_country_status() -puts result + +begin + result = api.db_ip_country_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbIpSecurity.rb b/examples/ruby/DbIpSecurity.rb index 3f4f9c7..351b3dd 100644 --- a/examples/ruby/DbIpSecurity.rb +++ b/examples/ruby/DbIpSecurity.rb @@ -1,13 +1,26 @@ -# Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +# IP Security Snapshot +# # Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPSecurityApi.new -result = api.db_ip_security((Date.today - 1).to_s) -puts result + +begin + file = api.db_ip_security(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbIpSecurity.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbIpSecurityStatus.rb b/examples/ruby/DbIpSecurityStatus.rb index 51710b2..132b1c5 100644 --- a/examples/ruby/DbIpSecurityStatus.rb +++ b/examples/ruby/DbIpSecurityStatus.rb @@ -1,12 +1,22 @@ -# Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +# IP Security Snapshot Status +# # Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPSecurityApi.new -result = api.db_ip_security_status() -puts result + +begin + result = api.db_ip_security_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbIpWhois.rb b/examples/ruby/DbIpWhois.rb index 5339afc..b9dabf6 100644 --- a/examples/ruby/DbIpWhois.rb +++ b/examples/ruby/DbIpWhois.rb @@ -1,13 +1,26 @@ -# Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +# IP WHOIS Snapshot +# # Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): # - date (string, required) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPWHOISApi.new -result = api.db_ip_whois((Date.today - 1).to_s) -puts result + +begin + file = api.db_ip_whois(Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbIpWhois.json.gz" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbIpWhoisStatus.rb b/examples/ruby/DbIpWhoisStatus.rb index 5107ea6..99deb91 100644 --- a/examples/ruby/DbIpWhoisStatus.rb +++ b/examples/ruby/DbIpWhoisStatus.rb @@ -1,12 +1,22 @@ -# Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +# IP WHOIS Snapshot Status +# # Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesIPWHOISApi.new -result = api.db_ip_whois_status() -puts result + +begin + result = api.db_ip_whois_status + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbNewlyCctld.rb b/examples/ruby/DbNewlyCctld.rb index fbb3672..fe2b679 100644 --- a/examples/ruby/DbNewlyCctld.rb +++ b/examples/ruby/DbNewlyCctld.rb @@ -1,15 +1,28 @@ -# Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +# Newly Registered ccTLD (CSV) +# # Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): # - whois (boolean, required) # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_cctld(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_cctld(true, date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyCctld.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbNewlyCctldCleaned.rb b/examples/ruby/DbNewlyCctldCleaned.rb index 1097119..81fcccc 100644 --- a/examples/ruby/DbNewlyCctldCleaned.rb +++ b/examples/ruby/DbNewlyCctldCleaned.rb @@ -1,13 +1,26 @@ -# Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +# Newly Registered ccTLD Cleaned WHOIS (CSV) +# # Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_cctld_cleaned((Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_cctld_cleaned(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyCctldCleaned.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbNewlyCctldJson.rb b/examples/ruby/DbNewlyCctldJson.rb index 49bc201..90f83cc 100644 --- a/examples/ruby/DbNewlyCctldJson.rb +++ b/examples/ruby/DbNewlyCctldJson.rb @@ -1,14 +1,23 @@ -# Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +# Newly Registered ccTLD (JSON) +# # Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_cctld_json((Date.today - 1).to_s) -puts result + +begin + domains = api.db_newly_cctld_json(date: Date.parse("2026-10-01")) + puts domains +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbNewlyDns.rb b/examples/ruby/DbNewlyDns.rb index d1947a2..56e82de 100644 --- a/examples/ruby/DbNewlyDns.rb +++ b/examples/ruby/DbNewlyDns.rb @@ -1,13 +1,26 @@ -# Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +# Newly Registered With DNS +# # Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_dns((Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_dns(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyDns.json" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbNewlyGtld.rb b/examples/ruby/DbNewlyGtld.rb index 4131042..b0352af 100644 --- a/examples/ruby/DbNewlyGtld.rb +++ b/examples/ruby/DbNewlyGtld.rb @@ -1,15 +1,28 @@ -# Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +# Newly Registered gTLD (CSV) +# # Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): # - whois (boolean, required) # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_gtld(false, (Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_gtld(true, date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyGtld.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbNewlyGtldCleaned.rb b/examples/ruby/DbNewlyGtldCleaned.rb index 653a5c0..eee92a3 100644 --- a/examples/ruby/DbNewlyGtldCleaned.rb +++ b/examples/ruby/DbNewlyGtldCleaned.rb @@ -1,13 +1,26 @@ -# Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +# Newly Registered gTLD Cleaned WHOIS (CSV) +# # Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_gtld_cleaned((Date.today - 1).to_s) -puts result + +begin + file = api.db_newly_gtld_cleaned(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbNewlyGtldCleaned.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbNewlyGtldJson.rb b/examples/ruby/DbNewlyGtldJson.rb index 037f5bc..87a29eb 100644 --- a/examples/ruby/DbNewlyGtldJson.rb +++ b/examples/ruby/DbNewlyGtldJson.rb @@ -1,14 +1,23 @@ -# Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +# Newly Registered gTLD (JSON) +# # Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): # - date (string, optional): yyyy-MM-dd; omit for latest # - tlds (string, optional) -require 'date' -require 'whoisfreaks' +require "date" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesNewlyRegisteredApi.new -result = api.db_newly_gtld_json((Date.today - 1).to_s) -puts result + +begin + domains = api.db_newly_gtld_json(date: Date.parse("2026-10-01")) + puts domains +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbSubdomainsDaily.rb b/examples/ruby/DbSubdomainsDaily.rb index 33a6b2a..ad49b51 100644 --- a/examples/ruby/DbSubdomainsDaily.rb +++ b/examples/ruby/DbSubdomainsDaily.rb @@ -1,13 +1,26 @@ -# Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +# Subdomains Daily +# # Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesSubdomainsApi.new -result = api.db_subdomains_daily((Date.today - 1).to_s) -puts result + +begin + file = api.db_subdomains_daily(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbSubdomainsDaily.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbSubdomainsMonthly.rb b/examples/ruby/DbSubdomainsMonthly.rb index 67a2305..8e96406 100644 --- a/examples/ruby/DbSubdomainsMonthly.rb +++ b/examples/ruby/DbSubdomainsMonthly.rb @@ -1,13 +1,26 @@ -# Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +# Subdomains Monthly +# # Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesSubdomainsApi.new -result = api.db_subdomains_monthly((Date.today - 1).to_s) -puts result + +begin + file = api.db_subdomains_monthly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbSubdomainsMonthly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbSubdomainsWeekly.rb b/examples/ruby/DbSubdomainsWeekly.rb index 04ac1b2..e93ab45 100644 --- a/examples/ruby/DbSubdomainsWeekly.rb +++ b/examples/ruby/DbSubdomainsWeekly.rb @@ -1,13 +1,26 @@ -# Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +# Subdomains Weekly +# # Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesSubdomainsApi.new -result = api.db_subdomains_weekly((Date.today - 1).to_s) -puts result + +begin + file = api.db_subdomains_weekly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbSubdomainsWeekly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbWhoisDaily.rb b/examples/ruby/DbWhoisDaily.rb index a8fbab9..aab6064 100644 --- a/examples/ruby/DbWhoisDaily.rb +++ b/examples/ruby/DbWhoisDaily.rb @@ -1,13 +1,26 @@ -# Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +# WHOIS Database Daily +# # Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesWHOISApi.new -result = api.db_whois_daily((Date.today - 1).to_s) -puts result + +begin + file = api.db_whois_daily(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbWhoisDaily.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbWhoisMonthly.rb b/examples/ruby/DbWhoisMonthly.rb index 24f63ec..60be625 100644 --- a/examples/ruby/DbWhoisMonthly.rb +++ b/examples/ruby/DbWhoisMonthly.rb @@ -1,13 +1,26 @@ -# Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +# WHOIS Database Monthly +# # Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesWHOISApi.new -result = api.db_whois_monthly((Date.today - 1).to_s) -puts result + +begin + file = api.db_whois_monthly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbWhoisMonthly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DbWhoisWeekly.rb b/examples/ruby/DbWhoisWeekly.rb index 2d1f78d..873017d 100644 --- a/examples/ruby/DbWhoisWeekly.rb +++ b/examples/ruby/DbWhoisWeekly.rb @@ -1,13 +1,26 @@ -# Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +# WHOIS Database Weekly +# # Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): # - date (string, optional): yyyy-MM-dd; omit for latest -require 'date' -require 'whoisfreaks' +require "date" +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesWHOISApi.new -result = api.db_whois_weekly((Date.today - 1).to_s) -puts result + +begin + file = api.db_whois_weekly(date: Date.parse("2026-10-01")) + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DbWhoisWeekly.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DnsBulk.rb b/examples/ruby/DnsBulk.rb index 142b34e..2c574b2 100644 --- a/examples/ruby/DnsBulk.rb +++ b/examples/ruby/DnsBulk.rb @@ -1,14 +1,26 @@ -# Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +# Bulk DNS Lookup +# # Parameters for dnsBulk (POST /v2.0/dns/bulk/live): # - type (string, required) # - format (string (one of: json, xml), optional) -# - body: DnsBulkRequest (required) -- request body object -require 'whoisfreaks' +# - body: DnsBulkRequest (required): request body object +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DNSApi.new -result = api.dns_bulk("value", WhoisFreaks::DnsBulkRequest.new) -puts result + +request = WhoisFreaks::DnsBulkRequest.new(domain_names: ["whoisfreaks.com", "example.com"]) + +begin + result = api.dns_bulk("A,MX,TXT", request) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DnsHistorical.rb b/examples/ruby/DnsHistorical.rb index a029174..1df1600 100644 --- a/examples/ruby/DnsHistorical.rb +++ b/examples/ruby/DnsHistorical.rb @@ -1,15 +1,25 @@ -# Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +# Historical DNS Lookup +# # Parameters for dnsHistorical (GET /v2.0/dns/historical): -# - domainName (string, required) +# - domain_name (string, required) # - type (string, required) # - page (integer, optional) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DNSApi.new -result = api.dns_historical("example.com", "value") -puts result + +begin + result = api.dns_historical("whoisfreaks.com", "A,MX,TXT", page: 1) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DnsLive.rb b/examples/ruby/DnsLive.rb index db32bf4..aef06ad 100644 --- a/examples/ruby/DnsLive.rb +++ b/examples/ruby/DnsLive.rb @@ -1,15 +1,25 @@ -# Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +# Live DNS Lookup +# # Parameters for dnsLive (GET /v2.0/dns/live): -# - domainName (string, required) -# - ipAddress (string, required): Use for PTR lookups +# - domain_name (string, optional) +# - ip_address (string, optional): Use for PTR lookups # - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DNSApi.new -result = api.dns_live("example.com", "8.8.8.8", "value") -puts result + +begin + result = api.dns_live("A,MX,TXT", domain_name: "whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DnsReverse.rb b/examples/ruby/DnsReverse.rb index 075f647..17face8 100644 --- a/examples/ruby/DnsReverse.rb +++ b/examples/ruby/DnsReverse.rb @@ -1,16 +1,26 @@ -# Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +# Reverse DNS Lookup +# # Parameters for dnsReverse (GET /v2.1/dns/reverse): # - value (string, required): IP, CIDR, or record value # - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) # - exact (boolean, optional) # - page (integer, optional) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DNSApi.new -result = api.dns_reverse("value", "a", true) -puts result + +begin + result = api.dns_reverse("8.8.8.8", "a", page: 1) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DomainAvailabilityV2.rb b/examples/ruby/DomainAvailabilityV2.rb index 6872db0..d6f8fb8 100644 --- a/examples/ruby/DomainAvailabilityV2.rb +++ b/examples/ruby/DomainAvailabilityV2.rb @@ -1,15 +1,25 @@ -# Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +# Domain Availability Check with Suggestions +# # Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): # - domain (string, required): The domain name to check # - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. # - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DomainAvailabilityApi.new -result = api.domain_availability_v2("example.com") -puts result + +begin + result = api.domain_availability_v2("google.com", sug: true, count: 5) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DomainReputation.rb b/examples/ruby/DomainReputation.rb index 7cd7545..9735be5 100644 --- a/examples/ruby/DomainReputation.rb +++ b/examples/ruby/DomainReputation.rb @@ -1,13 +1,23 @@ -# Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +# Domain Reputation Lookup +# # Parameters for domainReputation (GET /v1/domain/security): -# - domainName (string, required): The domain name to assess +# - domain_name (string, required): The domain name to assess # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DomainReputationApi.new -result = api.domain_reputation("example.com") -puts result + +begin + result = api.domain_reputation("amazon.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DownloadThreatFeedMalware.rb b/examples/ruby/DownloadThreatFeedMalware.rb index 5ce4178..5555776 100644 --- a/examples/ruby/DownloadThreatFeedMalware.rb +++ b/examples/ruby/DownloadThreatFeedMalware.rb @@ -1,13 +1,25 @@ -# Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +# Download the daily malware threat feed (CSV) +# # Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -require 'date' -require 'whoisfreaks' +# - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_malware((Date.today - 1).to_s) -puts result + +begin + file = api.download_threat_feed_malware(date: "2026-10-01") + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedMalware.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DownloadThreatFeedMalwareSample.rb b/examples/ruby/DownloadThreatFeedMalwareSample.rb index 6fb95e6..9e8d03e 100644 --- a/examples/ruby/DownloadThreatFeedMalwareSample.rb +++ b/examples/ruby/DownloadThreatFeedMalwareSample.rb @@ -1,12 +1,25 @@ -# Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +# Download a sample of the malware threat feed (CSV) +# # Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_malware_sample() -puts result + +begin + file = api.download_threat_feed_malware_sample + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedMalwareSample.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DownloadThreatFeedPhishing.rb b/examples/ruby/DownloadThreatFeedPhishing.rb index 46a199a..6a5aec8 100644 --- a/examples/ruby/DownloadThreatFeedPhishing.rb +++ b/examples/ruby/DownloadThreatFeedPhishing.rb @@ -1,13 +1,25 @@ -# Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +# Download the daily phishing threat feed (CSV) +# # Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -require 'date' -require 'whoisfreaks' +# - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_phishing((Date.today - 1).to_s) -puts result + +begin + file = api.download_threat_feed_phishing(date: "2026-10-01") + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedPhishing.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DownloadThreatFeedPhishingSample.rb b/examples/ruby/DownloadThreatFeedPhishingSample.rb index 360f792..a3e116a 100644 --- a/examples/ruby/DownloadThreatFeedPhishingSample.rb +++ b/examples/ruby/DownloadThreatFeedPhishingSample.rb @@ -1,12 +1,25 @@ -# Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +# Download a sample of the phishing threat feed (CSV) +# # Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_phishing_sample() -puts result + +begin + file = api.download_threat_feed_phishing_sample + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedPhishingSample.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DownloadThreatFeedSpam.rb b/examples/ruby/DownloadThreatFeedSpam.rb index 988df1e..b438bd8 100644 --- a/examples/ruby/DownloadThreatFeedSpam.rb +++ b/examples/ruby/DownloadThreatFeedSpam.rb @@ -1,13 +1,25 @@ -# Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +# Download the daily spam threat feed (CSV) +# # Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -# - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -require 'date' -require 'whoisfreaks' +# - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_spam((Date.today - 1).to_s) -puts result + +begin + file = api.download_threat_feed_spam(date: "2026-10-01") + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedSpam.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/DownloadThreatFeedSpamSample.rb b/examples/ruby/DownloadThreatFeedSpamSample.rb index 29075a5..401c5e9 100644 --- a/examples/ruby/DownloadThreatFeedSpamSample.rb +++ b/examples/ruby/DownloadThreatFeedSpamSample.rb @@ -1,12 +1,25 @@ -# Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +# Download a sample of the spam threat feed (CSV) +# # Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "fileutils" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::DatabasesThreatFeedApi.new -result = api.download_threat_feed_spam_sample() -puts result + +begin + file = api.download_threat_feed_spam_sample + # The SDK returns a Tempfile that is deleted when the program exits: copy it. + save_as = "DownloadThreatFeedSpamSample.csv" + FileUtils.cp(file.path, save_as) + puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/Geolocation.rb b/examples/ruby/Geolocation.rb index 3441f97..25972f5 100644 --- a/examples/ruby/Geolocation.rb +++ b/examples/ruby/Geolocation.rb @@ -1,12 +1,22 @@ -# Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +# IP Geolocation Lookup +# # Parameters for geolocation (GET /v1.0/geolocation): # - ip (string, required) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::GeolocationApi.new -result = api.geolocation("8.8.8.8") -puts result + +begin + result = api.geolocation("8.8.8.8") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/IpReputation.rb b/examples/ruby/IpReputation.rb index 45ad3bf..9fa8c51 100644 --- a/examples/ruby/IpReputation.rb +++ b/examples/ruby/IpReputation.rb @@ -1,12 +1,22 @@ -# Runnable example: IP Reputation Lookup (GET /v1.0/security) +# IP Reputation Lookup +# # Parameters for ipReputation (GET /v1.0/security): # - ip (string, required) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::IPReputationApi.new -result = api.ip_reputation("8.8.8.8") -puts result + +begin + result = api.ip_reputation("8.8.8.8") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/IpWhois.rb b/examples/ruby/IpWhois.rb index 74b8e24..f357fd5 100644 --- a/examples/ruby/IpWhois.rb +++ b/examples/ruby/IpWhois.rb @@ -1,13 +1,23 @@ -# Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +# IP WHOIS Lookup +# # Parameters for ipWhois (GET /v1.0/ip-whois): # - ip (string, required) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::IPWHOISApi.new -result = api.ip_whois("8.8.8.8") -puts result + +begin + result = api.ip_whois("8.8.8.8") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/README.md b/examples/ruby/README.md index bc7b06c..2c65e41 100644 --- a/examples/ruby/README.md +++ b/examples/ruby/README.md @@ -1,107 +1,107 @@ -# Ruby — Runnable Examples +# Ruby Runnable Examples -Install: see the [Ruby guide](../../docs/languages/ruby.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [Ruby guide](../../docs/languages/ruby.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.rb`](WhoisLive.rb) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.rb`](BulkWhois.rb) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.rb`](WhoisHistory.rb) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.rb`](WhoisReverse.rb) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.rb`](WhoisLive.rb): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.rb`](BulkWhois.rb): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.rb`](WhoisHistory.rb): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.rb`](WhoisReverse.rb): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.rb`](DnsLive.rb) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.rb`](DnsHistorical.rb) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.rb`](DnsReverse.rb) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.rb`](DnsBulk.rb) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.rb`](DnsLive.rb): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.rb`](DnsHistorical.rb): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.rb`](DnsReverse.rb): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.rb`](DnsBulk.rb): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.rb`](DomainAvailabilityV2.rb) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.rb`](BulkDomainAvailabilityV2.rb) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.rb`](DomainAvailabilityV2.rb): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.rb`](BulkDomainAvailabilityV2.rb): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.rb`](Typosquatting.rb) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.rb`](Typosquatting.rb): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.rb`](SslLookup.rb) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.rb`](SslLookup.rb): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.rb`](Geolocation.rb) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.rb`](BulkGeolocation.rb) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.rb`](Geolocation.rb): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.rb`](BulkGeolocation.rb): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.rb`](Subdomains.rb) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.rb`](Subdomains.rb): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.rb`](IpReputation.rb) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.rb`](BulkIpReputation.rb) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.rb`](IpReputation.rb): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.rb`](BulkIpReputation.rb): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.rb`](DomainReputation.rb) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.rb`](DomainReputation.rb): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.rb`](AsnWhois.rb) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.rb`](AsnWhois.rb): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.rb`](IpWhois.rb) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.rb`](IpWhois.rb): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.rb`](RotateApiKey.rb) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.rb`](AccountUsage.rb) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.rb`](DatabaseFileStatus.rb) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.rb`](RotateApiKey.rb): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.rb`](AccountUsage.rb): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.rb`](DatabaseFileStatus.rb): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.rb`](DbNewlyGtld.rb) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.rb`](DbNewlyCctld.rb) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.rb`](DbNewlyGtldCleaned.rb) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.rb`](DbNewlyCctldCleaned.rb) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.rb`](DbNewlyGtldJson.rb) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.rb`](DbNewlyCctldJson.rb) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.rb`](DbNewlyDns.rb) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.rb`](DbNewlyGtld.rb): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.rb`](DbNewlyCctld.rb): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.rb`](DbNewlyGtldCleaned.rb): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.rb`](DbNewlyCctldCleaned.rb): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.rb`](DbNewlyGtldJson.rb): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.rb`](DbNewlyCctldJson.rb): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.rb`](DbNewlyDns.rb): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.rb`](DbExpired.rb) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.rb`](DbExpiredCleaned.rb) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.rb`](DbDropped.rb) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.rb`](DbDroppedJson.rb) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.rb`](DbDroppedBacklinks.rb) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.rb`](DbExpired.rb): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.rb`](DbExpiredCleaned.rb): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.rb`](DbDropped.rb): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.rb`](DbDroppedJson.rb): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.rb`](DbDroppedBacklinks.rb): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.rb`](DbWhoisDaily.rb) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.rb`](DbWhoisWeekly.rb) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.rb`](DbWhoisMonthly.rb) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.rb`](DbWhoisDaily.rb): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.rb`](DbWhoisWeekly.rb): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.rb`](DbWhoisMonthly.rb): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.rb`](DbDnsDaily.rb) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.rb`](DbDnsWeekly.rb) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.rb`](DbDnsMonthly.rb) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.rb`](DbDnsDaily.rb): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.rb`](DbDnsWeekly.rb): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.rb`](DbDnsMonthly.rb): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.rb`](DbSubdomainsDaily.rb) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.rb`](DbSubdomainsWeekly.rb) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.rb`](DbSubdomainsMonthly.rb) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.rb`](DbSubdomainsDaily.rb): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.rb`](DbSubdomainsWeekly.rb): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.rb`](DbSubdomainsMonthly.rb): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.rb`](DbIpCountryStatus.rb) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.rb`](DbIpCountry.rb) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.rb`](DbIpCityStatus.rb) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.rb`](DbIpCity.rb) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.rb`](DbIpCountryStatus.rb): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.rb`](DbIpCountry.rb): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.rb`](DbIpCityStatus.rb): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.rb`](DbIpCity.rb): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.rb`](DbAsnWhois.rb) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.rb`](DbAsnWhoisStatus.rb) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.rb`](DbAsnWhois.rb): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.rb`](DbAsnWhoisStatus.rb): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.rb`](DbIpWhois.rb) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.rb`](DbIpWhoisStatus.rb) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.rb`](DbIpWhois.rb): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.rb`](DbIpWhoisStatus.rb): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.rb`](DbIpSecurity.rb) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.rb`](DbIpSecurityStatus.rb) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.rb`](DbIpSecurity.rb): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.rb`](DbIpSecurityStatus.rb): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.rb`](DownloadThreatFeedPhishing.rb) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.rb`](DownloadThreatFeedPhishingSample.rb) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.rb`](DownloadThreatFeedMalware.rb) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.rb`](DownloadThreatFeedMalwareSample.rb) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.rb`](DownloadThreatFeedSpam.rb) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.rb`](DownloadThreatFeedSpamSample.rb) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.rb`](DownloadThreatFeedPhishing.rb): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.rb`](DownloadThreatFeedPhishingSample.rb): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.rb`](DownloadThreatFeedMalware.rb): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.rb`](DownloadThreatFeedMalwareSample.rb): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.rb`](DownloadThreatFeedSpam.rb): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.rb`](DownloadThreatFeedSpamSample.rb): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/ruby/RotateApiKey.rb b/examples/ruby/RotateApiKey.rb index 2b96742..53f39c5 100644 --- a/examples/ruby/RotateApiKey.rb +++ b/examples/ruby/RotateApiKey.rb @@ -1,12 +1,22 @@ -# Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +# Rotate API Key +# # Parameters for rotateApiKey (GET /v1.0/api-key/rotate): # (no parameters; the API key is set on the client) -require 'whoisfreaks' +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::AccountApi.new -result = api.rotate_api_key() -puts result + +begin + new_key = api.rotate_api_key + # The old key stops working now: store the new one before making more calls. + puts "New API key: #{new_key}" +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/SslLookup.rb b/examples/ruby/SslLookup.rb index 2414a9a..8af23e3 100644 --- a/examples/ruby/SslLookup.rb +++ b/examples/ruby/SslLookup.rb @@ -1,15 +1,25 @@ -# Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +# SSL Certificate Lookup +# # Parameters for sslLookup (GET /v1.0/ssl/live): -# - domainName (string, required) +# - domain_name (string, required) # - chain (boolean, optional) -# - sslRaw (boolean, optional) +# - ssl_raw (boolean, optional) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::SSLApi.new -result = api.ssl_lookup("example.com") -puts result + +begin + result = api.ssl_lookup("whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/Subdomains.rb b/examples/ruby/Subdomains.rb index 0498492..284a9cc 100644 --- a/examples/ruby/Subdomains.rb +++ b/examples/ruby/Subdomains.rb @@ -1,4 +1,5 @@ -# Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +# Subdomains Lookup +# # Parameters for subdomains (GET /v1.0/subdomains): # - domain (string, required) # - after (string, optional) @@ -6,13 +7,21 @@ # - status (string (one of: active, inactive), optional) # - page (integer, optional) # - format (string (one of: json, xml), optional) -require 'date' -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::SubdomainsApi.new -result = api.subdomains("example.com", "2000-01-01", Date.today.to_s) -puts result + +begin + result = api.subdomains("whoisfreaks.com", page: 1) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/Typosquatting.rb b/examples/ruby/Typosquatting.rb index 247f0e7..0c09db3 100644 --- a/examples/ruby/Typosquatting.rb +++ b/examples/ruby/Typosquatting.rb @@ -1,14 +1,24 @@ -# Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +# Typosquatting Lookup +# # Parameters for typosquatting (GET /v3.0/domain/typos): # - keyword (string, optional) # - pattern (string, optional) -# - pageToken (string, optional) -require 'whoisfreaks' +# - page_token (string, optional) +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::TyposquattingApi.new -result = api.typosquatting() -puts result + +begin + result = api.typosquatting(keyword: "whoisfreaks") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/WhoisHistoricalOrReverse.rb b/examples/ruby/WhoisHistoricalOrReverse.rb deleted file mode 100644 index 23dac61..0000000 --- a/examples/ruby/WhoisHistoricalOrReverse.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Runnable example: WHOIS Historical or Reverse Lookup (GET /v1.0/whois) -# Parameters for whoisHistoricalOrReverse (GET /v1.0/whois): -# - apiKey (string, required): Your WHOISFreaks API key -# - whois (string (one of: historical, reverse), required) -# - domainName (string, required): Required for historical lookup -# - keyword (string, optional): For reverse — domain keyword search -# - email (string, optional): For reverse — registrant email search -# - owner (string, optional): For reverse — registrant name search -# - company (string, optional): For reverse — company name search -# - mode (string (one of: default, mini), optional) -# - exact (boolean, optional) -# - page (integer, optional) -# - format (string (one of: json, xml), optional) -require 'whoisfreaks' - -api = WhoisFreaks::WHOISApi.new -data, status, _headers = api.whois_historical_or_reverse_with_http_info("YOUR_API_KEY", "historical", "example.com", true) -puts "status: #{status}" -puts data diff --git a/examples/ruby/WhoisHistory.rb b/examples/ruby/WhoisHistory.rb index 63d05d0..1fafe17 100644 --- a/examples/ruby/WhoisHistory.rb +++ b/examples/ruby/WhoisHistory.rb @@ -1,14 +1,23 @@ -# Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +# Historical WHOIS records for a domain +# # Parameters for whoisHistory (GET /v2.0/whois/history): -# - domainName (string, required): Domain to fetch historical WHOIS records for -# - page (integer, optional): Page number +# - domain_name (string, required): Domain to fetch historical WHOIS records for # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.whois_history("example.com") -puts result + +begin + result = api.whois_history("whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/WhoisLive.rb b/examples/ruby/WhoisLive.rb index 4582ee3..8f80421 100644 --- a/examples/ruby/WhoisLive.rb +++ b/examples/ruby/WhoisLive.rb @@ -1,13 +1,23 @@ -# Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +# Live WHOIS Lookup +# # Parameters for whoisLive (GET /v2.0/whois/live): -# - domainName (string, required) +# - domain_name (string, required) # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.whois_live("example.com") -puts result + +begin + result = api.whois_live("whoisfreaks.com") + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/ruby/WhoisReverse.rb b/examples/ruby/WhoisReverse.rb index f3f2136..019709d 100644 --- a/examples/ruby/WhoisReverse.rb +++ b/examples/ruby/WhoisReverse.rb @@ -1,14 +1,24 @@ -# Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +# Reverse WHOIS lookup by keyword +# # Parameters for whoisReverse (GET /v2.0/whois/reverse): # - keyword (string, required): Keyword to search across WHOIS records # - page (integer, optional): Page number # - format (string (one of: json, xml), optional) -require 'whoisfreaks' +require "json" +require "whoisfreaks" + +# Read the API key from the environment and set it once. WhoisFreaks.configure do |config| - config.api_key["apiKey"] = "YOUR_API_KEY" # set once + config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY") end api = WhoisFreaks::WHOISApi.new -result = api.whois_reverse("value") -puts result + +begin + result = api.whois_reverse("whoisfreaks", page: 1) + puts JSON.pretty_generate(result.to_hash) +rescue WhoisFreaks::ApiError => e + warn "Request failed: HTTP #{e.code} #{e.response_body}" + exit 1 +end diff --git a/examples/swift/AccountUsage.swift b/examples/swift/AccountUsage.swift index 0ccab7f..bb96384 100644 --- a/examples/swift/AccountUsage.swift +++ b/examples/swift/AccountUsage.swift @@ -1,14 +1,24 @@ -// Runnable example: Account Usage (GET /v1.0/whoisapi/usage) +// Account Usage +// // Parameters for accountUsage (GET /v1.0/whoisapi/usage): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await AccountAPI.accountUsage() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/AsnWhois.swift b/examples/swift/AsnWhois.swift index 055f852..04407d6 100644 --- a/examples/swift/AsnWhois.swift +++ b/examples/swift/AsnWhois.swift @@ -1,15 +1,25 @@ -// Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) +// ASN WHOIS Lookup +// // Parameters for asnWhois (GET /v2.0/asn-whois): // - asn (string, required) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await ASNWHOISAPI.asnWhois(asn: "AS15169", format: nil) - print(result) + let result = try await ASNWHOISAPI.asnWhois(asn: "as15169") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/BulkDomainAvailabilityV2.swift b/examples/swift/BulkDomainAvailabilityV2.swift index 076241a..bb5d76c 100644 --- a/examples/swift/BulkDomainAvailabilityV2.swift +++ b/examples/swift/BulkDomainAvailabilityV2.swift @@ -1,16 +1,28 @@ -// Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) +// Bulk Domain Availability Check +// // Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): // - domain (string, optional): Required for TLD-mode bulk check (base domain). // - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object +// - body: BulkDomainAvailabilityRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = BulkDomainAvailabilityRequest(domainNames: ["whoisfreaks.com", "example.com"]) do { - let result = try await DomainAvailabilityAPI.bulkDomainAvailabilityV2(bulkDomainAvailabilityRequest: BulkDomainAvailabilityRequest(), domain: nil, format: nil) - print(result) + let result = try await DomainAvailabilityAPI.bulkDomainAvailabilityV2(bulkDomainAvailabilityRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/BulkGeolocation.swift b/examples/swift/BulkGeolocation.swift index dc91360..9cb8de1 100644 --- a/examples/swift/BulkGeolocation.swift +++ b/examples/swift/BulkGeolocation.swift @@ -1,14 +1,26 @@ -// Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) +// Bulk IP Geolocation +// // Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = BulkGeolocationRequest(ips: ["8.8.8.8", "1.1.1.1"]) do { - let result = try await GeolocationAPI.bulkGeolocation(bulkGeolocationRequest: BulkGeolocationRequest()) - print(result) + let result = try await GeolocationAPI.bulkGeolocation(bulkGeolocationRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/BulkIpReputation.swift b/examples/swift/BulkIpReputation.swift index 66d09e5..255eaa9 100644 --- a/examples/swift/BulkIpReputation.swift +++ b/examples/swift/BulkIpReputation.swift @@ -1,14 +1,26 @@ -// Runnable example: Bulk IP Reputation (POST /v1.0/security) +// Bulk IP Reputation +// // Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object +// - body: BulkGeolocationRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = BulkGeolocationRequest(ips: ["8.8.8.8", "1.1.1.1"]) do { - let result = try await IPReputationAPI.bulkIpReputation(bulkIpReputationRequest: BulkIpReputationRequest()) - print(result) + let result = try await IPReputationAPI.bulkIpReputation(bulkGeolocationRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/BulkWhois.swift b/examples/swift/BulkWhois.swift index 4e2fda6..ca3b2f6 100644 --- a/examples/swift/BulkWhois.swift +++ b/examples/swift/BulkWhois.swift @@ -1,15 +1,27 @@ -// Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) +// Bulk WHOIS Lookup +// // Parameters for bulkWhois (POST /v2.0/bulkwhois/live): // - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object +// - body: BulkWhoisRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = BulkWhoisRequest(domainNames: ["whoisfreaks.com", "jfreaks.com"]) do { - let result = try await WHOISAPI.bulkWhois(bulkWhoisRequest: BulkWhoisRequest(), format: nil) - print(result) + let result = try await WHOISAPI.bulkWhois(bulkWhoisRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DatabaseFileStatus.swift b/examples/swift/DatabaseFileStatus.swift index 78c199f..0b954d9 100644 --- a/examples/swift/DatabaseFileStatus.swift +++ b/examples/swift/DatabaseFileStatus.swift @@ -1,14 +1,25 @@ -// Runnable example: Database File Status (Public) (GET /v3.4/status) +// Database File Status (Public) +// // Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) +// (no parameters; no API key required) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] +// (This endpoint is public, so the key is not sent with this request.) do { let result = try await AccountAPI.databaseFileStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbAsnWhois.swift b/examples/swift/DbAsnWhois.swift index 49d9841..2ac1e58 100644 --- a/examples/swift/DbAsnWhois.swift +++ b/examples/swift/DbAsnWhois.swift @@ -1,15 +1,28 @@ -// Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) +// ASN WHOIS Snapshot +// // Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesASNWHOISAPI.dbAsnWhois(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesASNWHOISAPI.dbAsnWhois(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbAsnWhois.json.gz") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbAsnWhoisStatus.swift b/examples/swift/DbAsnWhoisStatus.swift index 9813d68..81375f8 100644 --- a/examples/swift/DbAsnWhoisStatus.swift +++ b/examples/swift/DbAsnWhoisStatus.swift @@ -1,14 +1,24 @@ -// Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) +// ASN WHOIS Snapshot Status +// // Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesASNWHOISAPI.dbAsnWhoisStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbDnsDaily.swift b/examples/swift/DbDnsDaily.swift index c03cba3..3bf19c3 100644 --- a/examples/swift/DbDnsDaily.swift +++ b/examples/swift/DbDnsDaily.swift @@ -1,15 +1,28 @@ -// Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) +// DNS Database Daily +// // Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesDNSAPI.dbDnsDaily(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesDNSAPI.dbDnsDaily(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDnsDaily.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbDnsMonthly.swift b/examples/swift/DbDnsMonthly.swift index 36b6f3b..2901401 100644 --- a/examples/swift/DbDnsMonthly.swift +++ b/examples/swift/DbDnsMonthly.swift @@ -1,15 +1,28 @@ -// Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) +// DNS Database Monthly +// // Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesDNSAPI.dbDnsMonthly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesDNSAPI.dbDnsMonthly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDnsMonthly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbDnsWeekly.swift b/examples/swift/DbDnsWeekly.swift index 5f4b93a..cbf25c6 100644 --- a/examples/swift/DbDnsWeekly.swift +++ b/examples/swift/DbDnsWeekly.swift @@ -1,15 +1,28 @@ -// Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) +// DNS Database Weekly +// // Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesDNSAPI.dbDnsWeekly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesDNSAPI.dbDnsWeekly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDnsWeekly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbDropped.swift b/examples/swift/DbDropped.swift index 0da2e9f..1031edb 100644 --- a/examples/swift/DbDropped.swift +++ b/examples/swift/DbDropped.swift @@ -1,16 +1,29 @@ -// Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) +// Dropped Domains +// // Parameters for dbDropped (GET /v3.1/download/domainer/dropped): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbDropped(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesExpiringDroppedAPI.dbDropped(whois: true, date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDropped.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbDroppedBacklinks.swift b/examples/swift/DbDroppedBacklinks.swift index 2c0ac7b..882447e 100644 --- a/examples/swift/DbDroppedBacklinks.swift +++ b/examples/swift/DbDroppedBacklinks.swift @@ -1,16 +1,29 @@ -// Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) +// Dropped With Backlinks +// // Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): // - whois (boolean, optional) // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbDroppedBacklinks(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesExpiringDroppedAPI.dbDroppedBacklinks(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbDroppedBacklinks.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbDroppedJson.swift b/examples/swift/DbDroppedJson.swift index 7e6aef7..7350248 100644 --- a/examples/swift/DbDroppedJson.swift +++ b/examples/swift/DbDroppedJson.swift @@ -1,16 +1,25 @@ -// Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) +// Dropped Domains (JSON) +// // Parameters for dbDroppedJson (GET /v3.1/domains/dropped): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbDroppedJson(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let domains = try await DatabasesExpiringDroppedAPI.dbDroppedJson(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + print(domains.joined(separator: "\n")) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbExpired.swift b/examples/swift/DbExpired.swift index 51669ba..980a0f0 100644 --- a/examples/swift/DbExpired.swift +++ b/examples/swift/DbExpired.swift @@ -1,16 +1,29 @@ -// Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) +// Expiring Domains +// // Parameters for dbExpired (GET /v3.1/download/domainer/expired): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbExpired(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesExpiringDroppedAPI.dbExpired(whois: true, date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbExpired.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbExpiredCleaned.swift b/examples/swift/DbExpiredCleaned.swift index 963398c..e6c0c28 100644 --- a/examples/swift/DbExpiredCleaned.swift +++ b/examples/swift/DbExpiredCleaned.swift @@ -1,15 +1,28 @@ -// Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) +// Expiring Cleaned WHOIS +// // Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesExpiringDroppedAPI.dbExpiredCleaned(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesExpiringDroppedAPI.dbExpiredCleaned(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbExpiredCleaned.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbIpCity.swift b/examples/swift/DbIpCity.swift index ae168ba..7931272 100644 --- a/examples/swift/DbIpCity.swift +++ b/examples/swift/DbIpCity.swift @@ -1,15 +1,28 @@ -// Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) +// IP to City Snapshot +// // Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesIPGeolocationAPI.dbIpCity(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesIPGeolocationAPI.dbIpCity(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbIpCity.zip") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbIpCityStatus.swift b/examples/swift/DbIpCityStatus.swift index 0ce43d2..bd9dfcd 100644 --- a/examples/swift/DbIpCityStatus.swift +++ b/examples/swift/DbIpCityStatus.swift @@ -1,14 +1,24 @@ -// Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) +// IP to City Snapshot Status +// // Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesIPGeolocationAPI.dbIpCityStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbIpCountry.swift b/examples/swift/DbIpCountry.swift index e6cc4fb..6dff5a8 100644 --- a/examples/swift/DbIpCountry.swift +++ b/examples/swift/DbIpCountry.swift @@ -1,15 +1,28 @@ -// Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) +// IP to Country Snapshot +// // Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesIPGeolocationAPI.dbIpCountry(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesIPGeolocationAPI.dbIpCountry(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbIpCountry.zip") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbIpCountryStatus.swift b/examples/swift/DbIpCountryStatus.swift index f131db9..7798557 100644 --- a/examples/swift/DbIpCountryStatus.swift +++ b/examples/swift/DbIpCountryStatus.swift @@ -1,14 +1,24 @@ -// Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) +// IP to Country Snapshot Status +// // Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesIPGeolocationAPI.dbIpCountryStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbIpSecurity.swift b/examples/swift/DbIpSecurity.swift index 6529e43..70a3881 100644 --- a/examples/swift/DbIpSecurity.swift +++ b/examples/swift/DbIpSecurity.swift @@ -1,15 +1,28 @@ -// Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) +// IP Security Snapshot +// // Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesIPSecurityAPI.dbIpSecurity(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesIPSecurityAPI.dbIpSecurity(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbIpSecurity.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbIpSecurityStatus.swift b/examples/swift/DbIpSecurityStatus.swift index f9db0fd..bb850da 100644 --- a/examples/swift/DbIpSecurityStatus.swift +++ b/examples/swift/DbIpSecurityStatus.swift @@ -1,14 +1,24 @@ -// Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) +// IP Security Snapshot Status +// // Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesIPSecurityAPI.dbIpSecurityStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbIpWhois.swift b/examples/swift/DbIpWhois.swift index c0b3669..9f59a70 100644 --- a/examples/swift/DbIpWhois.swift +++ b/examples/swift/DbIpWhois.swift @@ -1,15 +1,28 @@ -// Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) +// IP WHOIS Snapshot +// // Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): // - date (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesIPWHOISAPI.dbIpWhois(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesIPWHOISAPI.dbIpWhois(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbIpWhois.json.gz") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbIpWhoisStatus.swift b/examples/swift/DbIpWhoisStatus.swift index e4d6944..af1f7e6 100644 --- a/examples/swift/DbIpWhoisStatus.swift +++ b/examples/swift/DbIpWhoisStatus.swift @@ -1,14 +1,24 @@ -// Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) +// IP WHOIS Snapshot Status +// // Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await DatabasesIPWHOISAPI.dbIpWhoisStatus() - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbNewlyCctld.swift b/examples/swift/DbNewlyCctld.swift index cd60819..de3d5b3 100644 --- a/examples/swift/DbNewlyCctld.swift +++ b/examples/swift/DbNewlyCctld.swift @@ -1,17 +1,30 @@ -// Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) +// Newly Registered ccTLD (CSV) +// // Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyCctld(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyCctld(whois: true, date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyCctld.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbNewlyCctldCleaned.swift b/examples/swift/DbNewlyCctldCleaned.swift index cbfa7f2..a02c421 100644 --- a/examples/swift/DbNewlyCctldCleaned.swift +++ b/examples/swift/DbNewlyCctldCleaned.swift @@ -1,15 +1,28 @@ -// Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) +// Newly Registered ccTLD Cleaned WHOIS (CSV) +// // Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyCctldCleaned(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyCctldCleaned(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyCctldCleaned.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbNewlyCctldJson.swift b/examples/swift/DbNewlyCctldJson.swift index ac206cb..f0b875c 100644 --- a/examples/swift/DbNewlyCctldJson.swift +++ b/examples/swift/DbNewlyCctldJson.swift @@ -1,16 +1,25 @@ -// Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) +// Newly Registered ccTLD (JSON) +// // Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyCctldJson(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let domains = try await DatabasesNewlyRegisteredAPI.dbNewlyCctldJson(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + print(domains.joined(separator: "\n")) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbNewlyDns.swift b/examples/swift/DbNewlyDns.swift index c1b11f4..4639ed1 100644 --- a/examples/swift/DbNewlyDns.swift +++ b/examples/swift/DbNewlyDns.swift @@ -1,15 +1,28 @@ -// Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) +// Newly Registered With DNS +// // Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyDns(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyDns(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyDns.json") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbNewlyGtld.swift b/examples/swift/DbNewlyGtld.swift index 48cf61e..b92bd67 100644 --- a/examples/swift/DbNewlyGtld.swift +++ b/examples/swift/DbNewlyGtld.swift @@ -1,17 +1,30 @@ -// Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) +// Newly Registered gTLD (CSV) +// // Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): // - whois (boolean, required) // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyGtld(whois: false, date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyGtld(whois: true, date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyGtld.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbNewlyGtldCleaned.swift b/examples/swift/DbNewlyGtldCleaned.swift index 94a1a14..4d516bf 100644 --- a/examples/swift/DbNewlyGtldCleaned.swift +++ b/examples/swift/DbNewlyGtldCleaned.swift @@ -1,15 +1,28 @@ -// Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) +// Newly Registered gTLD Cleaned WHOIS (CSV) +// // Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyGtldCleaned(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesNewlyRegisteredAPI.dbNewlyGtldCleaned(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbNewlyGtldCleaned.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbNewlyGtldJson.swift b/examples/swift/DbNewlyGtldJson.swift index 72eceef..b10fa9e 100644 --- a/examples/swift/DbNewlyGtldJson.swift +++ b/examples/swift/DbNewlyGtldJson.swift @@ -1,16 +1,25 @@ -// Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) +// Newly Registered gTLD (JSON) +// // Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): // - date (string, optional): yyyy-MM-dd; omit for latest // - tlds (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesNewlyRegisteredAPI.dbNewlyGtldJson(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10)), tlds: nil) - print(result) + let domains = try await DatabasesNewlyRegisteredAPI.dbNewlyGtldJson(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + print(domains.joined(separator: "\n")) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbSubdomainsDaily.swift b/examples/swift/DbSubdomainsDaily.swift index 85cf6a6..2420a49 100644 --- a/examples/swift/DbSubdomainsDaily.swift +++ b/examples/swift/DbSubdomainsDaily.swift @@ -1,15 +1,28 @@ -// Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) +// Subdomains Daily +// // Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesSubdomainsAPI.dbSubdomainsDaily(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesSubdomainsAPI.dbSubdomainsDaily(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbSubdomainsDaily.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbSubdomainsMonthly.swift b/examples/swift/DbSubdomainsMonthly.swift index f7bbd46..f2e01ad 100644 --- a/examples/swift/DbSubdomainsMonthly.swift +++ b/examples/swift/DbSubdomainsMonthly.swift @@ -1,15 +1,28 @@ -// Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) +// Subdomains Monthly +// // Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesSubdomainsAPI.dbSubdomainsMonthly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesSubdomainsAPI.dbSubdomainsMonthly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbSubdomainsMonthly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbSubdomainsWeekly.swift b/examples/swift/DbSubdomainsWeekly.swift index ea5be6f..afda578 100644 --- a/examples/swift/DbSubdomainsWeekly.swift +++ b/examples/swift/DbSubdomainsWeekly.swift @@ -1,15 +1,28 @@ -// Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) +// Subdomains Weekly +// // Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesSubdomainsAPI.dbSubdomainsWeekly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesSubdomainsAPI.dbSubdomainsWeekly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbSubdomainsWeekly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbWhoisDaily.swift b/examples/swift/DbWhoisDaily.swift index c70b8e7..344cac0 100644 --- a/examples/swift/DbWhoisDaily.swift +++ b/examples/swift/DbWhoisDaily.swift @@ -1,15 +1,28 @@ -// Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) +// WHOIS Database Daily +// // Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesWHOISAPI.dbWhoisDaily(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesWHOISAPI.dbWhoisDaily(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbWhoisDaily.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbWhoisMonthly.swift b/examples/swift/DbWhoisMonthly.swift index 178f758..36378d8 100644 --- a/examples/swift/DbWhoisMonthly.swift +++ b/examples/swift/DbWhoisMonthly.swift @@ -1,15 +1,28 @@ -// Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) +// WHOIS Database Monthly +// // Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesWHOISAPI.dbWhoisMonthly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesWHOISAPI.dbWhoisMonthly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbWhoisMonthly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DbWhoisWeekly.swift b/examples/swift/DbWhoisWeekly.swift index 0d35d5f..e479267 100644 --- a/examples/swift/DbWhoisWeekly.swift +++ b/examples/swift/DbWhoisWeekly.swift @@ -1,15 +1,28 @@ -// Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) +// WHOIS Database Weekly +// // Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): // - date (string, optional): yyyy-MM-dd; omit for latest +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesWHOISAPI.dbWhoisWeekly(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesWHOISAPI.dbWhoisWeekly(date: OpenAPIDateWithoutTime(rawValue: "2026-10-01")!) + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DbWhoisWeekly.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DnsBulk.swift b/examples/swift/DnsBulk.swift index 10419be..c2e5cc5 100644 --- a/examples/swift/DnsBulk.swift +++ b/examples/swift/DnsBulk.swift @@ -1,16 +1,28 @@ -// Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) +// Bulk DNS Lookup +// // Parameters for dnsBulk (POST /v2.0/dns/bulk/live): // - type (string, required) // - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object +// - body: DnsBulkRequest (required): request body object +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] + +let request = DnsBulkRequest(domainNames: ["whoisfreaks.com", "example.com"]) do { - let result = try await DNSAPI.dnsBulk(type: "value", dnsBulkRequest: DnsBulkRequest(), format: nil) - print(result) + let result = try await DNSAPI.dnsBulk(type: "A,MX,TXT", dnsBulkRequest: request) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DnsHistorical.swift b/examples/swift/DnsHistorical.swift index 2ad907e..f07c469 100644 --- a/examples/swift/DnsHistorical.swift +++ b/examples/swift/DnsHistorical.swift @@ -1,17 +1,27 @@ -// Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) +// Historical DNS Lookup +// // Parameters for dnsHistorical (GET /v2.0/dns/historical): // - domainName (string, required) // - type (string, required) // - page (integer, optional) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DNSAPI.dnsHistorical(domainName: "example.com", type: "value", page: nil, format: nil) - print(result) + let result = try await DNSAPI.dnsHistorical(domainName: "whoisfreaks.com", type: "A,MX,TXT", page: 1) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DnsLive.swift b/examples/swift/DnsLive.swift index afd1b1e..01655e7 100644 --- a/examples/swift/DnsLive.swift +++ b/examples/swift/DnsLive.swift @@ -1,17 +1,27 @@ -// Runnable example: Live DNS Lookup (GET /v2.0/dns/live) +// Live DNS Lookup +// // Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups +// - domainName (string, optional) +// - ipAddress (string, optional): Use for PTR lookups // - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DNSAPI.dnsLive(domainName: "example.com", ipAddress: "8.8.8.8", type: "value", format: nil) - print(result) + let result = try await DNSAPI.dnsLive(type: "A,MX,TXT", domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DnsReverse.swift b/examples/swift/DnsReverse.swift index 60c3467..1f5cb92 100644 --- a/examples/swift/DnsReverse.swift +++ b/examples/swift/DnsReverse.swift @@ -1,18 +1,28 @@ -// Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) +// Reverse DNS Lookup +// // Parameters for dnsReverse (GET /v2.1/dns/reverse): // - value (string, required): IP, CIDR, or record value // - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) // - exact (boolean, optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DNSAPI.dnsReverse(value: "value", type: "a", exact: true, page: nil, format: nil) - print(result) + let result = try await DNSAPI.dnsReverse(value: "8.8.8.8", type: .a, page: 1) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DomainAvailabilityV2.swift b/examples/swift/DomainAvailabilityV2.swift index 2d88f28..9f6e10b 100644 --- a/examples/swift/DomainAvailabilityV2.swift +++ b/examples/swift/DomainAvailabilityV2.swift @@ -1,17 +1,27 @@ -// Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) +// Domain Availability Check with Suggestions +// // Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): // - domain (string, required): The domain name to check // - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. // - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DomainAvailabilityAPI.domainAvailabilityV2(domain: "example.com", sug: nil, count: nil, format: nil) - print(result) + let result = try await DomainAvailabilityAPI.domainAvailabilityV2(domain: "google.com", sug: true, count: 5) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DomainReputation.swift b/examples/swift/DomainReputation.swift index 28c419c..1adc972 100644 --- a/examples/swift/DomainReputation.swift +++ b/examples/swift/DomainReputation.swift @@ -1,15 +1,25 @@ -// Runnable example: Domain Reputation Lookup (GET /v1/domain/security) +// Domain Reputation Lookup +// // Parameters for domainReputation (GET /v1/domain/security): // - domainName (string, required): The domain name to assess // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DomainReputationAPI.domainReputation(domainName: "example.com", format: nil) - print(result) + let result = try await DomainReputationAPI.domainReputation(domainName: "amazon.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DownloadThreatFeedMalware.swift b/examples/swift/DownloadThreatFeedMalware.swift index 56318d5..45d491e 100644 --- a/examples/swift/DownloadThreatFeedMalware.swift +++ b/examples/swift/DownloadThreatFeedMalware.swift @@ -1,15 +1,28 @@ -// Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) +// Download the daily malware threat feed (CSV) +// // Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedMalware(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedMalware(date: "2026-10-01") + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedMalware.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DownloadThreatFeedMalwareSample.swift b/examples/swift/DownloadThreatFeedMalwareSample.swift index a774fe6..3b72df3 100644 --- a/examples/swift/DownloadThreatFeedMalwareSample.swift +++ b/examples/swift/DownloadThreatFeedMalwareSample.swift @@ -1,14 +1,28 @@ -// Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) +// Download a sample of the malware threat feed (CSV) +// // Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedMalwareSample() - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedMalwareSample() + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedMalwareSample.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DownloadThreatFeedPhishing.swift b/examples/swift/DownloadThreatFeedPhishing.swift index b6a6ce7..98a4ecd 100644 --- a/examples/swift/DownloadThreatFeedPhishing.swift +++ b/examples/swift/DownloadThreatFeedPhishing.swift @@ -1,15 +1,28 @@ -// Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) +// Download the daily phishing threat feed (CSV) +// // Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedPhishing(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedPhishing(date: "2026-10-01") + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedPhishing.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DownloadThreatFeedPhishingSample.swift b/examples/swift/DownloadThreatFeedPhishingSample.swift index b514f6b..66d9945 100644 --- a/examples/swift/DownloadThreatFeedPhishingSample.swift +++ b/examples/swift/DownloadThreatFeedPhishingSample.swift @@ -1,14 +1,28 @@ -// Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) +// Download a sample of the phishing threat feed (CSV) +// // Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedPhishingSample() - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedPhishingSample() + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedPhishingSample.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DownloadThreatFeedSpam.swift b/examples/swift/DownloadThreatFeedSpam.swift index 70fe784..e94f0ae 100644 --- a/examples/swift/DownloadThreatFeedSpam.swift +++ b/examples/swift/DownloadThreatFeedSpam.swift @@ -1,15 +1,28 @@ -// Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) +// Download the daily spam threat feed (CSV) +// // Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available +// - date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedSpam(date: String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))) - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedSpam(date: "2026-10-01") + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedSpam.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/DownloadThreatFeedSpamSample.swift b/examples/swift/DownloadThreatFeedSpamSample.swift index 27a4bf8..866b9ac 100644 --- a/examples/swift/DownloadThreatFeedSpamSample.swift +++ b/examples/swift/DownloadThreatFeedSpamSample.swift @@ -1,14 +1,28 @@ -// Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) +// Download a sample of the spam threat feed (CSV) +// // Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await DatabasesThreatFeedAPI.downloadThreatFeedSpamSample() - print(result) + let file = try await DatabasesThreatFeedAPI.downloadThreatFeedSpamSample() + // The SDK saves the download under the caches directory: move it somewhere permanent. + let saveAs = URL(fileURLWithPath: "DownloadThreatFeedSpamSample.csv") + try? FileManager.default.removeItem(at: saveAs) + try FileManager.default.moveItem(at: file, to: saveAs) + print("Saved \(saveAs.path)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/Geolocation.swift b/examples/swift/Geolocation.swift index d5fab4d..9caec53 100644 --- a/examples/swift/Geolocation.swift +++ b/examples/swift/Geolocation.swift @@ -1,14 +1,24 @@ -// Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) +// IP Geolocation Lookup +// // Parameters for geolocation (GET /v1.0/geolocation): // - ip (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await GeolocationAPI.geolocation(ip: "8.8.8.8") - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/IpReputation.swift b/examples/swift/IpReputation.swift index 02b7c5d..4484c05 100644 --- a/examples/swift/IpReputation.swift +++ b/examples/swift/IpReputation.swift @@ -1,14 +1,24 @@ -// Runnable example: IP Reputation Lookup (GET /v1.0/security) +// IP Reputation Lookup +// // Parameters for ipReputation (GET /v1.0/security): // - ip (string, required) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { let result = try await IPReputationAPI.ipReputation(ip: "8.8.8.8") - print(result) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/IpWhois.swift b/examples/swift/IpWhois.swift index 1062a84..21bcdd0 100644 --- a/examples/swift/IpWhois.swift +++ b/examples/swift/IpWhois.swift @@ -1,15 +1,25 @@ -// Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) +// IP WHOIS Lookup +// // Parameters for ipWhois (GET /v1.0/ip-whois): // - ip (string, required) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await IPWHOISAPI.ipWhois(ip: "8.8.8.8", format: nil) - print(result) + let result = try await IPWHOISAPI.ipWhois(ip: "8.8.8.8") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/README.md b/examples/swift/README.md index a42d9f4..f99606f 100644 --- a/examples/swift/README.md +++ b/examples/swift/README.md @@ -1,107 +1,107 @@ -# Swift — Runnable Examples +# Swift Runnable Examples -Install: see the [Swift guide](../../docs/languages/swift.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [Swift guide](../../docs/languages/swift.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.swift`](WhoisLive.swift) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.swift`](BulkWhois.swift) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.swift`](WhoisHistory.swift) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.swift`](WhoisReverse.swift) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.swift`](WhoisLive.swift): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.swift`](BulkWhois.swift): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.swift`](WhoisHistory.swift): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.swift`](WhoisReverse.swift): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.swift`](DnsLive.swift) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.swift`](DnsHistorical.swift) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.swift`](DnsReverse.swift) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.swift`](DnsBulk.swift) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.swift`](DnsLive.swift): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.swift`](DnsHistorical.swift): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.swift`](DnsReverse.swift): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.swift`](DnsBulk.swift): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.swift`](DomainAvailabilityV2.swift) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.swift`](BulkDomainAvailabilityV2.swift) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.swift`](DomainAvailabilityV2.swift): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.swift`](BulkDomainAvailabilityV2.swift): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.swift`](Typosquatting.swift) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.swift`](Typosquatting.swift): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.swift`](SslLookup.swift) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.swift`](SslLookup.swift): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.swift`](Geolocation.swift) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.swift`](BulkGeolocation.swift) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.swift`](Geolocation.swift): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.swift`](BulkGeolocation.swift): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.swift`](Subdomains.swift) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.swift`](Subdomains.swift): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.swift`](IpReputation.swift) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.swift`](BulkIpReputation.swift) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.swift`](IpReputation.swift): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.swift`](BulkIpReputation.swift): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.swift`](DomainReputation.swift) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.swift`](DomainReputation.swift): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.swift`](AsnWhois.swift) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.swift`](AsnWhois.swift): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.swift`](IpWhois.swift) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.swift`](IpWhois.swift): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.swift`](RotateApiKey.swift) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.swift`](AccountUsage.swift) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.swift`](DatabaseFileStatus.swift) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.swift`](RotateApiKey.swift): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.swift`](AccountUsage.swift): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.swift`](DatabaseFileStatus.swift): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.swift`](DbNewlyGtld.swift) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.swift`](DbNewlyCctld.swift) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.swift`](DbNewlyGtldCleaned.swift) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.swift`](DbNewlyCctldCleaned.swift) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.swift`](DbNewlyGtldJson.swift) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.swift`](DbNewlyCctldJson.swift) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.swift`](DbNewlyDns.swift) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.swift`](DbNewlyGtld.swift): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.swift`](DbNewlyCctld.swift): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.swift`](DbNewlyGtldCleaned.swift): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.swift`](DbNewlyCctldCleaned.swift): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.swift`](DbNewlyGtldJson.swift): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.swift`](DbNewlyCctldJson.swift): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.swift`](DbNewlyDns.swift): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.swift`](DbExpired.swift) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.swift`](DbExpiredCleaned.swift) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.swift`](DbDropped.swift) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.swift`](DbDroppedJson.swift) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.swift`](DbDroppedBacklinks.swift) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.swift`](DbExpired.swift): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.swift`](DbExpiredCleaned.swift): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.swift`](DbDropped.swift): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.swift`](DbDroppedJson.swift): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.swift`](DbDroppedBacklinks.swift): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.swift`](DbWhoisDaily.swift) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.swift`](DbWhoisWeekly.swift) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.swift`](DbWhoisMonthly.swift) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.swift`](DbWhoisDaily.swift): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.swift`](DbWhoisWeekly.swift): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.swift`](DbWhoisMonthly.swift): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.swift`](DbDnsDaily.swift) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.swift`](DbDnsWeekly.swift) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.swift`](DbDnsMonthly.swift) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.swift`](DbDnsDaily.swift): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.swift`](DbDnsWeekly.swift): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.swift`](DbDnsMonthly.swift): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.swift`](DbSubdomainsDaily.swift) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.swift`](DbSubdomainsWeekly.swift) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.swift`](DbSubdomainsMonthly.swift) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.swift`](DbSubdomainsDaily.swift): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.swift`](DbSubdomainsWeekly.swift): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.swift`](DbSubdomainsMonthly.swift): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.swift`](DbIpCountryStatus.swift) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.swift`](DbIpCountry.swift) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.swift`](DbIpCityStatus.swift) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.swift`](DbIpCity.swift) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.swift`](DbIpCountryStatus.swift): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.swift`](DbIpCountry.swift): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.swift`](DbIpCityStatus.swift): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.swift`](DbIpCity.swift): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.swift`](DbAsnWhois.swift) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.swift`](DbAsnWhoisStatus.swift) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.swift`](DbAsnWhois.swift): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.swift`](DbAsnWhoisStatus.swift): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.swift`](DbIpWhois.swift) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.swift`](DbIpWhoisStatus.swift) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.swift`](DbIpWhois.swift): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.swift`](DbIpWhoisStatus.swift): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.swift`](DbIpSecurity.swift) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.swift`](DbIpSecurityStatus.swift) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.swift`](DbIpSecurity.swift): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.swift`](DbIpSecurityStatus.swift): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.swift`](DownloadThreatFeedPhishing.swift) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.swift`](DownloadThreatFeedPhishingSample.swift) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.swift`](DownloadThreatFeedMalware.swift) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.swift`](DownloadThreatFeedMalwareSample.swift) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.swift`](DownloadThreatFeedSpam.swift) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.swift`](DownloadThreatFeedSpamSample.swift) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.swift`](DownloadThreatFeedPhishing.swift): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.swift`](DownloadThreatFeedPhishingSample.swift): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.swift`](DownloadThreatFeedMalware.swift): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.swift`](DownloadThreatFeedMalwareSample.swift): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.swift`](DownloadThreatFeedSpam.swift): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.swift`](DownloadThreatFeedSpamSample.swift): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/swift/RotateApiKey.swift b/examples/swift/RotateApiKey.swift index 16fd80f..bc192c5 100644 --- a/examples/swift/RotateApiKey.swift +++ b/examples/swift/RotateApiKey.swift @@ -1,14 +1,25 @@ -// Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) +// Rotate API Key +// // Parameters for rotateApiKey (GET /v1.0/api-key/rotate): // (no parameters; the API key is set on the client) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await AccountAPI.rotateApiKey() - print(result) + let newKey = try await AccountAPI.rotateApiKey() + // The old key stops working now: store the new one before making more calls. + print("New API key: \(newKey)") +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/SslLookup.swift b/examples/swift/SslLookup.swift index b4f9109..79540d1 100644 --- a/examples/swift/SslLookup.swift +++ b/examples/swift/SslLookup.swift @@ -1,17 +1,27 @@ -// Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) +// SSL Certificate Lookup +// // Parameters for sslLookup (GET /v1.0/ssl/live): // - domainName (string, required) // - chain (boolean, optional) // - sslRaw (boolean, optional) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await SSLAPI.sslLookup(domainName: "example.com", chain: nil, sslRaw: nil, format: nil) - print(result) + let result = try await SSLAPI.sslLookup(domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/Subdomains.swift b/examples/swift/Subdomains.swift index fc5a9f3..7a18864 100644 --- a/examples/swift/Subdomains.swift +++ b/examples/swift/Subdomains.swift @@ -1,4 +1,5 @@ -// Runnable example: Subdomains Lookup (GET /v1.0/subdomains) +// Subdomains Lookup +// // Parameters for subdomains (GET /v1.0/subdomains): // - domain (string, required) // - after (string, optional) @@ -6,15 +7,23 @@ // - status (string (one of: active, inactive), optional) // - page (integer, optional) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await SubdomainsAPI.subdomains(domain: "example.com", after: "2000-01-01", before: String(ISO8601DateFormatter().string(from: Date()).prefix(10)), status: nil, page: nil, format: nil) - print(result) + let result = try await SubdomainsAPI.subdomains(domain: "whoisfreaks.com", page: 1) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/Typosquatting.swift b/examples/swift/Typosquatting.swift index bf69e86..f09ba4f 100644 --- a/examples/swift/Typosquatting.swift +++ b/examples/swift/Typosquatting.swift @@ -1,16 +1,26 @@ -// Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) +// Typosquatting Lookup +// // Parameters for typosquatting (GET /v3.0/domain/typos): // - keyword (string, optional) // - pattern (string, optional) // - pageToken (string, optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await TyposquattingAPI.typosquatting(keyword: nil, pattern: nil, pageToken: nil) - print(result) + let result = try await TyposquattingAPI.typosquatting(keyword: "whoisfreaks") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/WhoisHistoricalOrReverse.swift b/examples/swift/WhoisHistoricalOrReverse.swift deleted file mode 100644 index 8b688a6..0000000 --- a/examples/swift/WhoisHistoricalOrReverse.swift +++ /dev/null @@ -1,21 +0,0 @@ -// Runnable example: WHOIS Historical or Reverse Lookup (GET /v1.0/whois) -// Parameters for whoisHistoricalOrReverse (GET /v1.0/whois): -// - apiKey (string, required): Your WHOISFreaks API key -// - whois (string (one of: historical, reverse), required) -// - domainName (string, required): Required for historical lookup -// - keyword (string, optional): For reverse — domain keyword search -// - email (string, optional): For reverse — registrant email search -// - owner (string, optional): For reverse — registrant name search -// - company (string, optional): For reverse — company name search -// - mode (string (one of: default, mini), optional) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import WhoisFreaks - -do { - let result = try await WHOISAPI.whoisHistoricalOrReverse(apiKey: "YOUR_API_KEY", whois: "historical", domainName: "example.com", exact: true, keyword: nil, email: nil, owner: nil, company: nil, mode: nil, page: nil, format: nil) - print(result) -} catch { - print(error) -} diff --git a/examples/swift/WhoisHistory.swift b/examples/swift/WhoisHistory.swift index 65309f6..912501d 100644 --- a/examples/swift/WhoisHistory.swift +++ b/examples/swift/WhoisHistory.swift @@ -1,16 +1,25 @@ -// Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) +// Historical WHOIS records for a domain +// // Parameters for whoisHistory (GET /v2.0/whois/history): // - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await WHOISAPI.whoisHistory(domainName: "example.com", page: nil, format: nil) - print(result) + let result = try await WHOISAPI.whoisHistory(domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/WhoisLive.swift b/examples/swift/WhoisLive.swift index c2acacc..db02cc2 100644 --- a/examples/swift/WhoisLive.swift +++ b/examples/swift/WhoisLive.swift @@ -1,15 +1,25 @@ -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) +// Live WHOIS Lookup +// // Parameters for whoisLive (GET /v2.0/whois/live): // - domainName (string, required) // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await WHOISAPI.whoisLive(domainName: "example.com", format: nil) - print(result) + let result = try await WHOISAPI.whoisLive(domainName: "whoisfreaks.com") + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/swift/WhoisReverse.swift b/examples/swift/WhoisReverse.swift index c0608fe..dfea7bb 100644 --- a/examples/swift/WhoisReverse.swift +++ b/examples/swift/WhoisReverse.swift @@ -1,16 +1,26 @@ -// Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) +// Reverse WHOIS lookup by keyword +// // Parameters for whoisReverse (GET /v2.0/whois/reverse): // - keyword (string, required): Keyword to search across WHOIS records // - page (integer, optional): Page number // - format (string (one of: json, xml), optional) +// +// Top-level code for Sources//main.swift (see Getting Started). + +import Foundation import WhoisFreaks -// Set your API key once (applied to every request) -WhoisFreaksAPI.apiKey = "YOUR_API_KEY" +// Read the API key from the environment and set it once. +WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"] do { - let result = try await WHOISAPI.whoisReverse(keyword: "value", page: nil, format: nil) - print(result) + let result = try await WHOISAPI.whoisReverse(keyword: "whoisfreaks", page: 1) + print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self)) +} catch ErrorResponse.error(let status, let data, _, let underlying) { + let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\(underlying)" + print("Request failed: HTTP \(status) \(body)") + exit(1) } catch { - print(error) + print("Request failed: \(error)") + exit(1) } diff --git a/examples/typescript/AccountUsage.ts b/examples/typescript/AccountUsage.ts index d8699cd..97bdc78 100644 --- a/examples/typescript/AccountUsage.ts +++ b/examples/typescript/AccountUsage.ts @@ -1,13 +1,23 @@ -// Runnable example: Account Usage (GET /v1.0/whoisapi/usage) -// Parameters for accountUsage (GET /v1.0/whoisapi/usage): -// (no parameters; the API key is set on the client) -import { Configuration, AccountApi } from "whoisfreaks"; +// Account Usage: GET https://api.whoisfreaks.com/v1.0/whoisapi/usage +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx AccountUsage.ts +import { Configuration, AccountApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new AccountApi(config); -async function main() { - const result = await api.accountUsage({ }); - console.log(result); +// accountUsage() takes no parameters. +async function main(): Promise { + const result = await api.accountUsage(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/AsnWhois.ts b/examples/typescript/AsnWhois.ts index 2ee8dea..f89b1c3 100644 --- a/examples/typescript/AsnWhois.ts +++ b/examples/typescript/AsnWhois.ts @@ -1,14 +1,25 @@ -// Runnable example: ASN WHOIS Lookup (GET /v2.0/asn-whois) -// Parameters for asnWhois (GET /v2.0/asn-whois): -// - asn (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, ASNWHOISApi } from "whoisfreaks"; +// ASN WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/asn-whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx AsnWhois.ts +import { Configuration, ASNWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new ASNWHOISApi(config); -async function main() { - const result = await api.asnWhois({ asn: "AS15169", format: undefined }); - console.log(result); +// asnWhois({ asn, format? }) +// asn (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.asnWhois({ asn: "as15169" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/BulkDomainAvailabilityV2.ts b/examples/typescript/BulkDomainAvailabilityV2.ts index 4d2fd12..f18db34 100644 --- a/examples/typescript/BulkDomainAvailabilityV2.ts +++ b/examples/typescript/BulkDomainAvailabilityV2.ts @@ -1,15 +1,27 @@ -// Runnable example: Bulk Domain Availability Check (POST /v2.0/domain/availability) -// Parameters for bulkDomainAvailabilityV2 (POST /v2.0/domain/availability): -// - domain (string, optional): Required for TLD-mode bulk check (base domain). -// - format (string (one of: json, xml), optional) -// - body: BulkDomainAvailabilityRequest (required) -- request body object -import { Configuration, DomainAvailabilityApi } from "whoisfreaks"; +// Bulk Domain Availability Check: POST https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkDomainAvailabilityV2.ts +import { Configuration, DomainAvailabilityApi, ResponseError, type BulkDomainAvailabilityRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DomainAvailabilityApi(config); -async function main() { - const result = await api.bulkDomainAvailabilityV2({ bulkDomainAvailabilityRequest: {}, domain: undefined, format: undefined }); - console.log(result); +// bulkDomainAvailabilityV2({ bulkDomainAvailabilityRequest, domain?, format? }) +// bulkDomainAvailabilityRequest (BulkDomainAvailabilityRequest, required): request body +// domain (string, optional): Required for TLD-mode bulk check (base domain) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const body: BulkDomainAvailabilityRequest = { domainNames: ["whoisfreaks.com", "example.com"] }; + const result = await api.bulkDomainAvailabilityV2({ bulkDomainAvailabilityRequest: body }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/BulkGeolocation.ts b/examples/typescript/BulkGeolocation.ts index 028e98a..31a08c0 100644 --- a/examples/typescript/BulkGeolocation.ts +++ b/examples/typescript/BulkGeolocation.ts @@ -1,13 +1,25 @@ -// Runnable example: Bulk IP Geolocation (POST /v1.0/geolocation) -// Parameters for bulkGeolocation (POST /v1.0/geolocation): -// - body: BulkGeolocationRequest (required) -- request body object -import { Configuration, GeolocationApi } from "whoisfreaks"; +// Bulk IP Geolocation: POST https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkGeolocation.ts +import { Configuration, GeolocationApi, ResponseError, type BulkGeolocationRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new GeolocationApi(config); -async function main() { - const result = await api.bulkGeolocation({ bulkGeolocationRequest: {} }); - console.log(result); +// bulkGeolocation({ bulkGeolocationRequest }) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main(): Promise { + const body: BulkGeolocationRequest = { ips: ["8.8.8.8", "1.1.1.1"] }; + const results = await api.bulkGeolocation({ bulkGeolocationRequest: body }); + console.log(JSON.stringify(results, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/BulkIpReputation.ts b/examples/typescript/BulkIpReputation.ts index 840d5e0..c049cc6 100644 --- a/examples/typescript/BulkIpReputation.ts +++ b/examples/typescript/BulkIpReputation.ts @@ -1,13 +1,25 @@ -// Runnable example: Bulk IP Reputation (POST /v1.0/security) -// Parameters for bulkIpReputation (POST /v1.0/security): -// - body: BulkIpReputationRequest (required) -- request body object -import { Configuration, IPReputationApi } from "whoisfreaks"; +// Bulk IP Reputation: POST https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkIpReputation.ts +import { Configuration, IPReputationApi, ResponseError, type BulkGeolocationRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new IPReputationApi(config); -async function main() { - const result = await api.bulkIpReputation({ bulkIpReputationRequest: {} }); - console.log(result); +// bulkIpReputation({ bulkGeolocationRequest }) +// bulkGeolocationRequest (BulkGeolocationRequest, required): request body +async function main(): Promise { + const body: BulkGeolocationRequest = { ips: ["8.8.8.8", "1.1.1.1"] }; + const results = await api.bulkIpReputation({ bulkGeolocationRequest: body }); + console.log(JSON.stringify(results, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/BulkWhois.ts b/examples/typescript/BulkWhois.ts index 2f92106..9287b88 100644 --- a/examples/typescript/BulkWhois.ts +++ b/examples/typescript/BulkWhois.ts @@ -1,14 +1,26 @@ -// Runnable example: Bulk WHOIS Lookup (POST /v2.0/bulkwhois/live) -// Parameters for bulkWhois (POST /v2.0/bulkwhois/live): -// - format (string (one of: json, xml), optional) -// - body: BulkWhoisRequest (required) -- request body object -import { Configuration, WHOISApi } from "whoisfreaks"; +// Bulk WHOIS Lookup: POST https://api.whoisfreaks.com/v2.0/bulkwhois/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx BulkWhois.ts +import { Configuration, WHOISApi, ResponseError, type BulkWhoisRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.bulkWhois({ bulkWhoisRequest: {}, format: undefined }); - console.log(result); +// bulkWhois({ bulkWhoisRequest, format? }) +// bulkWhoisRequest (BulkWhoisRequest, required): request body +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const body: BulkWhoisRequest = { domainNames: ["whoisfreaks.com", "jfreaks.com"] }; + const result = await api.bulkWhois({ bulkWhoisRequest: body }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DatabaseFileStatus.ts b/examples/typescript/DatabaseFileStatus.ts index 7937d05..413ac82 100644 --- a/examples/typescript/DatabaseFileStatus.ts +++ b/examples/typescript/DatabaseFileStatus.ts @@ -1,13 +1,22 @@ -// Runnable example: Database File Status (Public) (GET /v3.4/status) -// Parameters for databaseFileStatus (GET /v3.4/status): -// (no parameters; the API key is set on the client) -import { Configuration, AccountApi } from "whoisfreaks"; +// Database File Status (Public): GET https://files.whoisfreaks.com/v3.4/status +// Run (public endpoint, no API key needed): npx tsx DatabaseFileStatus.ts +import { AccountApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once -const api = new AccountApi(config); +// Public endpoint: no API key needed. +const api = new AccountApi(); -async function main() { - const result = await api.databaseFileStatus({ }); - console.log(result); +// databaseFileStatus() takes no parameters. +async function main(): Promise { + const result = await api.databaseFileStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbAsnWhois.ts b/examples/typescript/DbAsnWhois.ts index 8b1c03d..50436d5 100644 --- a/examples/typescript/DbAsnWhois.ts +++ b/examples/typescript/DbAsnWhois.ts @@ -1,13 +1,28 @@ -// Runnable example: ASN WHOIS Snapshot (GET /v3.3/download/snapshot/asn/whois) -// Parameters for dbAsnWhois (GET /v3.3/download/snapshot/asn/whois): -// - date (string, required) -import { Configuration, DatabasesASNWHOISApi } from "whoisfreaks"; +// ASN WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbAsnWhois.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesASNWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesASNWHOISApi(config); -async function main() { - const result = await api.dbAsnWhois({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbAsnWhois({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbAsnWhois({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbAsnWhois.json.gz"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbAsnWhoisStatus.ts b/examples/typescript/DbAsnWhoisStatus.ts index 6a979db..5bd151b 100644 --- a/examples/typescript/DbAsnWhoisStatus.ts +++ b/examples/typescript/DbAsnWhoisStatus.ts @@ -1,13 +1,23 @@ -// Runnable example: ASN WHOIS Snapshot Status (GET /v3.3/status/snapshot/asn/whois) -// Parameters for dbAsnWhoisStatus (GET /v3.3/status/snapshot/asn/whois): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesASNWHOISApi } from "whoisfreaks"; +// ASN WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/asn/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbAsnWhoisStatus.ts +import { Configuration, DatabasesASNWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesASNWHOISApi(config); -async function main() { - const result = await api.dbAsnWhoisStatus({ }); - console.log(result); +// dbAsnWhoisStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbAsnWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbDnsDaily.ts b/examples/typescript/DbDnsDaily.ts index c78d372..8f9d50d 100644 --- a/examples/typescript/DbDnsDaily.ts +++ b/examples/typescript/DbDnsDaily.ts @@ -1,13 +1,28 @@ -// Runnable example: DNS Database Daily (GET /v3.2/download/dbupdate/daily/dns) -// Parameters for dbDnsDaily (GET /v3.2/download/dbupdate/daily/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesDNSApi } from "whoisfreaks"; +// DNS Database Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDnsDaily.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesDNSApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesDNSApi(config); -async function main() { - const result = await api.dbDnsDaily({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDnsDaily({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDnsDaily({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDnsDaily.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbDnsMonthly.ts b/examples/typescript/DbDnsMonthly.ts index 7af333b..725d2a0 100644 --- a/examples/typescript/DbDnsMonthly.ts +++ b/examples/typescript/DbDnsMonthly.ts @@ -1,13 +1,28 @@ -// Runnable example: DNS Database Monthly (GET /v3.2/download/dbupdate/monthly/dns) -// Parameters for dbDnsMonthly (GET /v3.2/download/dbupdate/monthly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesDNSApi } from "whoisfreaks"; +// DNS Database Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDnsMonthly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesDNSApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesDNSApi(config); -async function main() { - const result = await api.dbDnsMonthly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDnsMonthly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDnsMonthly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDnsMonthly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbDnsWeekly.ts b/examples/typescript/DbDnsWeekly.ts index e2f0549..5017d23 100644 --- a/examples/typescript/DbDnsWeekly.ts +++ b/examples/typescript/DbDnsWeekly.ts @@ -1,13 +1,28 @@ -// Runnable example: DNS Database Weekly (GET /v3.2/download/dbupdate/weekly/dns) -// Parameters for dbDnsWeekly (GET /v3.2/download/dbupdate/weekly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesDNSApi } from "whoisfreaks"; +// DNS Database Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDnsWeekly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesDNSApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesDNSApi(config); -async function main() { - const result = await api.dbDnsWeekly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDnsWeekly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDnsWeekly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDnsWeekly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbDropped.ts b/examples/typescript/DbDropped.ts index e0e1945..7dd0864 100644 --- a/examples/typescript/DbDropped.ts +++ b/examples/typescript/DbDropped.ts @@ -1,14 +1,29 @@ -// Runnable example: Dropped Domains (GET /v3.1/download/domainer/dropped) -// Parameters for dbDropped (GET /v3.1/download/domainer/dropped): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; +// Dropped Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDropped.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbDropped({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDropped({ whois, date? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDropped({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDropped.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbDroppedBacklinks.ts b/examples/typescript/DbDroppedBacklinks.ts index 63a071f..00ae34f 100644 --- a/examples/typescript/DbDroppedBacklinks.ts +++ b/examples/typescript/DbDroppedBacklinks.ts @@ -1,14 +1,29 @@ -// Runnable example: Dropped With Backlinks (GET /v3.3/download/domainer/dropped/backlinks) -// Parameters for dbDroppedBacklinks (GET /v3.3/download/domainer/dropped/backlinks): -// - whois (boolean, optional) -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; +// Dropped With Backlinks: GET https://files.whoisfreaks.com/v3.3/download/domainer/dropped/backlinks +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDroppedBacklinks.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbDroppedBacklinks({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbDroppedBacklinks({ whois?, date? }) +// whois (boolean, optional) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbDroppedBacklinks({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbDroppedBacklinks.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbDroppedJson.ts b/examples/typescript/DbDroppedJson.ts index 0bcc27a..cc75dcd 100644 --- a/examples/typescript/DbDroppedJson.ts +++ b/examples/typescript/DbDroppedJson.ts @@ -1,14 +1,26 @@ -// Runnable example: Dropped Domains (JSON) (GET /v3.1/domains/dropped) -// Parameters for dbDroppedJson (GET /v3.1/domains/dropped): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; +// Dropped Domains (JSON): GET https://files.whoisfreaks.com/v3.1/domains/dropped +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbDroppedJson.ts +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbDroppedJson({ date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbDroppedJson({ date?, tlds? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const domains = await api.dbDroppedJson({ date: new Date("2026-10-01") }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbExpired.ts b/examples/typescript/DbExpired.ts index a267376..917a07a 100644 --- a/examples/typescript/DbExpired.ts +++ b/examples/typescript/DbExpired.ts @@ -1,14 +1,29 @@ -// Runnable example: Expiring Domains (GET /v3.1/download/domainer/expired) -// Parameters for dbExpired (GET /v3.1/download/domainer/expired): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; +// Expiring Domains: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbExpired.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbExpired({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbExpired({ whois, date? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbExpired({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbExpired.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbExpiredCleaned.ts b/examples/typescript/DbExpiredCleaned.ts index 52de5e4..b8512da 100644 --- a/examples/typescript/DbExpiredCleaned.ts +++ b/examples/typescript/DbExpiredCleaned.ts @@ -1,13 +1,28 @@ -// Runnable example: Expiring Cleaned WHOIS (GET /v3.1/download/domainer/expired/cleaned) -// Parameters for dbExpiredCleaned (GET /v3.1/download/domainer/expired/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesExpiringDroppedApi } from "whoisfreaks"; +// Expiring Cleaned WHOIS: GET https://files.whoisfreaks.com/v3.1/download/domainer/expired/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbExpiredCleaned.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesExpiringDroppedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesExpiringDroppedApi(config); -async function main() { - const result = await api.dbExpiredCleaned({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbExpiredCleaned({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbExpiredCleaned({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbExpiredCleaned.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbIpCity.ts b/examples/typescript/DbIpCity.ts index d1df975..e4f0a34 100644 --- a/examples/typescript/DbIpCity.ts +++ b/examples/typescript/DbIpCity.ts @@ -1,13 +1,28 @@ -// Runnable example: IP to City Snapshot (GET /v3.3/download/snapshot/ip/city) -// Parameters for dbIpCity (GET /v3.3/download/snapshot/ip/city): -// - date (string, required) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; +// IP to City Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCity.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCity({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpCity({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpCity({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpCity.zip"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbIpCityStatus.ts b/examples/typescript/DbIpCityStatus.ts index 4bd2e1c..c5f509a 100644 --- a/examples/typescript/DbIpCityStatus.ts +++ b/examples/typescript/DbIpCityStatus.ts @@ -1,13 +1,23 @@ -// Runnable example: IP to City Snapshot Status (GET /v3.3/status/snapshot/ip/city) -// Parameters for dbIpCityStatus (GET /v3.3/status/snapshot/ip/city): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; +// IP to City Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/city +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCityStatus.ts +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCityStatus({ }); - console.log(result); +// dbIpCityStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpCityStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbIpCountry.ts b/examples/typescript/DbIpCountry.ts index 03be353..ededd25 100644 --- a/examples/typescript/DbIpCountry.ts +++ b/examples/typescript/DbIpCountry.ts @@ -1,13 +1,28 @@ -// Runnable example: IP to Country Snapshot (GET /v3.3/download/snapshot/ip/country) -// Parameters for dbIpCountry (GET /v3.3/download/snapshot/ip/country): -// - date (string, required) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; +// IP to Country Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCountry.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCountry({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpCountry({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpCountry({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpCountry.zip"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbIpCountryStatus.ts b/examples/typescript/DbIpCountryStatus.ts index 9375046..5bc68f3 100644 --- a/examples/typescript/DbIpCountryStatus.ts +++ b/examples/typescript/DbIpCountryStatus.ts @@ -1,13 +1,23 @@ -// Runnable example: IP to Country Snapshot Status (GET /v3.3/status/snapshot/ip/country) -// Parameters for dbIpCountryStatus (GET /v3.3/status/snapshot/ip/country): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPGeolocationApi } from "whoisfreaks"; +// IP to Country Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/country +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpCountryStatus.ts +import { Configuration, DatabasesIPGeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPGeolocationApi(config); -async function main() { - const result = await api.dbIpCountryStatus({ }); - console.log(result); +// dbIpCountryStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpCountryStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbIpSecurity.ts b/examples/typescript/DbIpSecurity.ts index 5bba0ef..bc461f1 100644 --- a/examples/typescript/DbIpSecurity.ts +++ b/examples/typescript/DbIpSecurity.ts @@ -1,13 +1,28 @@ -// Runnable example: IP Security Snapshot (GET /v3.3/download/snapshot/ip/security) -// Parameters for dbIpSecurity (GET /v3.3/download/snapshot/ip/security): -// - date (string, required) -import { Configuration, DatabasesIPSecurityApi } from "whoisfreaks"; +// IP Security Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpSecurity.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPSecurityApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPSecurityApi(config); -async function main() { - const result = await api.dbIpSecurity({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpSecurity({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpSecurity({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpSecurity.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbIpSecurityStatus.ts b/examples/typescript/DbIpSecurityStatus.ts index 9b66111..a04fa0a 100644 --- a/examples/typescript/DbIpSecurityStatus.ts +++ b/examples/typescript/DbIpSecurityStatus.ts @@ -1,13 +1,23 @@ -// Runnable example: IP Security Snapshot Status (GET /v3.3/status/snapshot/ip/security) -// Parameters for dbIpSecurityStatus (GET /v3.3/status/snapshot/ip/security): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPSecurityApi } from "whoisfreaks"; +// IP Security Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpSecurityStatus.ts +import { Configuration, DatabasesIPSecurityApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPSecurityApi(config); -async function main() { - const result = await api.dbIpSecurityStatus({ }); - console.log(result); +// dbIpSecurityStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpSecurityStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbIpWhois.ts b/examples/typescript/DbIpWhois.ts index b3c4a9a..873bc12 100644 --- a/examples/typescript/DbIpWhois.ts +++ b/examples/typescript/DbIpWhois.ts @@ -1,13 +1,28 @@ -// Runnable example: IP WHOIS Snapshot (GET /v3.3/download/snapshot/ip/whois) -// Parameters for dbIpWhois (GET /v3.3/download/snapshot/ip/whois): -// - date (string, required) -import { Configuration, DatabasesIPWHOISApi } from "whoisfreaks"; +// IP WHOIS Snapshot: GET https://files.whoisfreaks.com/v3.3/download/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpWhois.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesIPWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPWHOISApi(config); -async function main() { - const result = await api.dbIpWhois({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbIpWhois({ date }) +// date (Date, required) +async function main(): Promise { + const blob = await api.dbIpWhois({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbIpWhois.json.gz"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbIpWhoisStatus.ts b/examples/typescript/DbIpWhoisStatus.ts index ba5ac8d..3a728e9 100644 --- a/examples/typescript/DbIpWhoisStatus.ts +++ b/examples/typescript/DbIpWhoisStatus.ts @@ -1,13 +1,23 @@ -// Runnable example: IP WHOIS Snapshot Status (GET /v3.3/status/snapshot/ip/whois) -// Parameters for dbIpWhoisStatus (GET /v3.3/status/snapshot/ip/whois): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesIPWHOISApi } from "whoisfreaks"; +// IP WHOIS Snapshot Status: GET https://files.whoisfreaks.com/v3.3/status/snapshot/ip/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbIpWhoisStatus.ts +import { Configuration, DatabasesIPWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesIPWHOISApi(config); -async function main() { - const result = await api.dbIpWhoisStatus({ }); - console.log(result); +// dbIpWhoisStatus() takes no parameters. +async function main(): Promise { + const result = await api.dbIpWhoisStatus(); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbNewlyCctld.ts b/examples/typescript/DbNewlyCctld.ts index d014da7..af94f5c 100644 --- a/examples/typescript/DbNewlyCctld.ts +++ b/examples/typescript/DbNewlyCctld.ts @@ -1,15 +1,30 @@ -// Runnable example: Newly Registered ccTLD (CSV) (GET /v3.1/download/domainer/cctld) -// Parameters for dbNewlyCctld (GET /v3.1/download/domainer/cctld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered ccTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyCctld.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyCctld({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyCctld({ whois, date?, tlds? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const blob = await api.dbNewlyCctld({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyCctld.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbNewlyCctldCleaned.ts b/examples/typescript/DbNewlyCctldCleaned.ts index c8e1870..0718d2e 100644 --- a/examples/typescript/DbNewlyCctldCleaned.ts +++ b/examples/typescript/DbNewlyCctldCleaned.ts @@ -1,13 +1,28 @@ -// Runnable example: Newly Registered ccTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/cctld/cleaned) -// Parameters for dbNewlyCctldCleaned (GET /v3.1/download/domainer/cctld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered ccTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/cctld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyCctldCleaned.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyCctldCleaned({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbNewlyCctldCleaned({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbNewlyCctldCleaned({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyCctldCleaned.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbNewlyCctldJson.ts b/examples/typescript/DbNewlyCctldJson.ts index 8523780..79fb769 100644 --- a/examples/typescript/DbNewlyCctldJson.ts +++ b/examples/typescript/DbNewlyCctldJson.ts @@ -1,14 +1,26 @@ -// Runnable example: Newly Registered ccTLD (JSON) (GET /v3.1/domains/newly/cctld) -// Parameters for dbNewlyCctldJson (GET /v3.1/domains/newly/cctld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered ccTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/cctld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyCctldJson.ts +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyCctldJson({ date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyCctldJson({ date?, tlds? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const domains = await api.dbNewlyCctldJson({ date: new Date("2026-10-01") }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbNewlyDns.ts b/examples/typescript/DbNewlyDns.ts index 2ac9dd7..3f1eafd 100644 --- a/examples/typescript/DbNewlyDns.ts +++ b/examples/typescript/DbNewlyDns.ts @@ -1,13 +1,28 @@ -// Runnable example: Newly Registered With DNS (GET /v3.1/download/domainer/newly/dns) -// Parameters for dbNewlyDns (GET /v3.1/download/domainer/newly/dns): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered With DNS: GET https://files.whoisfreaks.com/v3.1/download/domainer/newly/dns +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyDns.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyDns({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbNewlyDns({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbNewlyDns({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyDns.json"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbNewlyGtld.ts b/examples/typescript/DbNewlyGtld.ts index 058f2a0..763c89d 100644 --- a/examples/typescript/DbNewlyGtld.ts +++ b/examples/typescript/DbNewlyGtld.ts @@ -1,15 +1,30 @@ -// Runnable example: Newly Registered gTLD (CSV) (GET /v3.1/download/domainer/gtld) -// Parameters for dbNewlyGtld (GET /v3.1/download/domainer/gtld): -// - whois (boolean, required) -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered gTLD (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyGtld.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyGtld({ whois: false, date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyGtld({ whois, date?, tlds? }) +// whois (boolean, required) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const blob = await api.dbNewlyGtld({ whois: true, date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyGtld.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbNewlyGtldCleaned.ts b/examples/typescript/DbNewlyGtldCleaned.ts index 723893a..91786e1 100644 --- a/examples/typescript/DbNewlyGtldCleaned.ts +++ b/examples/typescript/DbNewlyGtldCleaned.ts @@ -1,13 +1,28 @@ -// Runnable example: Newly Registered gTLD Cleaned WHOIS (CSV) (GET /v3.1/download/domainer/gtld/cleaned) -// Parameters for dbNewlyGtldCleaned (GET /v3.1/download/domainer/gtld/cleaned): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered gTLD Cleaned WHOIS (CSV): GET https://files.whoisfreaks.com/v3.1/download/domainer/gtld/cleaned +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyGtldCleaned.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyGtldCleaned({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbNewlyGtldCleaned({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbNewlyGtldCleaned({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbNewlyGtldCleaned.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbNewlyGtldJson.ts b/examples/typescript/DbNewlyGtldJson.ts index b52305a..565971a 100644 --- a/examples/typescript/DbNewlyGtldJson.ts +++ b/examples/typescript/DbNewlyGtldJson.ts @@ -1,14 +1,26 @@ -// Runnable example: Newly Registered gTLD (JSON) (GET /v3.1/domains/newly/gtld) -// Parameters for dbNewlyGtldJson (GET /v3.1/domains/newly/gtld): -// - date (string, optional): yyyy-MM-dd; omit for latest -// - tlds (string, optional) -import { Configuration, DatabasesNewlyRegisteredApi } from "whoisfreaks"; +// Newly Registered gTLD (JSON): GET https://files.whoisfreaks.com/v3.1/domains/newly/gtld +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbNewlyGtldJson.ts +import { Configuration, DatabasesNewlyRegisteredApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesNewlyRegisteredApi(config); -async function main() { - const result = await api.dbNewlyGtldJson({ date: new Date(Date.now()-86400000).toISOString().slice(0,10), tlds: undefined }); - console.log(result); +// dbNewlyGtldJson({ date?, tlds? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +// tlds (string, optional) +async function main(): Promise { + const domains = await api.dbNewlyGtldJson({ date: new Date("2026-10-01") }); + console.log(`${domains.length} domains`); + console.log(domains.slice(0, 10).join("\n")); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbSubdomainsDaily.ts b/examples/typescript/DbSubdomainsDaily.ts index e56c304..4e5aa85 100644 --- a/examples/typescript/DbSubdomainsDaily.ts +++ b/examples/typescript/DbSubdomainsDaily.ts @@ -1,13 +1,28 @@ -// Runnable example: Subdomains Daily (GET /v3.2/download/dbupdate/daily/subdomains) -// Parameters for dbSubdomainsDaily (GET /v3.2/download/dbupdate/daily/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesSubdomainsApi } from "whoisfreaks"; +// Subdomains Daily: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/daily/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbSubdomainsDaily.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesSubdomainsApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesSubdomainsApi(config); -async function main() { - const result = await api.dbSubdomainsDaily({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbSubdomainsDaily({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbSubdomainsDaily({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbSubdomainsDaily.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbSubdomainsMonthly.ts b/examples/typescript/DbSubdomainsMonthly.ts index dc8d61e..47af9e2 100644 --- a/examples/typescript/DbSubdomainsMonthly.ts +++ b/examples/typescript/DbSubdomainsMonthly.ts @@ -1,13 +1,28 @@ -// Runnable example: Subdomains Monthly (GET /v3.2/download/dbupdate/monthly/subdomains) -// Parameters for dbSubdomainsMonthly (GET /v3.2/download/dbupdate/monthly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesSubdomainsApi } from "whoisfreaks"; +// Subdomains Monthly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/monthly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbSubdomainsMonthly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesSubdomainsApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesSubdomainsApi(config); -async function main() { - const result = await api.dbSubdomainsMonthly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbSubdomainsMonthly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbSubdomainsMonthly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbSubdomainsMonthly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbSubdomainsWeekly.ts b/examples/typescript/DbSubdomainsWeekly.ts index 09e39a4..7f4117b 100644 --- a/examples/typescript/DbSubdomainsWeekly.ts +++ b/examples/typescript/DbSubdomainsWeekly.ts @@ -1,13 +1,28 @@ -// Runnable example: Subdomains Weekly (GET /v3.2/download/dbupdate/weekly/subdomains) -// Parameters for dbSubdomainsWeekly (GET /v3.2/download/dbupdate/weekly/subdomains): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesSubdomainsApi } from "whoisfreaks"; +// Subdomains Weekly: GET https://files.whoisfreaks.com/v3.2/download/dbupdate/weekly/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbSubdomainsWeekly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesSubdomainsApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesSubdomainsApi(config); -async function main() { - const result = await api.dbSubdomainsWeekly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbSubdomainsWeekly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbSubdomainsWeekly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbSubdomainsWeekly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbWhoisDaily.ts b/examples/typescript/DbWhoisDaily.ts index 7a0b67d..e0fb063 100644 --- a/examples/typescript/DbWhoisDaily.ts +++ b/examples/typescript/DbWhoisDaily.ts @@ -1,13 +1,28 @@ -// Runnable example: WHOIS Database Daily (GET /v3.3/download/dbupdate/daily/domains/whois) -// Parameters for dbWhoisDaily (GET /v3.3/download/dbupdate/daily/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesWHOISApi } from "whoisfreaks"; +// WHOIS Database Daily: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/daily/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbWhoisDaily.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesWHOISApi(config); -async function main() { - const result = await api.dbWhoisDaily({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbWhoisDaily({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbWhoisDaily({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbWhoisDaily.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbWhoisMonthly.ts b/examples/typescript/DbWhoisMonthly.ts index 51265fb..3e82467 100644 --- a/examples/typescript/DbWhoisMonthly.ts +++ b/examples/typescript/DbWhoisMonthly.ts @@ -1,13 +1,28 @@ -// Runnable example: WHOIS Database Monthly (GET /v3.3/download/dbupdate/monthly/domains/whois) -// Parameters for dbWhoisMonthly (GET /v3.3/download/dbupdate/monthly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesWHOISApi } from "whoisfreaks"; +// WHOIS Database Monthly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/monthly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbWhoisMonthly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesWHOISApi(config); -async function main() { - const result = await api.dbWhoisMonthly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbWhoisMonthly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbWhoisMonthly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbWhoisMonthly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DbWhoisWeekly.ts b/examples/typescript/DbWhoisWeekly.ts index 1c0434c..4993ec4 100644 --- a/examples/typescript/DbWhoisWeekly.ts +++ b/examples/typescript/DbWhoisWeekly.ts @@ -1,13 +1,28 @@ -// Runnable example: WHOIS Database Weekly (GET /v3.3/download/dbupdate/weekly/domains/whois) -// Parameters for dbWhoisWeekly (GET /v3.3/download/dbupdate/weekly/domains/whois): -// - date (string, optional): yyyy-MM-dd; omit for latest -import { Configuration, DatabasesWHOISApi } from "whoisfreaks"; +// WHOIS Database Weekly: GET https://files.whoisfreaks.com/v3.3/download/dbupdate/weekly/domains/whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DbWhoisWeekly.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesWHOISApi(config); -async function main() { - const result = await api.dbWhoisWeekly({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// dbWhoisWeekly({ date? }) +// date (Date, optional): yyyy-MM-dd; omit for latest +async function main(): Promise { + const blob = await api.dbWhoisWeekly({ date: new Date("2026-10-01") }); // a Blob with the file's bytes + const file = "DbWhoisWeekly.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DnsBulk.ts b/examples/typescript/DnsBulk.ts index 82d52f2..9aae3cb 100644 --- a/examples/typescript/DnsBulk.ts +++ b/examples/typescript/DnsBulk.ts @@ -1,15 +1,27 @@ -// Runnable example: Bulk DNS Lookup (POST /v2.0/dns/bulk/live) -// Parameters for dnsBulk (POST /v2.0/dns/bulk/live): -// - type (string, required) -// - format (string (one of: json, xml), optional) -// - body: DnsBulkRequest (required) -- request body object -import { Configuration, DNSApi } from "whoisfreaks"; +// Bulk DNS Lookup: POST https://api.whoisfreaks.com/v2.0/dns/bulk/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsBulk.ts +import { Configuration, DNSApi, ResponseError, type DnsBulkRequest } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsBulk({ type: "value", dnsBulkRequest: {}, format: undefined }); - console.log(result); +// dnsBulk({ type, dnsBulkRequest, format? }) +// type (string, required): default "all" +// dnsBulkRequest (DnsBulkRequest, required): request body +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const body: DnsBulkRequest = { domainNames: ["whoisfreaks.com", "example.com"] }; + const result = await api.dnsBulk({ type: "A,MX,TXT", dnsBulkRequest: body }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DnsHistorical.ts b/examples/typescript/DnsHistorical.ts index 9f98fa9..0185c63 100644 --- a/examples/typescript/DnsHistorical.ts +++ b/examples/typescript/DnsHistorical.ts @@ -1,16 +1,27 @@ -// Runnable example: Historical DNS Lookup (GET /v2.0/dns/historical) -// Parameters for dnsHistorical (GET /v2.0/dns/historical): -// - domainName (string, required) -// - type (string, required) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, DNSApi } from "whoisfreaks"; +// Historical DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/historical +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsHistorical.ts +import { Configuration, DNSApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsHistorical({ domainName: "example.com", type: "value", page: undefined, format: undefined }); - console.log(result); +// dnsHistorical({ domainName, type, page?, format? }) +// domainName (string, required) +// type (string, required): default "all" +// page (number, optional): default 1 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.dnsHistorical({ domainName: "whoisfreaks.com", type: "A,MX,TXT", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DnsLive.ts b/examples/typescript/DnsLive.ts index 5dd4f73..9d78991 100644 --- a/examples/typescript/DnsLive.ts +++ b/examples/typescript/DnsLive.ts @@ -1,16 +1,27 @@ -// Runnable example: Live DNS Lookup (GET /v2.0/dns/live) -// Parameters for dnsLive (GET /v2.0/dns/live): -// - domainName (string, required) -// - ipAddress (string, required): Use for PTR lookups -// - type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME -// - format (string (one of: json, xml), optional) -import { Configuration, DNSApi } from "whoisfreaks"; +// Live DNS Lookup: GET https://api.whoisfreaks.com/v2.0/dns/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsLive.ts +import { Configuration, DNSApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsLive({ domainName: "example.com", ipAddress: "8.8.8.8", type: "value", format: undefined }); - console.log(result); +// dnsLive({ type, domainName?, ipAddress?, format? }) +// type (string, required): all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME; default "all" +// domainName (string, optional) +// ipAddress (string, optional): Use for PTR lookups +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.dnsLive({ type: "A,MX,TXT", domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DnsReverse.ts b/examples/typescript/DnsReverse.ts index 20e5d87..637bcf9 100644 --- a/examples/typescript/DnsReverse.ts +++ b/examples/typescript/DnsReverse.ts @@ -1,17 +1,28 @@ -// Runnable example: Reverse DNS Lookup (GET /v2.1/dns/reverse) -// Parameters for dnsReverse (GET /v2.1/dns/reverse): -// - value (string, required): IP, CIDR, or record value -// - type (string (one of: a, mx, cname, ns, aaaa, txt, soa), required) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, DNSApi } from "whoisfreaks"; +// Reverse DNS Lookup: GET https://api.whoisfreaks.com/v2.1/dns/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DnsReverse.ts +import { Configuration, DNSApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DNSApi(config); -async function main() { - const result = await api.dnsReverse({ value: "value", type: "a", exact: true, page: undefined, format: undefined }); - console.log(result); +// dnsReverse({ value, type, exact?, page?, format? }) +// value (string, required): IP, CIDR, or record value +// type ("a" | "mx" | "cname" | "ns" | "aaaa" | "txt" | "soa", required) +// exact (boolean, optional): default true +// page (number, optional): default 1 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.dnsReverse({ value: "8.8.8.8", type: "a", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DomainAvailabilityV2.ts b/examples/typescript/DomainAvailabilityV2.ts index e33659b..fee2e15 100644 --- a/examples/typescript/DomainAvailabilityV2.ts +++ b/examples/typescript/DomainAvailabilityV2.ts @@ -1,16 +1,27 @@ -// Runnable example: Domain Availability Check with Suggestions (GET /v2.0/domain/availability) -// Parameters for domainAvailabilityV2 (GET /v2.0/domain/availability): -// - domain (string, required): The domain name to check -// - sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain. -// - count (integer, optional): Number of TLD suggestions to return when sug=true. Maximum is 100. -// - format (string (one of: json, xml), optional) -import { Configuration, DomainAvailabilityApi } from "whoisfreaks"; +// Domain Availability Check with Suggestions: GET https://api.whoisfreaks.com/v2.0/domain/availability +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DomainAvailabilityV2.ts +import { Configuration, DomainAvailabilityApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DomainAvailabilityApi(config); -async function main() { - const result = await api.domainAvailabilityV2({ domain: "example.com", sug: undefined, count: undefined, format: undefined }); - console.log(result); +// domainAvailabilityV2({ domain, sug?, count?, format? }) +// domain (string, required): The domain name to check +// sug (boolean, optional): Whether to return TLD suggestions alongside the queried domain; default false +// count (number, optional): Number of TLD suggestions to return when sug=true. Maximum is 100; default 5 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.domainAvailabilityV2({ domain: "google.com", sug: true, count: 5 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DomainReputation.ts b/examples/typescript/DomainReputation.ts index cb94c7f..5469a4e 100644 --- a/examples/typescript/DomainReputation.ts +++ b/examples/typescript/DomainReputation.ts @@ -1,14 +1,25 @@ -// Runnable example: Domain Reputation Lookup (GET /v1/domain/security) -// Parameters for domainReputation (GET /v1/domain/security): -// - domainName (string, required): The domain name to assess -// - format (string (one of: json, xml), optional) -import { Configuration, DomainReputationApi } from "whoisfreaks"; +// Domain Reputation Lookup: GET https://api.whoisfreaks.com/v1/domain/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DomainReputation.ts +import { Configuration, DomainReputationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DomainReputationApi(config); -async function main() { - const result = await api.domainReputation({ domainName: "example.com", format: undefined }); - console.log(result); +// domainReputation({ domainName, format? }) +// domainName (string, required): The domain name to assess +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.domainReputation({ domainName: "amazon.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DownloadThreatFeedMalware.ts b/examples/typescript/DownloadThreatFeedMalware.ts index 90843d4..b8e636c 100644 --- a/examples/typescript/DownloadThreatFeedMalware.ts +++ b/examples/typescript/DownloadThreatFeedMalware.ts @@ -1,13 +1,28 @@ -// Runnable example: Download the daily malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware) -// Parameters for downloadThreatFeedMalware (GET /v3.4/download/threat-feed/malware): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; +// Download the daily malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedMalware.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedMalware({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// downloadThreatFeedMalware({ date? }) +// date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main(): Promise { + const blob = await api.downloadThreatFeedMalware({ date: "2026-10-01" }); // a Blob with the file's bytes + const file = "DownloadThreatFeedMalware.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DownloadThreatFeedMalwareSample.ts b/examples/typescript/DownloadThreatFeedMalwareSample.ts index e1a3ffa..2eca327 100644 --- a/examples/typescript/DownloadThreatFeedMalwareSample.ts +++ b/examples/typescript/DownloadThreatFeedMalwareSample.ts @@ -1,13 +1,27 @@ -// Runnable example: Download a sample of the malware threat feed (CSV) (GET /v3.4/download/threat-feed/malware/sample) -// Parameters for downloadThreatFeedMalwareSample (GET /v3.4/download/threat-feed/malware/sample): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; +// Download a sample of the malware threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/malware/sample +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedMalwareSample.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedMalwareSample({ }); - console.log(result); +// downloadThreatFeedMalwareSample() takes no parameters. +async function main(): Promise { + const blob = await api.downloadThreatFeedMalwareSample(); // a Blob with the file's bytes + const file = "DownloadThreatFeedMalwareSample.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DownloadThreatFeedPhishing.ts b/examples/typescript/DownloadThreatFeedPhishing.ts index 3b8bf3e..a9c3c76 100644 --- a/examples/typescript/DownloadThreatFeedPhishing.ts +++ b/examples/typescript/DownloadThreatFeedPhishing.ts @@ -1,13 +1,28 @@ -// Runnable example: Download the daily phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing) -// Parameters for downloadThreatFeedPhishing (GET /v3.4/download/threat-feed/phishing): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; +// Download the daily phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedPhishing.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedPhishing({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// downloadThreatFeedPhishing({ date? }) +// date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main(): Promise { + const blob = await api.downloadThreatFeedPhishing({ date: "2026-10-01" }); // a Blob with the file's bytes + const file = "DownloadThreatFeedPhishing.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DownloadThreatFeedPhishingSample.ts b/examples/typescript/DownloadThreatFeedPhishingSample.ts index 800f763..6389cd8 100644 --- a/examples/typescript/DownloadThreatFeedPhishingSample.ts +++ b/examples/typescript/DownloadThreatFeedPhishingSample.ts @@ -1,13 +1,27 @@ -// Runnable example: Download a sample of the phishing threat feed (CSV) (GET /v3.4/download/threat-feed/phishing/sample) -// Parameters for downloadThreatFeedPhishingSample (GET /v3.4/download/threat-feed/phishing/sample): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; +// Download a sample of the phishing threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/phishing/sample +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedPhishingSample.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedPhishingSample({ }); - console.log(result); +// downloadThreatFeedPhishingSample() takes no parameters. +async function main(): Promise { + const blob = await api.downloadThreatFeedPhishingSample(); // a Blob with the file's bytes + const file = "DownloadThreatFeedPhishingSample.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DownloadThreatFeedSpam.ts b/examples/typescript/DownloadThreatFeedSpam.ts index 4328e10..bf085d6 100644 --- a/examples/typescript/DownloadThreatFeedSpam.ts +++ b/examples/typescript/DownloadThreatFeedSpam.ts @@ -1,13 +1,28 @@ -// Runnable example: Download the daily spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam) -// Parameters for downloadThreatFeedSpam (GET /v3.4/download/threat-feed/spam): -// - date (string, optional): Feed date (yyyy-MM-dd); defaults to latest available -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; +// Download the daily spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedSpam.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedSpam({ date: new Date(Date.now()-86400000).toISOString().slice(0,10) }); - console.log(result); +// downloadThreatFeedSpam({ date? }) +// date (string, optional): Feed date (yyyy-MM-dd); omit for the full dump of the feed +async function main(): Promise { + const blob = await api.downloadThreatFeedSpam({ date: "2026-10-01" }); // a Blob with the file's bytes + const file = "DownloadThreatFeedSpam.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/DownloadThreatFeedSpamSample.ts b/examples/typescript/DownloadThreatFeedSpamSample.ts index e472c10..5befa34 100644 --- a/examples/typescript/DownloadThreatFeedSpamSample.ts +++ b/examples/typescript/DownloadThreatFeedSpamSample.ts @@ -1,13 +1,27 @@ -// Runnable example: Download a sample of the spam threat feed (CSV) (GET /v3.4/download/threat-feed/spam/sample) -// Parameters for downloadThreatFeedSpamSample (GET /v3.4/download/threat-feed/spam/sample): -// (no parameters; the API key is set on the client) -import { Configuration, DatabasesThreatFeedApi } from "whoisfreaks"; +// Download a sample of the spam threat feed (CSV): GET https://files.whoisfreaks.com/v3.4/download/threat-feed/spam/sample +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx DownloadThreatFeedSpamSample.ts +import { writeFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { Configuration, DatabasesThreatFeedApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new DatabasesThreatFeedApi(config); -async function main() { - const result = await api.downloadThreatFeedSpamSample({ }); - console.log(result); +// downloadThreatFeedSpamSample() takes no parameters. +async function main(): Promise { + const blob = await api.downloadThreatFeedSpamSample(); // a Blob with the file's bytes + const file = "DownloadThreatFeedSpamSample.csv"; + await writeFile(file, new Uint8Array(await blob.arrayBuffer())); + console.log(`Saved ${blob.size} bytes to ${resolve(file)}`); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/Geolocation.ts b/examples/typescript/Geolocation.ts index 078d8b3..25902d3 100644 --- a/examples/typescript/Geolocation.ts +++ b/examples/typescript/Geolocation.ts @@ -1,13 +1,24 @@ -// Runnable example: IP Geolocation Lookup (GET /v1.0/geolocation) -// Parameters for geolocation (GET /v1.0/geolocation): -// - ip (string, required) -import { Configuration, GeolocationApi } from "whoisfreaks"; +// IP Geolocation Lookup: GET https://api.whoisfreaks.com/v1.0/geolocation +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx Geolocation.ts +import { Configuration, GeolocationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new GeolocationApi(config); -async function main() { +// geolocation({ ip }) +// ip (string, required) +async function main(): Promise { const result = await api.geolocation({ ip: "8.8.8.8" }); - console.log(result); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/IpReputation.ts b/examples/typescript/IpReputation.ts index bb90255..34e42c7 100644 --- a/examples/typescript/IpReputation.ts +++ b/examples/typescript/IpReputation.ts @@ -1,13 +1,24 @@ -// Runnable example: IP Reputation Lookup (GET /v1.0/security) -// Parameters for ipReputation (GET /v1.0/security): -// - ip (string, required) -import { Configuration, IPReputationApi } from "whoisfreaks"; +// IP Reputation Lookup: GET https://api.whoisfreaks.com/v1.0/security +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx IpReputation.ts +import { Configuration, IPReputationApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new IPReputationApi(config); -async function main() { +// ipReputation({ ip }) +// ip (string, required) +async function main(): Promise { const result = await api.ipReputation({ ip: "8.8.8.8" }); - console.log(result); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/IpWhois.ts b/examples/typescript/IpWhois.ts index 54bd41b..a84ac37 100644 --- a/examples/typescript/IpWhois.ts +++ b/examples/typescript/IpWhois.ts @@ -1,14 +1,25 @@ -// Runnable example: IP WHOIS Lookup (GET /v1.0/ip-whois) -// Parameters for ipWhois (GET /v1.0/ip-whois): -// - ip (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, IPWHOISApi } from "whoisfreaks"; +// IP WHOIS Lookup: GET https://api.whoisfreaks.com/v1.0/ip-whois +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx IpWhois.ts +import { Configuration, IPWHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new IPWHOISApi(config); -async function main() { - const result = await api.ipWhois({ ip: "8.8.8.8", format: undefined }); - console.log(result); +// ipWhois({ ip, format? }) +// ip (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.ipWhois({ ip: "8.8.8.8" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/README.md b/examples/typescript/README.md index 830fdac..9c7954f 100644 --- a/examples/typescript/README.md +++ b/examples/typescript/README.md @@ -1,107 +1,107 @@ -# TypeScript — Runnable Examples +# TypeScript Runnable Examples -Install: see the [TypeScript guide](../../docs/languages/typescript.md). Set `YOUR_API_KEY` and run any file below. +Install: see the [TypeScript guide](../../docs/languages/typescript.md). Set the `WHOISFREAKS_API_KEY` environment variable and run any file below. ## WHOIS -- [`WhoisLive.ts`](WhoisLive.ts) — Live WHOIS Lookup (`GET /v2.0/whois/live`) -- [`BulkWhois.ts`](BulkWhois.ts) — Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) -- [`WhoisHistory.ts`](WhoisHistory.ts) — Historical WHOIS records for a domain (`GET /v2.0/whois/history`) -- [`WhoisReverse.ts`](WhoisReverse.ts) — Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) +- [`WhoisLive.ts`](WhoisLive.ts): Live WHOIS Lookup (`GET /v2.0/whois/live`) +- [`BulkWhois.ts`](BulkWhois.ts): Bulk WHOIS Lookup (`POST /v2.0/bulkwhois/live`) +- [`WhoisHistory.ts`](WhoisHistory.ts): Historical WHOIS records for a domain (`GET /v2.0/whois/history`) +- [`WhoisReverse.ts`](WhoisReverse.ts): Reverse WHOIS lookup by keyword (`GET /v2.0/whois/reverse`) ## DNS -- [`DnsLive.ts`](DnsLive.ts) — Live DNS Lookup (`GET /v2.0/dns/live`) -- [`DnsHistorical.ts`](DnsHistorical.ts) — Historical DNS Lookup (`GET /v2.0/dns/historical`) -- [`DnsReverse.ts`](DnsReverse.ts) — Reverse DNS Lookup (`GET /v2.1/dns/reverse`) -- [`DnsBulk.ts`](DnsBulk.ts) — Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) +- [`DnsLive.ts`](DnsLive.ts): Live DNS Lookup (`GET /v2.0/dns/live`) +- [`DnsHistorical.ts`](DnsHistorical.ts): Historical DNS Lookup (`GET /v2.0/dns/historical`) +- [`DnsReverse.ts`](DnsReverse.ts): Reverse DNS Lookup (`GET /v2.1/dns/reverse`) +- [`DnsBulk.ts`](DnsBulk.ts): Bulk DNS Lookup (`POST /v2.0/dns/bulk/live`) ## Domain Availability -- [`DomainAvailabilityV2.ts`](DomainAvailabilityV2.ts) — Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) -- [`BulkDomainAvailabilityV2.ts`](BulkDomainAvailabilityV2.ts) — Bulk Domain Availability Check (`POST /v2.0/domain/availability`) +- [`DomainAvailabilityV2.ts`](DomainAvailabilityV2.ts): Domain Availability Check with Suggestions (`GET /v2.0/domain/availability`) +- [`BulkDomainAvailabilityV2.ts`](BulkDomainAvailabilityV2.ts): Bulk Domain Availability Check (`POST /v2.0/domain/availability`) ## Typosquatting -- [`Typosquatting.ts`](Typosquatting.ts) — Typosquatting Lookup (`GET /v3.0/domain/typos`) +- [`Typosquatting.ts`](Typosquatting.ts): Typosquatting Lookup (`GET /v3.0/domain/typos`) ## SSL -- [`SslLookup.ts`](SslLookup.ts) — SSL Certificate Lookup (`GET /v1.0/ssl/live`) +- [`SslLookup.ts`](SslLookup.ts): SSL Certificate Lookup (`GET /v1.0/ssl/live`) ## Geolocation -- [`Geolocation.ts`](Geolocation.ts) — IP Geolocation Lookup (`GET /v1.0/geolocation`) -- [`BulkGeolocation.ts`](BulkGeolocation.ts) — Bulk IP Geolocation (`POST /v1.0/geolocation`) +- [`Geolocation.ts`](Geolocation.ts): IP Geolocation Lookup (`GET /v1.0/geolocation`) +- [`BulkGeolocation.ts`](BulkGeolocation.ts): Bulk IP Geolocation (`POST /v1.0/geolocation`) ## Subdomains -- [`Subdomains.ts`](Subdomains.ts) — Subdomains Lookup (`GET /v1.0/subdomains`) +- [`Subdomains.ts`](Subdomains.ts): Subdomains Lookup (`GET /v1.0/subdomains`) ## IP Reputation -- [`IpReputation.ts`](IpReputation.ts) — IP Reputation Lookup (`GET /v1.0/security`) -- [`BulkIpReputation.ts`](BulkIpReputation.ts) — Bulk IP Reputation (`POST /v1.0/security`) +- [`IpReputation.ts`](IpReputation.ts): IP Reputation Lookup (`GET /v1.0/security`) +- [`BulkIpReputation.ts`](BulkIpReputation.ts): Bulk IP Reputation (`POST /v1.0/security`) ## Domain Reputation -- [`DomainReputation.ts`](DomainReputation.ts) — Domain Reputation Lookup (`GET /v1/domain/security`) +- [`DomainReputation.ts`](DomainReputation.ts): Domain Reputation Lookup (`GET /v1/domain/security`) ## ASN WHOIS -- [`AsnWhois.ts`](AsnWhois.ts) — ASN WHOIS Lookup (`GET /v2.0/asn-whois`) +- [`AsnWhois.ts`](AsnWhois.ts): ASN WHOIS Lookup (`GET /v2.0/asn-whois`) ## IP WHOIS -- [`IpWhois.ts`](IpWhois.ts) — IP WHOIS Lookup (`GET /v1.0/ip-whois`) +- [`IpWhois.ts`](IpWhois.ts): IP WHOIS Lookup (`GET /v1.0/ip-whois`) ## Account -- [`RotateApiKey.ts`](RotateApiKey.ts) — Rotate API Key (`GET /v1.0/api-key/rotate`) -- [`AccountUsage.ts`](AccountUsage.ts) — Account Usage (`GET /v1.0/whoisapi/usage`) -- [`DatabaseFileStatus.ts`](DatabaseFileStatus.ts) — Database File Status (Public) (`GET /v3.4/status`) +- [`RotateApiKey.ts`](RotateApiKey.ts): Rotate API Key (`GET /v1.0/api-key/rotate`) +- [`AccountUsage.ts`](AccountUsage.ts): Account Usage (`GET /v1.0/whoisapi/usage`) +- [`DatabaseFileStatus.ts`](DatabaseFileStatus.ts): Database File Status (Public) (`GET /v3.4/status`) ## Databases - Newly Registered -- [`DbNewlyGtld.ts`](DbNewlyGtld.ts) — Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) -- [`DbNewlyCctld.ts`](DbNewlyCctld.ts) — Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) -- [`DbNewlyGtldCleaned.ts`](DbNewlyGtldCleaned.ts) — Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) -- [`DbNewlyCctldCleaned.ts`](DbNewlyCctldCleaned.ts) — Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) -- [`DbNewlyGtldJson.ts`](DbNewlyGtldJson.ts) — Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) -- [`DbNewlyCctldJson.ts`](DbNewlyCctldJson.ts) — Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) -- [`DbNewlyDns.ts`](DbNewlyDns.ts) — Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) +- [`DbNewlyGtld.ts`](DbNewlyGtld.ts): Newly Registered gTLD (CSV) (`GET /v3.1/download/domainer/gtld`) +- [`DbNewlyCctld.ts`](DbNewlyCctld.ts): Newly Registered ccTLD (CSV) (`GET /v3.1/download/domainer/cctld`) +- [`DbNewlyGtldCleaned.ts`](DbNewlyGtldCleaned.ts): Newly Registered gTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/gtld/cleaned`) +- [`DbNewlyCctldCleaned.ts`](DbNewlyCctldCleaned.ts): Newly Registered ccTLD Cleaned WHOIS (CSV) (`GET /v3.1/download/domainer/cctld/cleaned`) +- [`DbNewlyGtldJson.ts`](DbNewlyGtldJson.ts): Newly Registered gTLD (JSON) (`GET /v3.1/domains/newly/gtld`) +- [`DbNewlyCctldJson.ts`](DbNewlyCctldJson.ts): Newly Registered ccTLD (JSON) (`GET /v3.1/domains/newly/cctld`) +- [`DbNewlyDns.ts`](DbNewlyDns.ts): Newly Registered With DNS (`GET /v3.1/download/domainer/newly/dns`) ## Databases - Expiring & Dropped -- [`DbExpired.ts`](DbExpired.ts) — Expiring Domains (`GET /v3.1/download/domainer/expired`) -- [`DbExpiredCleaned.ts`](DbExpiredCleaned.ts) — Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) -- [`DbDropped.ts`](DbDropped.ts) — Dropped Domains (`GET /v3.1/download/domainer/dropped`) -- [`DbDroppedJson.ts`](DbDroppedJson.ts) — Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) -- [`DbDroppedBacklinks.ts`](DbDroppedBacklinks.ts) — Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) +- [`DbExpired.ts`](DbExpired.ts): Expiring Domains (`GET /v3.1/download/domainer/expired`) +- [`DbExpiredCleaned.ts`](DbExpiredCleaned.ts): Expiring Cleaned WHOIS (`GET /v3.1/download/domainer/expired/cleaned`) +- [`DbDropped.ts`](DbDropped.ts): Dropped Domains (`GET /v3.1/download/domainer/dropped`) +- [`DbDroppedJson.ts`](DbDroppedJson.ts): Dropped Domains (JSON) (`GET /v3.1/domains/dropped`) +- [`DbDroppedBacklinks.ts`](DbDroppedBacklinks.ts): Dropped With Backlinks (`GET /v3.3/download/domainer/dropped/backlinks`) ## Databases - WHOIS -- [`DbWhoisDaily.ts`](DbWhoisDaily.ts) — WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) -- [`DbWhoisWeekly.ts`](DbWhoisWeekly.ts) — WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) -- [`DbWhoisMonthly.ts`](DbWhoisMonthly.ts) — WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) +- [`DbWhoisDaily.ts`](DbWhoisDaily.ts): WHOIS Database Daily (`GET /v3.3/download/dbupdate/daily/domains/whois`) +- [`DbWhoisWeekly.ts`](DbWhoisWeekly.ts): WHOIS Database Weekly (`GET /v3.3/download/dbupdate/weekly/domains/whois`) +- [`DbWhoisMonthly.ts`](DbWhoisMonthly.ts): WHOIS Database Monthly (`GET /v3.3/download/dbupdate/monthly/domains/whois`) ## Databases - DNS -- [`DbDnsDaily.ts`](DbDnsDaily.ts) — DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) -- [`DbDnsWeekly.ts`](DbDnsWeekly.ts) — DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) -- [`DbDnsMonthly.ts`](DbDnsMonthly.ts) — DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) +- [`DbDnsDaily.ts`](DbDnsDaily.ts): DNS Database Daily (`GET /v3.2/download/dbupdate/daily/dns`) +- [`DbDnsWeekly.ts`](DbDnsWeekly.ts): DNS Database Weekly (`GET /v3.2/download/dbupdate/weekly/dns`) +- [`DbDnsMonthly.ts`](DbDnsMonthly.ts): DNS Database Monthly (`GET /v3.2/download/dbupdate/monthly/dns`) ## Databases - Subdomains -- [`DbSubdomainsDaily.ts`](DbSubdomainsDaily.ts) — Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) -- [`DbSubdomainsWeekly.ts`](DbSubdomainsWeekly.ts) — Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) -- [`DbSubdomainsMonthly.ts`](DbSubdomainsMonthly.ts) — Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) +- [`DbSubdomainsDaily.ts`](DbSubdomainsDaily.ts): Subdomains Daily (`GET /v3.2/download/dbupdate/daily/subdomains`) +- [`DbSubdomainsWeekly.ts`](DbSubdomainsWeekly.ts): Subdomains Weekly (`GET /v3.2/download/dbupdate/weekly/subdomains`) +- [`DbSubdomainsMonthly.ts`](DbSubdomainsMonthly.ts): Subdomains Monthly (`GET /v3.2/download/dbupdate/monthly/subdomains`) ## Databases - IP Geolocation -- [`DbIpCountryStatus.ts`](DbIpCountryStatus.ts) — IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) -- [`DbIpCountry.ts`](DbIpCountry.ts) — IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) -- [`DbIpCityStatus.ts`](DbIpCityStatus.ts) — IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) -- [`DbIpCity.ts`](DbIpCity.ts) — IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) +- [`DbIpCountryStatus.ts`](DbIpCountryStatus.ts): IP to Country Snapshot Status (`GET /v3.3/status/snapshot/ip/country`) +- [`DbIpCountry.ts`](DbIpCountry.ts): IP to Country Snapshot (`GET /v3.3/download/snapshot/ip/country`) +- [`DbIpCityStatus.ts`](DbIpCityStatus.ts): IP to City Snapshot Status (`GET /v3.3/status/snapshot/ip/city`) +- [`DbIpCity.ts`](DbIpCity.ts): IP to City Snapshot (`GET /v3.3/download/snapshot/ip/city`) ## Databases - ASN WHOIS -- [`DbAsnWhois.ts`](DbAsnWhois.ts) — ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) -- [`DbAsnWhoisStatus.ts`](DbAsnWhoisStatus.ts) — ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) +- [`DbAsnWhois.ts`](DbAsnWhois.ts): ASN WHOIS Snapshot (`GET /v3.3/download/snapshot/asn/whois`) +- [`DbAsnWhoisStatus.ts`](DbAsnWhoisStatus.ts): ASN WHOIS Snapshot Status (`GET /v3.3/status/snapshot/asn/whois`) ## Databases - IP WHOIS -- [`DbIpWhois.ts`](DbIpWhois.ts) — IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) -- [`DbIpWhoisStatus.ts`](DbIpWhoisStatus.ts) — IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) +- [`DbIpWhois.ts`](DbIpWhois.ts): IP WHOIS Snapshot (`GET /v3.3/download/snapshot/ip/whois`) +- [`DbIpWhoisStatus.ts`](DbIpWhoisStatus.ts): IP WHOIS Snapshot Status (`GET /v3.3/status/snapshot/ip/whois`) ## Databases - IP Security -- [`DbIpSecurity.ts`](DbIpSecurity.ts) — IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) -- [`DbIpSecurityStatus.ts`](DbIpSecurityStatus.ts) — IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) +- [`DbIpSecurity.ts`](DbIpSecurity.ts): IP Security Snapshot (`GET /v3.3/download/snapshot/ip/security`) +- [`DbIpSecurityStatus.ts`](DbIpSecurityStatus.ts): IP Security Snapshot Status (`GET /v3.3/status/snapshot/ip/security`) ## Databases - Threat Feed -- [`DownloadThreatFeedPhishing.ts`](DownloadThreatFeedPhishing.ts) — Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) -- [`DownloadThreatFeedPhishingSample.ts`](DownloadThreatFeedPhishingSample.ts) — Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) -- [`DownloadThreatFeedMalware.ts`](DownloadThreatFeedMalware.ts) — Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) -- [`DownloadThreatFeedMalwareSample.ts`](DownloadThreatFeedMalwareSample.ts) — Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) -- [`DownloadThreatFeedSpam.ts`](DownloadThreatFeedSpam.ts) — Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) -- [`DownloadThreatFeedSpamSample.ts`](DownloadThreatFeedSpamSample.ts) — Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) +- [`DownloadThreatFeedPhishing.ts`](DownloadThreatFeedPhishing.ts): Download the daily phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing`) +- [`DownloadThreatFeedPhishingSample.ts`](DownloadThreatFeedPhishingSample.ts): Download a sample of the phishing threat feed (CSV) (`GET /v3.4/download/threat-feed/phishing/sample`) +- [`DownloadThreatFeedMalware.ts`](DownloadThreatFeedMalware.ts): Download the daily malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware`) +- [`DownloadThreatFeedMalwareSample.ts`](DownloadThreatFeedMalwareSample.ts): Download a sample of the malware threat feed (CSV) (`GET /v3.4/download/threat-feed/malware/sample`) +- [`DownloadThreatFeedSpam.ts`](DownloadThreatFeedSpam.ts): Download the daily spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam`) +- [`DownloadThreatFeedSpamSample.ts`](DownloadThreatFeedSpamSample.ts): Download a sample of the spam threat feed (CSV) (`GET /v3.4/download/threat-feed/spam/sample`) diff --git a/examples/typescript/RotateApiKey.ts b/examples/typescript/RotateApiKey.ts index 9b5eeca..74b8d8f 100644 --- a/examples/typescript/RotateApiKey.ts +++ b/examples/typescript/RotateApiKey.ts @@ -1,13 +1,23 @@ -// Runnable example: Rotate API Key (GET /v1.0/api-key/rotate) -// Parameters for rotateApiKey (GET /v1.0/api-key/rotate): -// (no parameters; the API key is set on the client) -import { Configuration, AccountApi } from "whoisfreaks"; +// Rotate API Key: GET https://api.whoisfreaks.com/v1.0/api-key/rotate +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx RotateApiKey.ts +import { Configuration, AccountApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new AccountApi(config); -async function main() { - const result = await api.rotateApiKey({ }); - console.log(result); +// rotateApiKey() takes no parameters. +async function main(): Promise { + const newKey = await api.rotateApiKey(); // use this key from now on + console.log("New API key:", newKey); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/SslLookup.ts b/examples/typescript/SslLookup.ts index e756a37..05609a9 100644 --- a/examples/typescript/SslLookup.ts +++ b/examples/typescript/SslLookup.ts @@ -1,16 +1,27 @@ -// Runnable example: SSL Certificate Lookup (GET /v1.0/ssl/live) -// Parameters for sslLookup (GET /v1.0/ssl/live): -// - domainName (string, required) -// - chain (boolean, optional) -// - sslRaw (boolean, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, SSLApi } from "whoisfreaks"; +// SSL Certificate Lookup: GET https://api.whoisfreaks.com/v1.0/ssl/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx SslLookup.ts +import { Configuration, SSLApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new SSLApi(config); -async function main() { - const result = await api.sslLookup({ domainName: "example.com", chain: undefined, sslRaw: undefined, format: undefined }); - console.log(result); +// sslLookup({ domainName, chain?, sslRaw?, format? }) +// domainName (string, required) +// chain (boolean, optional): default false +// sslRaw (boolean, optional): default false +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.sslLookup({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/Subdomains.ts b/examples/typescript/Subdomains.ts index 60f6684..c4b883c 100644 --- a/examples/typescript/Subdomains.ts +++ b/examples/typescript/Subdomains.ts @@ -1,18 +1,29 @@ -// Runnable example: Subdomains Lookup (GET /v1.0/subdomains) -// Parameters for subdomains (GET /v1.0/subdomains): -// - domain (string, required) -// - after (string, optional) -// - before (string, optional) -// - status (string (one of: active, inactive), optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, SubdomainsApi } from "whoisfreaks"; +// Subdomains Lookup: GET https://api.whoisfreaks.com/v1.0/subdomains +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx Subdomains.ts +import { Configuration, SubdomainsApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new SubdomainsApi(config); -async function main() { - const result = await api.subdomains({ domain: "example.com", after: "2000-01-01", before: new Date().toISOString().slice(0,10), status: undefined, page: undefined, format: undefined }); - console.log(result); +// subdomains({ domain, after?, before?, status?, page?, format? }) +// domain (string, required) +// after (Date, optional) +// before (Date, optional) +// status ("active" | "inactive", optional) +// page (number, optional): default 1 +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.subdomains({ domain: "whoisfreaks.com", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/Typosquatting.ts b/examples/typescript/Typosquatting.ts index 096e110..85087fa 100644 --- a/examples/typescript/Typosquatting.ts +++ b/examples/typescript/Typosquatting.ts @@ -1,15 +1,26 @@ -// Runnable example: Typosquatting Lookup (GET /v3.0/domain/typos) -// Parameters for typosquatting (GET /v3.0/domain/typos): -// - keyword (string, optional) -// - pattern (string, optional) -// - pageToken (string, optional) -import { Configuration, TyposquattingApi } from "whoisfreaks"; +// Typosquatting Lookup: GET https://api.whoisfreaks.com/v3.0/domain/typos +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx Typosquatting.ts +import { Configuration, TyposquattingApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new TyposquattingApi(config); -async function main() { - const result = await api.typosquatting({ keyword: undefined, pattern: undefined, pageToken: undefined }); - console.log(result); +// typosquatting({ keyword?, pattern?, pageToken? }) +// keyword (string, optional) +// pattern (string, optional) +// pageToken (string, optional) +async function main(): Promise { + const result = await api.typosquatting({ keyword: "whoisfreaks" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/WhoisHistoricalOrReverse.ts b/examples/typescript/WhoisHistoricalOrReverse.ts deleted file mode 100644 index e98782d..0000000 --- a/examples/typescript/WhoisHistoricalOrReverse.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Runnable example: WHOIS Historical or Reverse Lookup (GET /v1.0/whois) -// Parameters for whoisHistoricalOrReverse (GET /v1.0/whois): -// - apiKey (string, required): Your WHOISFreaks API key -// - whois (string (one of: historical, reverse), required) -// - domainName (string, required): Required for historical lookup -// - keyword (string, optional): For reverse — domain keyword search -// - email (string, optional): For reverse — registrant email search -// - owner (string, optional): For reverse — registrant name search -// - company (string, optional): For reverse — company name search -// - mode (string (one of: default, mini), optional) -// - exact (boolean, optional) -// - page (integer, optional) -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; - -const api = new WHOISApi(new Configuration()); - -async function main() { - const resp = await api.whoisHistoricalOrReverseRaw({ apiKey: "YOUR_API_KEY", whois: "historical", domainName: "example.com", exact: true, keyword: undefined, email: undefined, owner: undefined, company: undefined, mode: undefined, page: undefined, format: undefined }); - console.log("status:", resp.raw.status); - console.log(await resp.value()); -} -main().catch(console.error); diff --git a/examples/typescript/WhoisHistory.ts b/examples/typescript/WhoisHistory.ts index 7ec4d96..8dac32e 100644 --- a/examples/typescript/WhoisHistory.ts +++ b/examples/typescript/WhoisHistory.ts @@ -1,15 +1,25 @@ -// Runnable example: Historical WHOIS records for a domain (GET /v2.0/whois/history) -// Parameters for whoisHistory (GET /v2.0/whois/history): -// - domainName (string, required): Domain to fetch historical WHOIS records for -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; +// Historical WHOIS records for a domain: GET https://api.whoisfreaks.com/v2.0/whois/history +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisHistory.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisHistory({ domainName: "example.com", page: undefined, format: undefined }); - console.log(result); +// whoisHistory({ domainName, format? }) +// domainName (string, required): Domain to fetch historical WHOIS records for +// format ("json" | "xml", optional) +async function main(): Promise { + const result = await api.whoisHistory({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/WhoisLive.ts b/examples/typescript/WhoisLive.ts index 773e9b5..5b66789 100644 --- a/examples/typescript/WhoisLive.ts +++ b/examples/typescript/WhoisLive.ts @@ -1,14 +1,25 @@ -// Runnable example: Live WHOIS Lookup (GET /v2.0/whois/live) -// Parameters for whoisLive (GET /v2.0/whois/live): -// - domainName (string, required) -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; +// Live WHOIS Lookup: GET https://api.whoisfreaks.com/v2.0/whois/live +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisLive.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisLive({ domainName: "example.com", format: undefined }); - console.log(result); +// whoisLive({ domainName, format? }) +// domainName (string, required) +// format ("json" | "xml", optional): default "json" +async function main(): Promise { + const result = await api.whoisLive({ domainName: "whoisfreaks.com" }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/examples/typescript/WhoisReverse.ts b/examples/typescript/WhoisReverse.ts index 0323dde..48346f7 100644 --- a/examples/typescript/WhoisReverse.ts +++ b/examples/typescript/WhoisReverse.ts @@ -1,15 +1,26 @@ -// Runnable example: Reverse WHOIS lookup by keyword (GET /v2.0/whois/reverse) -// Parameters for whoisReverse (GET /v2.0/whois/reverse): -// - keyword (string, required): Keyword to search across WHOIS records -// - page (integer, optional): Page number -// - format (string (one of: json, xml), optional) -import { Configuration, WHOISApi } from "whoisfreaks"; +// Reverse WHOIS lookup by keyword: GET https://api.whoisfreaks.com/v2.0/whois/reverse +// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx WhoisReverse.ts +import { Configuration, WHOISApi, ResponseError } from "whoisfreaks"; -const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once +// Set the API key once; the client adds it to every request. +const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }); const api = new WHOISApi(config); -async function main() { - const result = await api.whoisReverse({ keyword: "value", page: undefined, format: undefined }); - console.log(result); +// whoisReverse({ keyword, page?, format? }) +// keyword (string, required): Keyword to search across WHOIS records +// page (number, optional): Page number +// format ("json" | "xml", optional) +async function main(): Promise { + const result = await api.whoisReverse({ keyword: "whoisfreaks", page: 1 }); + console.log(JSON.stringify(result, null, 2)); } -main().catch(console.error); + +main().catch(async (err: unknown) => { + // API errors carry the HTTP response + if (err instanceof ResponseError) { + console.error(`HTTP ${err.response.status}: ${await err.response.text()}`); + } else { + console.error(err); + } + process.exitCode = 1; +}); diff --git a/scripts/docs_lang/__init__.py b/scripts/docs_lang/__init__.py new file mode 100644 index 0000000..97fff06 --- /dev/null +++ b/scripts/docs_lang/__init__.py @@ -0,0 +1 @@ +"""Per-language example renderers for gen_docs.py: one module per SDK language.""" diff --git a/scripts/docs_lang/csharp.py b/scripts/docs_lang/csharp.py new file mode 100644 index 0000000..07b0937 --- /dev/null +++ b/scripts/docs_lang/csharp.py @@ -0,0 +1,190 @@ +"""C# example renderer (NuGet package WhoisFreaks, httpclient library, net8.0). + +Examples are top-level-statement programs (a `dotnet new console` Program.cs). +API classes keep acronyms upper case (WHOISApi, DatabasesDNSApi). The API key +name is "apiKey"; BasePath is left alone so database operations reach the files +host. Optional params are C# optional arguments, so examples pass the ones they +show by name. Dates are DateOnly; downloads return a FileParameter whose +Content stream is copied to a file. +""" +import json + +ENV = "WHOISFREAKS_API_KEY" + +# Optional params worth showing: the date on database downloads, suggestions on +# availability, the page on paginated lookups, and the lookup subject where the +# spec marks it optional (dnsLive domainName, typosquatting keyword). +_SHOWN = {"date", "sug", "count", "page", "domainName", "keyword"} + + +def _shown(p): + return p["required"] or p["name"] in _SHOWN + + +def _value(p, ctx): + if p["name"] == "sug": + return True # suggestions on, so `count` means something + return ctx.example_value(p) + + +def _signature(op): + """SDK argument order: required params, then the request body, then optionals.""" + params = [p for p in op["params"] if p["name"] != "apiKey"] + body = [None] if op.get("body_model") else [] + return [p for p in params if p["required"]] + body + [p for p in params if not p["required"]] + + +def _response(op, ctx): + path = ctx.spec["paths"][op["path"]][op["method"].lower()] + return ctx.deref((path.get("responses") or {}).get("200") or {}) + + +def _returns(op, ctx): + """('file'|'model'|'models'|'strings'|'string', model name or None).""" + if op.get("is_binary"): + return "file", None + for _ct, media in (_response(op, ctx).get("content") or {}).items(): + sch = ctx.deref(media).get("schema") or {} + if "$ref" in sch: + return "model", sch["$ref"].split("/")[-1] + if sch.get("type") == "array": + items = sch.get("items") or {} + if "$ref" in items: + return "models", items["$ref"].split("/")[-1] + return "strings", None + if sch.get("type") == "string": + return "string", None + return "string", None + + +def _lit(v, p=None): + if p and p.get("format") == "date": + y, m, d = (int(x) for x in str(v).split("-")) + return f"new DateOnly({y}, {m}, {d})" + if isinstance(v, bool): + return "true" if v else "false" + if isinstance(v, int): + return str(v) + if isinstance(v, (list, tuple)): + return "new List { " + ", ".join(_lit(x) for x in v) + " }" + return json.dumps(str(v)) + + +def example(op, ctx): + api = ctx.api_class(op["tag"], "csharp") + method = op["op_id"][0].upper() + op["op_id"][1:] + usings = {"System", "WhoisFreaks.Api", "WhoisFreaks.Client"} + + body, args, named = [], [], False + for p in _signature(op): + if p is None: + model = op["body_model"] + usings.update({"System.Collections.Generic", "WhoisFreaks.Model"}) + fields = ", ".join(f"{k}: {_lit(v)}" for k, v in ctx.body_example(op).items()) + body = [f"var body = new {model}({fields});"] + pname = model[0].lower() + model[1:] + args.append(f"{pname}: body" if named else "body") + elif not _shown(p): + named = True # skipped optional: everything after it is named + else: + lit = _lit(_value(p, ctx), p) + if named or not p["required"]: + named = True + args.append(f"{p['name']}: {lit}") + else: + args.append(lit) + call = f"api.{method}({', '.join(args)})" + + kind, model = _returns(op, ctx) + out = [] + if kind == "file": + usings.add("System.IO") + name = ctx.download_name(op) + out += [f"FileParameter download = {call};", + "// The SDK returns the response body as a stream: copy it to a file.", + f'var path = Path.GetFullPath("{name}");', + "using (Stream input = download.Content)", + "using (FileStream output = File.Create(path))", + "{", + " input.CopyTo(output);", + "}", + 'Console.WriteLine($"Saved {new FileInfo(path).Length} bytes to {path}");'] + elif op["op_id"] == "rotateApiKey": + out += [f"string newKey = {call};", + "// The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY.", + 'Console.WriteLine($"New API key: {newKey}");'] + elif kind in ("models", "strings"): + usings.add("System.Collections.Generic") + item = model or "string" + if model: + usings.add("WhoisFreaks.Model") + out += [f"List<{item}> result = {call};", + "foreach (var item in result)", + "{", + " Console.WriteLine(item.ToJson());" if model else " Console.WriteLine(item);", + "}"] + else: + rtype = model or "string" + if model: + usings.add("WhoisFreaks.Model") + out += [f"{rtype} result = {call};", + "Console.WriteLine(result.ToJson());" if model else "Console.WriteLine(result);"] + + pc = ctx.params_comment("csharp", op) + if op.get("public"): + pc = pc.replace("(no parameters; the API key is set on the client)", + "(no parameters; public endpoint, no API key needed)") + lines = [f"// Runnable example: {op['summary']} ({op['method']} {op['path']})", + "// Run it from the Getting Started project: replace Program.cs with this file, then `dotnet run`", + pc] + order = ["System", "System.Collections.Generic", "System.IO", + "WhoisFreaks.Api", "WhoisFreaks.Client", "WhoisFreaks.Model"] + lines += [f"using {u};" for u in order if u in usings] + lines += [""] + lines += ["var config = new Configuration();"] + if op.get("public"): + lines += ["// Public endpoint: no API key needed."] + else: + lines += [f'var apiKey = Environment.GetEnvironmentVariable("{ENV}")', + f' ?? throw new InvalidOperationException("Set the {ENV} environment variable");', + 'config.AddApiKey("apiKey", apiKey); // set once, sent with every call'] + lines += [f"var api = new {api}(config);", ""] + lines += body + out + return "\n".join(lines) + "\n" + + +def getting_started(ctx): + pkg = ctx.LANGS["csharp"]["pkg"] + v = ctx.SDK_VERSION + return [ + "You need the .NET 8 SDK or later. Create a console app and add the package:", "", + "```bash", + "dotnet new console -o whoisfreaks-test", + "cd whoisfreaks-test", + f"dotnet add package {pkg} --version {v}", + "```", "", + "Replace `Program.cs` with:", "", + "```csharp", + "using System;", + "using WhoisFreaks.Api;", + "using WhoisFreaks.Client;", + "using WhoisFreaks.Model;", + "", + "var config = new Configuration();", + f'var apiKey = Environment.GetEnvironmentVariable("{ENV}")', + f' ?? throw new InvalidOperationException("Set the {ENV} environment variable");', + 'config.AddApiKey("apiKey", apiKey); // set once, sent with every call', + "", + "var whois = new WHOISApi(config);", + 'WhoisResponse record = whois.WhoisLive("whoisfreaks.com");', + 'Console.WriteLine($"{record.DomainName} expires {record.ExpiryDate}");', + "Console.WriteLine(record.ToJson());", + "```", "", + "Set your API key and run it:", "", + "```bash", + f'export {ENV}="your_api_key"', + "dotnet run", + "```", "", + "To run one of the [runnable examples](../../examples/csharp/README.md), use it " + "as `Program.cs` and run `dotnet run` again.", + ] diff --git a/scripts/docs_lang/go.py b/scripts/docs_lang/go.py new file mode 100644 index 0000000..9e9bfa9 --- /dev/null +++ b/scripts/docs_lang/go.py @@ -0,0 +1,178 @@ +"""Go example renderer (github.com//whoisfreaks-go). + +Requests use the generated builder pattern: client.API.(ctx).(v) +...Execute(). The API key travels in the context (ContextAPIKeys, scheme +"ApiKeyAuth"). The `type` param's setter is Type_ (reserved word), dates are +plain "YYYY-MM-DD" strings, and downloads return a temporary *os.File that the +example copies to its destination. +""" +import json + +ENV = "WHOISFREAKS_API_KEY" +GO_KEYWORDS = {"break", "case", "chan", "const", "continue", "default", "defer", "else", + "fallthrough", "for", "func", "go", "goto", "if", "import", "interface", + "map", "package", "range", "return", "select", "struct", "switch", "type", "var"} + +# Optional params worth showing: the date on database downloads, suggestions on +# availability, the page on paginated lookups, and the lookup subject where the +# spec marks it optional (dnsLive domainName, typosquatting keyword). +_SHOWN = {"date", "sug", "count", "page", "domainName", "keyword"} + + +def _shown(p): + return p["required"] or p["name"] in _SHOWN + + +def _value(p, ctx): + if p["name"] == "sug": + return True # suggestions on, so `count` means something + return ctx.example_value(p) + + +def _exported(name): + s = name[0].upper() + name[1:] + return s + "_" if name in GO_KEYWORDS else s + + +def _lit(v): + if isinstance(v, bool): + return "true" if v else "false" + if isinstance(v, int): + return str(v) + if isinstance(v, (list, tuple)): + items = [_lit(x) for x in v] + kind = "string" if all(isinstance(x, str) for x in v) else "interface{}" + return f"[]{kind}{{" + ", ".join(items) + "}" + return json.dumps(str(v)) + + +def _body(op, ctx, alias): + """Lines building `body` with the model constructor (required fields) and setters.""" + model = op["body_model"] + sch = op.get("body_schema") or {} + required = set(sch.get("required") or []) + fields = ctx.body_example(op) + ctor = [k for k in (sch.get("properties") or {}) if k in required] + args = ", ".join(_lit(fields.get(k, [])) for k in ctor) + lines = [f"\tbody := {alias}.New{model}({args})"] + for k, v in fields.items(): + if k not in required: + lines.append(f"\tbody.Set{_exported(k)}({_lit(v)})") + return lines + + +def _fatal(): + return ["\tif err != nil {", "\t\tlog.Fatal(err)", "\t}"] + + +def example(op, ctx): + alias = "whoisfreaks" + module = ctx.LANGS["go"]["pkg"] + imports = {"context", "fmt", "log"} + lines_body = [] + setters = "" + for p in op["params"]: + if p["name"] == "apiKey" or not _shown(p): + continue + setters += f".{_exported(p['name'])}({_lit(_value(p, ctx))})" + if op.get("body_model"): + lines_body = _body(op, ctx, alias) + setters += f".{op['body_model']}(*body)" + method = op["op_id"][0].upper() + op["op_id"][1:] + head = f"client.{ctx.go_accessor(op['tag'])}.{method}(ctx)" + call = f"{head}{setters}.Execute()" + if len(call) > 80 and setters: + call = f"{head}.\n\t\t{setters[1:]}.Execute()" + + main = [] + if op.get("public"): + main += ["\t// Public endpoint: no API key needed.", + "\tctx := context.Background()"] + else: + imports.add("os") + main += ["\t// Set the API key once on the context; every call made with ctx sends it.", + f"\tctx := context.WithValue(context.Background(), {alias}.ContextAPIKeys,", + f'\t\tmap[string]{alias}.APIKey{{"ApiKeyAuth": {{Key: os.Getenv("{ENV}")}}}})'] + main += [f"\tclient := {alias}.NewAPIClient({alias}.NewConfiguration())", ""] + main += lines_body + + if op.get("is_binary"): + imports.update({"io", "os", "path/filepath"}) + name = ctx.download_name(op) + main += [f"\tfile, _, err := {call}"] + _fatal() + [ + "\t// The SDK saves the response to a temporary file: copy it to its destination.", + "\tdefer os.Remove(file.Name())", + "\tdefer file.Close()", + "", + f'\tout, err := os.Create("{name}")'] + _fatal() + [ + "\tdefer out.Close()", + "\tn, err := io.Copy(out, file)"] + _fatal() + [ + "\tpath, _ := filepath.Abs(out.Name())", + '\tfmt.Printf("Saved %d bytes to %s\\n", n, path)'] + elif op["op_id"] == "rotateApiKey": + main += [f"\tnewKey, _, err := {call}"] + _fatal() + [ + "\t// The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY.", + '\tfmt.Println("New API key:", newKey)'] + else: + imports.add("encoding/json") + main += [f"\tresult, _, err := {call}"] + _fatal() + [ + '\tout, _ := json.MarshalIndent(result, "", " ")', + "\tfmt.Println(string(out))"] + + pc = ctx.params_comment("go", op) + if op.get("public"): + pc = pc.replace("(no parameters; the API key is set on the client)", + "(no parameters; public endpoint, no API key needed)") + lines = [f"// Runnable example: {op['summary']} ({op['method']} {op['path']})", + "// Run it from the Getting Started module: save it as main.go, then `go run .`", + pc, "", "package main", "", "import ("] + lines += [f'\t"{i}"' for i in sorted(imports)] + lines += ["", f'\t{alias} "{module}"', ")", "", "func main() {"] + main + ["}"] + return "\n".join(lines) + "\n" + + +def getting_started(ctx): + module = ctx.LANGS["go"]["pkg"] + v = ctx.SDK_VERSION + return [ + "You need Go 1.18 or later. Create a module and add the SDK:", "", + "```bash", + "mkdir whoisfreaks-test && cd whoisfreaks-test", + "go mod init whoisfreaks-test", + f"go get {module}@v{v}", + "```", "", + "Create `main.go`:", "", + "```go", + "package main", + "", + "import (", + '\t"context"', + '\t"fmt"', + '\t"log"', + '\t"os"', + "", + f'\twhoisfreaks "{module}"', + ")", + "", + "func main() {", + "\t// Set the API key once on the context; every call made with ctx sends it.", + "\tctx := context.WithValue(context.Background(), whoisfreaks.ContextAPIKeys,", + f'\t\tmap[string]whoisfreaks.APIKey{{"ApiKeyAuth": {{Key: os.Getenv("{ENV}")}}}})', + "\tclient := whoisfreaks.NewAPIClient(whoisfreaks.NewConfiguration())", + "", + '\trecord, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName("whoisfreaks.com").Execute()', + "\tif err != nil {", + "\t\tlog.Fatal(err)", + "\t}", + '\tfmt.Println(record.GetDomainName(), "expires", record.GetExpiryDate())', + "}", + "```", "", + "Set your API key, tidy the module and run it:", "", + "```bash", + f'export {ENV}="your_api_key"', + "go mod tidy", + "go run .", + "```", "", + "To run one of the [runnable examples](../../examples/go/README.md), save it as " + "`main.go` in this module and run `go run .` again.", + ] diff --git a/scripts/docs_lang/java.py b/scripts/docs_lang/java.py new file mode 100644 index 0000000..3ac54f0 --- /dev/null +++ b/scripts/docs_lang/java.py @@ -0,0 +1,249 @@ +"""Java example renderer (com.whoisfreaks:whoisfreaks, okhttp-gson client). + +Signatures follow the generated Java SDK: every parameter is positional, in the +order required params, request body, optional params, so optional parameters +that the example leaves unset are passed as null. Date params are LocalDate, +downloads return a temporary java.io.File that the example moves into place. +""" +import json + +ENV = "WHOISFREAKS_API_KEY" +PKG = "com.whoisfreaks.client" + +# Optional params worth showing: the date on database downloads, suggestions on +# availability, the page on paginated lookups, and the lookup subject where the +# spec marks it optional (dnsLive domainName, typosquatting keyword). +_SHOWN = {"date", "sug", "count", "page", "domainName", "keyword"} + + +def _shown(p): + return p["required"] or p["name"] in _SHOWN + + +def _value(p, ctx): + if p["name"] == "sug": + return True # suggestions on, so `count` means something + return ctx.example_value(p) + + +def _signature(op): + """SDK argument order: required params, then the request body, then optionals.""" + params = [p for p in op["params"] if p["name"] != "apiKey"] + body = [None] if op.get("body_model") else [] + return [p for p in params if p["required"]] + body + [p for p in params if not p["required"]] + + +def _response(op, ctx): + path = ctx.spec["paths"][op["path"]][op["method"].lower()] + return ctx.deref((path.get("responses") or {}).get("200") or {}) + + +def _returns(op, ctx): + """('file'|'model'|'models'|'strings'|'string', model name or None).""" + if op.get("is_binary"): + return "file", None + for _ct, media in (_response(op, ctx).get("content") or {}).items(): + sch = ctx.deref(media).get("schema") or {} + if "$ref" in sch: + return "model", sch["$ref"].split("/")[-1] + if sch.get("type") == "array": + items = sch.get("items") or {} + if "$ref" in items: + return "models", items["$ref"].split("/")[-1] + return "strings", None + if sch.get("type") == "string": + return "string", None + return "string", None + + +def _str(s): + return json.dumps(str(s)) + + +def _lit(v, p, imports): + if p and p.get("format") == "date": + y, m, d = (int(x) for x in str(v).split("-")) + imports.add("java.time.LocalDate") + return f"LocalDate.of({y}, {m}, {d})" + if isinstance(v, bool): + return "true" if v else "false" + if isinstance(v, int): + return str(v) + if isinstance(v, (list, tuple)): + imports.add("java.util.Arrays") + return "Arrays.asList(" + ", ".join(_lit(x, None, imports) for x in v) + ")" + return _str(v) + + +def _header(op, ctx, cls): + pc = ctx.params_comment("java", op) + if op.get("public"): + pc = pc.replace("(no parameters; the API key is set on the client)", + "(no parameters; public endpoint, no API key needed)") + return [f"// Runnable example: {op['summary']} ({op['method']} {op['path']})", + f"// Run it from the Getting Started project: mvn -q compile exec:java -Dexec.mainClass={cls}", + pc] + + +def example(op, ctx): + cls = ctx.pascal(op["op_id"]) + api = ctx.api_class(op["tag"], "java") + method = op["op_id"] + imports = {f"{PKG}.ApiClient", f"{PKG}.Configuration", f"{PKG}.api.{api}"} + if not op.get("public"): + imports.add(f"{PKG}.auth.ApiKeyAuth") + + body = [] + args, names, skipped = [], [], False + for p in _signature(op): + if p is None: + model = op["body_model"] + imports.add(f"{PKG}.model.{model}") + fields = ctx.body_example(op) + chain = "".join(f"\n .{k}({_lit(v, None, imports)})" for k, v in fields.items()) + body = [f" {model} body = new {model}(){chain};"] + args.append("body") + names.append(model[0].lower() + model[1:]) + elif _shown(p): + args.append(_lit(_value(p, ctx), p, imports)) + names.append(p["name"]) + else: + args.append("null") + names.append(p["name"]) + skipped = True + + kind, model = _returns(op, ctx) + if kind == "file": + rtype = "File" + imports.update({"java.io.File", "java.nio.file.Files", "java.nio.file.Path", + "java.nio.file.Paths", "java.nio.file.StandardCopyOption"}) + elif kind == "model": + rtype = model + imports.add(f"{PKG}.model.{model}") + elif kind == "models": + rtype = f"List<{model}>" + imports.update({f"{PKG}.model.{model}", "java.util.List"}) + elif kind == "strings": + rtype = "List" + imports.add("java.util.List") + else: + rtype = "String" + + # A model named like the example class (DatabaseFileStatus) is used fully qualified. + clash = f"{PKG}.model.{cls}" + if clash in imports: + imports.discard(clash) + rtype = rtype.replace(cls, clash) + + lines = _header(op, ctx, cls) + sdk = sorted(i for i in imports if i.startswith(PKG)) + jdk = sorted(i for i in imports if not i.startswith(PKG)) + lines += [f"import {i};" for i in sdk] + if jdk: + lines += [""] + [f"import {i};" for i in jdk] + lines += ["", f"public class {cls} {{", + " public static void main(String[] args) throws Exception {", + " ApiClient client = Configuration.getDefaultApiClient();"] + if op.get("public"): + lines += [" // Public endpoint: no API key needed."] + else: + lines += [' ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth");', + f' auth.setApiKey(System.getenv("{ENV}")); // set once, sent with every call'] + lines += [f" {api} api = new {api}(client);", ""] + lines += body + if skipped: + lines += [f" // {method}({', '.join(names)}); null leaves an optional parameter unset"] + call = f"api.{method}({', '.join(args)})" + + if kind == "file": + name = ctx.download_name(op) + lines += [f" File download = {call};", + " // The SDK saves the response to a temporary file: move it where you want it.", + f' Path target = Paths.get("{name}");', + " Files.move(download.toPath(), target, StandardCopyOption.REPLACE_EXISTING);", + ' System.out.println("Saved " + Files.size(target) + " bytes to " + target.toAbsolutePath());'] + elif op["op_id"] == "rotateApiKey": + lines += [f" String newKey = {call};", + " // The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY.", + ' System.out.println("New API key: " + newKey);'] + else: + lines += [f" {rtype} result = {call};", + " System.out.println(result);"] + lines += [" }", "}"] + return "\n".join(lines) + "\n" + + +def getting_started(ctx): + g, a = ctx.LANGS["java"]["pkg"].split(":") + v = ctx.SDK_VERSION + return [ + "You need JDK 8 or later and Maven. Create the project directory:", "", + "```bash", + "mkdir -p whoisfreaks-test/src/main/java && cd whoisfreaks-test", + "```", "", + "Create `pom.xml`. The `exec.mainClass` property picks the class that " + "`mvn exec:java` runs:", "", + "```xml", + '', + '', + " 4.0.0", + " com.example", + " whoisfreaks-test", + " 1.0-SNAPSHOT", "", + " ", + " 1.8", + " 1.8", + " UTF-8", + " Main", + " ", "", + " ", + " ", + f" {g}", + f" {a}", + f" {v}", + " ", + " ", "", + " ", + " ", + " ", + " org.codehaus.mojo", + " exec-maven-plugin", + " 3.5.0", + " ", + " ", + " ", + "", + "```", "", + "Create `src/main/java/Main.java`:", "", + "```java", + f"import {PKG}.ApiClient;", + f"import {PKG}.Configuration;", + f"import {PKG}.api.WhoisApi;", + f"import {PKG}.auth.ApiKeyAuth;", + f"import {PKG}.model.WhoisResponse;", + "", + "public class Main {", + " public static void main(String[] args) throws Exception {", + " ApiClient client = Configuration.getDefaultApiClient();", + ' ApiKeyAuth auth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth");', + f' auth.setApiKey(System.getenv("{ENV}")); // set once, sent with every call', + "", + " WhoisApi whois = new WhoisApi(client);", + " // whoisLive(domainName, format); null format returns JSON", + ' WhoisResponse record = whois.whoisLive("whoisfreaks.com", null);', + ' System.out.println(record.getDomainName() + " expires " + record.getExpiryDate());', + " System.out.println(record);", + " }", + "}", + "```", "", + "Set your API key and run it:", "", + "```bash", + f'export {ENV}="your_api_key"', + "mvn -q compile exec:java", + "```", "", + "To run one of the [runnable examples](../../examples/java/README.md), copy it " + "into `src/main/java` and pass its class name, for example " + "`mvn -q compile exec:java -Dexec.mainClass=WhoisLive`.", + ] diff --git a/scripts/docs_lang/javascript.py b/scripts/docs_lang/javascript.py new file mode 100644 index 0000000..e4fff63 --- /dev/null +++ b/scripts/docs_lang/javascript.py @@ -0,0 +1,229 @@ +"""JavaScript example renderer for gen_docs.py (SDK: `whoisfreaks-js` on npm). + +Matches the openapi-generator `javascript` (ES6, superagent) client as built to +CommonJS in dist/: + * examples are CommonJS (`require`) so they run with plain `node file.js` + after `npm init -y && npm install whoisfreaks-js` + * auth: ApiClient.instance.authentications["ApiKeyAuth"].apiKey, set once, + read from WHOISFREAKS_API_KEY + * required params are positional, in spec order, then the request body; + optional params go in a trailing `opts` object + * dates are "yyyy-MM-dd" strings: the SDK sends a Date object as a full + ISO timestamp (Date#toJSON), which the API does not expect + * request bodies are built with .constructFromObject({...}) + * downloads resolve to a Buffer in Node.js, written with fs.writeFileSync +""" +import json + +LANG = "javascript" + +# Optional params worth showing, beyond the always-shown `date` (database +# downloads) and `page` (paginated lookups). None = use the spec example value. +_SHOW_OPTIONAL = { + "domainAvailabilityV2": {"sug": True, "count": None}, + "dnsLive": {"domainName": None}, + "typosquatting": {"keyword": None}, +} + + +def _clean(text): + """One-line text without em/en dashes (house style).""" + return " ".join(str(text).replace(" — ", ": ").replace("—", ", ") + .replace("–", "-").split()) + + +def _shown(op, p): + n = p["name"] + if n == "apiKey": + return False + if p["required"] or n in ("date", "page"): + return True + return n in _SHOW_OPTIONAL.get(op["op_id"], {}) + + +def _value(op, p, ctx): + override = _SHOW_OPTIONAL.get(op["op_id"], {}).get(p["name"]) + return override if override is not None else ctx.example_value(p) + + +def _lit(v): + if isinstance(v, bool): + return "true" if v else "false" + if isinstance(v, (int, float)): + return repr(v) + if isinstance(v, list): + return "[" + ", ".join(_lit(x) for x in v) + "]" + return json.dumps(str(v)) + + +def _response_kind(op, ctx): + """binary | model | model_list | string_list | text""" + if op.get("is_binary"): + return "binary" + if op.get("response_schema"): + return "model_list" if op.get("response_is_array") else "model" + resp = ctx.deref(((ctx.spec["paths"][op["path"]][op["method"].lower()].get("responses") or {}) + .get("200")) or {}) + content = resp.get("content") or {} + if "text/plain" in content: + return "text" + sch = ctx.deref((content.get("application/json") or {}).get("schema") or {}) + if sch.get("type") == "array": + return "string_list" + return "model" + + +def download_filename(op, ctx): + return ctx.download_name(op) + + +def _type_label(p): + if p.get("format") == "date": + return 'string, "yyyy-MM-dd"' + return {"integer": "number", "boolean": "boolean", "number": "number"}.get(p.get("type"), "string") + + +def _body_var(model): + return model[0].lower() + model[1:] + + +def _params_comment(op, ctx, method): + req = [p for p in op["params"] if p["name"] != "apiKey" and p["required"]] + opt = [p for p in op["params"] if p["name"] != "apiKey" and not p["required"]] + bm = op.get("body_model") + sig = [p["name"] for p in req] + ([_body_var(bm)] if bm else []) + (["opts"] if opt else []) + if not sig: + return [f"// {method}() takes no parameters."] + lines = [f"// {method}({', '.join(sig)})"] + def line(p, name, kind): + extra = [] + if p.get("enum"): + extra.append("one of " + ", ".join(str(e) for e in p["enum"])) + if p.get("default") is not None: + extra.append(f"default {_lit(p['default'])}") + desc = _clean(p.get("desc") or "").rstrip(".") + if len(desc) > 80: + desc = desc[:77] + "..." + tail = "; ".join(x for x in [desc] + extra if x) + return f"// {name} ({_type_label(p)}, {kind})" + (f": {tail}" if tail else "") + for p in req: + lines.append(line(p, p["name"], "required")) + if bm: + lines.append(f"// {_body_var(bm)} ({bm}, required): request body") + for p in opt: + lines.append(line(p, "opts." + p["name"], "optional")) + return lines + + +def _header(op, run_file): + run = (f"// Run (public endpoint, no API key needed): node {run_file}" if op["public"] else + f"// Run: WHOISFREAKS_API_KEY=your_api_key node {run_file}") + return [f"// {_clean(op['summary'] or op['op_id'])}: {op['method']} {op['server']}{op['path']}", run] + + +def example(op, ctx): + cls = ctx.api_class(op["tag"], LANG) + m = ctx.method_name(op["op_id"], LANG) + kind = _response_kind(op, ctx) + bm = op.get("body_model") + ind = " " + + args, opts = [], [] + for p in op["params"]: + if _shown(op, p) and p["required"]: + args.append(_lit(_value(op, p, ctx))) + body_lines = [] + if bm: + fields = ", ".join(f"{k}: {_lit(v)}" for k, v in ctx.body_example(op).items()) + body_lines.append(f"{ind}const body = {bm}.constructFromObject({{ {fields} }});") + args.append("body") + for p in op["params"]: + if _shown(op, p) and not p["required"]: + opts.append(f"{p['name']}: {_lit(_value(op, p, ctx))}") + if opts: + args.append("{ " + ", ".join(opts) + " }") + call = f"api.{m}({', '.join(args)})" + + names = ([] if op["public"] else ["ApiClient"]) + [cls] + ([bm] if bm else []) + out = _header(op, f"{ctx.pascal(op['op_id'])}.js") + if kind == "binary": + out += ['const fs = require("node:fs");', 'const path = require("node:path");'] + out.append(f'const {{ {", ".join(names)} }} = require("{ctx.LANGS[LANG]["pkg"]}");') + out.append("") + if op["public"]: + out += ["// Public endpoint: no API key needed.", f"const api = new {cls}();"] + else: + out += ["// Set the API key once; the client adds it to every request.", + "const client = ApiClient.instance;", + 'client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY;', + f"const api = new {cls}(client);"] + out.append("") + out += _params_comment(op, ctx, m) + out.append("async function main() {") + out += body_lines + if kind == "binary": + fname = download_filename(op, ctx) + out += [f"{ind}const data = await {call}; // a Buffer with the file's bytes", + f'{ind}const file = "{fname}";', + f"{ind}fs.writeFileSync(file, data);", + f"{ind}console.log(`Saved ${{data.length}} bytes to ${{path.resolve(file)}}`);"] + elif kind == "model_list": + out += [f"{ind}const results = await {call};", + f"{ind}console.log(JSON.stringify(results, null, 2));"] + elif kind == "string_list": + out += [f"{ind}const domains = await {call};", + f"{ind}console.log(`${{domains.length}} domains`);", + f'{ind}console.log(domains.slice(0, 10).join("\\n"));'] + elif kind == "text": + out += [f"{ind}const newKey = await {call}; // use this key from now on", + f'{ind}console.log("New API key:", newKey);'] + else: + out += [f"{ind}const result = await {call};", + f"{ind}console.log(JSON.stringify(result, null, 2));"] + out += ["}", "", + "main().catch((err) => {", + " // API errors carry the HTTP status and the parsed error body", + " console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err);", + " process.exitCode = 1;", + "});"] + return "\n".join(out) + + +def getting_started(ctx): + pkg = ctx.LANGS[LANG]["pkg"] + cls = ctx.api_class("WHOIS", LANG) + m = ctx.method_name("whoisLive", LANG) + return [ + "1. Create a project and install the SDK (Node.js 18 or later):", "", + "```bash", + "mkdir whoisfreaks-test && cd whoisfreaks-test", + "npm init -y", + f"npm install {pkg}", + "```", "", + "2. Create `main.js`:", "", + "```javascript", + f'const {{ ApiClient, {cls} }} = require("{pkg}");', + "", + "// Set the API key once; the client adds it to every request.", + "const client = ApiClient.instance;", + 'client.authentications["ApiKeyAuth"].apiKey = process.env.WHOISFREAKS_API_KEY;', + f"const api = new {cls}(client);", + "", + "async function main() {", + f' const record = await api.{m}("whoisfreaks.com");', + ' console.log("Domain: ", record.domain_name);', + ' console.log("Created:", record.create_date);', + ' console.log("Expires:", record.expiry_date);', + "}", + "", + "main().catch((err) => {", + " console.error(err.status ? `HTTP ${err.status}: ${JSON.stringify(err.body)}` : err);", + " process.exitCode = 1;", + "});", + "```", "", + "3. Set your API key and run it:", "", + "```bash", + 'export WHOISFREAKS_API_KEY="your_api_key" # PowerShell: $env:WHOISFREAKS_API_KEY="your_api_key"', + "node main.js", + "```", + ] diff --git a/scripts/docs_lang/kotlin.py b/scripts/docs_lang/kotlin.py new file mode 100644 index 0000000..0b6e284 --- /dev/null +++ b/scripts/docs_lang/kotlin.py @@ -0,0 +1,175 @@ +"""Kotlin example renderer (com.whoisfreaks:whoisfreaks-kotlin, jvm-okhttp4 client). + +API classes keep acronyms upper case (WHOISApi, DatabasesDNSApi). Optional +parameters have Kotlin defaults, so examples pass required params positionally +and the optional ones they show as named arguments. Enum params (format, the +dnsReverse type) are nested enum classes; date params are java.time.LocalDate; +downloads return a temporary java.io.File (deleteOnExit) that is copied out. +""" +import json + +ENV = "WHOISFREAKS_API_KEY" +PKG = "com.whoisfreaks.client" + +# Optional params worth showing: the date on database downloads, suggestions on +# availability, the page on paginated lookups, and the lookup subject where the +# spec marks it optional (dnsLive domainName, typosquatting keyword). +_SHOWN = {"date", "sug", "count", "page", "domainName", "keyword"} + + +def _shown(p): + return p["required"] or p["name"] in _SHOWN + + +def _value(p, ctx): + if p["name"] == "sug": + return True # suggestions on, so `count` means something + return ctx.example_value(p) + + +def _signature(op): + """SDK argument order: required params, then the request body, then optionals.""" + params = [p for p in op["params"] if p["name"] != "apiKey"] + body = [None] if op.get("body_model") else [] + return [p for p in params if p["required"]] + body + [p for p in params if not p["required"]] + + +def _lit(v, p, imports, api=None, op=None): + if p and p.get("enum"): + # nested enum class: ., constants named like the values + imports.add(f"{PKG}.apis.{api}") + enum = p["name"][0].upper() + p["name"][1:] + op["op_id"][0].upper() + op["op_id"][1:] + return f"{api}.{enum}.{v}" + if p and p.get("format") == "date": + y, m, d = (int(x) for x in str(v).split("-")) + imports.add("java.time.LocalDate") + return f"LocalDate.of({y}, {m}, {d})" + if isinstance(v, bool): + return "true" if v else "false" + if isinstance(v, int): + return str(v) + if isinstance(v, (list, tuple)): + return "listOf(" + ", ".join(_lit(x, None, imports) for x in v) + ")" + return json.dumps(str(v)).replace("$", "\\$") + + +def _header(op, ctx, cls): + pc = ctx.params_comment("kotlin", op) + if op.get("public"): + pc = pc.replace("(no parameters; the API key is set on the client)", + "(no parameters; public endpoint, no API key needed)") + return [f"// Runnable example: {op['summary']} ({op['method']} {op['path']})", + f"// Run it from the Getting Started project: gradle run -PmainClass={cls}Kt", + pc] + + +def example(op, ctx): + cls = ctx.pascal(op["op_id"]) + api = ctx.api_class(op["tag"], "kotlin") + imports = {f"{PKG}.apis.{api}"} + if not op.get("public"): + imports.add(f"{PKG}.infrastructure.ApiClient") + + body, args, named = [], [], False + for p in _signature(op): + if p is None: + model = op["body_model"] + imports.add(f"{PKG}.models.{model}") + fields = ", ".join(f"{k} = {_lit(v, None, imports)}" + for k, v in ctx.body_example(op).items()) + body = [f" val body = {model}({fields})"] + pname = model[0].lower() + model[1:] + args.append(f"{pname} = body" if named else "body") + elif not _shown(p): + named = True # skipped optional: everything after it is named + else: + lit = _lit(_value(p, ctx), p, imports, api, op) + if named or not p["required"]: + named = True + args.append(f"{p['name']} = {lit}") + else: + args.append(lit) + call = f"api.{op['op_id']}({', '.join(args)})" + + lines = _header(op, ctx, cls) + if op.get("is_binary"): + imports.add("java.io.File") + sdk = sorted(i for i in imports if i.startswith(PKG)) + jdk = sorted(i for i in imports if not i.startswith(PKG)) + lines += [f"import {i}" for i in sdk + jdk] + lines += ["", "fun main() {"] + if op.get("public"): + lines += [" // Public endpoint: no API key needed."] + else: + lines += [f' ApiClient.apiKey["apiKey"] = System.getenv("{ENV}") // set once, sent with every call'] + lines += [f" val api = {api}()", ""] + lines += body + if op.get("is_binary"): + name = ctx.download_name(op) + lines += [f" val download = {call}", + " // The SDK saves the response to a temporary file that is deleted on exit: copy it.", + f' val target = download.copyTo(File("{name}"), overwrite = true)', + ' println("Saved ${target.length()} bytes to ${target.absolutePath}")'] + elif op["op_id"] == "rotateApiKey": + lines += [f" val newKey = {call}", + " // The old key stops working: store the new one, e.g. in WHOISFREAKS_API_KEY.", + ' println("New API key: $newKey")'] + else: + lines += [f" val result = {call}", + " println(result)"] + lines += ["}"] + return "\n".join(lines) + "\n" + + +def getting_started(ctx): + pkg = ctx.LANGS["kotlin"]["pkg"] + v = ctx.SDK_VERSION + return [ + "You need JDK 11 or later and [Gradle](https://gradle.org/install/) 8. " + "Create the project directory:", "", + "```bash", + "mkdir -p whoisfreaks-test/src/main/kotlin && cd whoisfreaks-test", + "```", "", + "Create `settings.gradle.kts`:", "", + "```kotlin", + 'rootProject.name = "whoisfreaks-test"', + "```", "", + "Create `build.gradle.kts`. The `mainClass` property picks the program " + "that `gradle run` starts:", "", + "```kotlin", + "plugins {", + ' kotlin("jvm") version "2.0.21"', + " application", + "}", "", + "repositories {", + " mavenCentral()", + "}", "", + "dependencies {", + f' implementation("{pkg}:{v}")', + "}", "", + "application {", + ' mainClass.set(providers.gradleProperty("mainClass").orElse("MainKt"))', + "}", + "```", "", + "Create `src/main/kotlin/Main.kt`:", "", + "```kotlin", + f"import {PKG}.apis.WHOISApi", + f"import {PKG}.infrastructure.ApiClient", + "", + "fun main() {", + f' ApiClient.apiKey["apiKey"] = System.getenv("{ENV}") // set once, sent with every call', + "", + ' val record = WHOISApi().whoisLive("whoisfreaks.com")', + ' println("${record.domainName} expires ${record.expiryDate}")', + " println(record)", + "}", + "```", "", + "Set your API key and run it:", "", + "```bash", + f'export {ENV}="your_api_key"', + "gradle run", + "```", "", + "To run one of the [runnable examples](../../examples/kotlin/README.md), copy it " + "into `src/main/kotlin` and pass its class name (file name plus `Kt`), for " + "example `gradle run -PmainClass=WhoisLiveKt`.", + ] diff --git a/scripts/docs_lang/php.py b/scripts/docs_lang/php.py new file mode 100644 index 0000000..fed9bba --- /dev/null +++ b/scripts/docs_lang/php.py @@ -0,0 +1,204 @@ +"""PHP example renderer for gen_docs.py (SDK: whoisfreaks/whoisfreaks-php). + +Matches the generated PHP client: positional arguments in the generated order +(required params in spec order, then the request body, then optional params in +spec order), API classes named like WHOISApi, models in WhoisFreaks\\Model, and +downloads returned as an \\SplFileObject temp file. +""" +import re + +FILES_HOST = "files.whoisfreaks.com" +# Optional params worth showing; every other optional param is left at its default. +SHOWN_OPTIONALS = {"domainName", "keyword", "sug", "count", "page"} +VALUE_OVERRIDES = {"sug": True} # suggestions only matter when turned on + + +# ---- shared helpers (kept local to this module) ----------------------------- +def _is_db(op): + return FILES_HOST in (op.get("server") or "") + + +def _shown(op, p): + if p["required"] or p["name"] in SHOWN_OPTIONALS: + return True + return p["name"] == "date" and _is_db(op) + + +def _value(p, ctx): + return VALUE_OVERRIDES.get(p["name"], ctx.example_value(p)) + + +def _params(op): + return [p for p in op["params"] if p["name"] != "apiKey"] + + +def _response(op, ctx): + item = ctx.spec["paths"][op["path"]][op["method"].lower()] + return ctx.deref((item.get("responses") or {}).get("200") or {}) + + +def _return_kind(op, ctx): + """file | model | models | strings | string""" + if op.get("is_binary"): + return "file" + if op.get("response_schema"): + return "models" if op.get("response_is_array") else "model" + for c in (_response(op, ctx).get("content") or {}).values(): + sch = ctx.deref(c.get("schema") or {}) + return "strings" if sch.get("type") == "array" else "string" + return "string" + + +def _download_name(op, ctx): + return ctx.download_name(op) + + +def _body_fields(op, ctx): + """[(jsonField, value)] for the request body, in the model's property order.""" + ex = ctx.body_example(op) + order = list(((op.get("body_schema") or {}).get("properties") or {}).keys()) + return sorted(ex.items(), key=lambda kv: order.index(kv[0]) if kv[0] in order else len(order)) + + +def _camel(name): + parts = [w for w in re.split(r"[^A-Za-z0-9]+", name) if w] + return parts[0][:1].lower() + parts[0][1:] + "".join(w[:1].upper() + w[1:] for w in parts[1:]) + + +# ---- PHP rendering ----------------------------------------------------------- +def _lit(v): + if isinstance(v, bool): + return "true" if v else "false" + if v is None: + return "null" + if isinstance(v, (int, float)): + return str(v) + if isinstance(v, (list, tuple)): + return "[" + ", ".join(_lit(x) for x in v) + "]" + return "'" + str(v).replace("\\", "\\\\").replace("'", "\\'") + "'" + + +def _args(op, ctx): + """Positional (name, code) pairs up to the last argument worth passing. + Skipped optionals before it are filled with their default value.""" + params = _params(op) + seq = [("p", p) for p in params if p["required"]] + if op.get("body_model"): + seq.append(("body", None)) + seq += [("p", p) for p in params if not p["required"]] + out, pending = [], [] + for kind, p in seq: + if kind == "body": + bm = op["body_model"] + out += pending + [(bm[:1].lower() + bm[1:], "$request")] + pending = [] + elif _shown(op, p): + out += pending + [(p["name"], _lit(_value(p, ctx)))] + pending = [] + else: + pending.append((p["name"], _lit(p.get("default")))) + return out + + +def _header(op, ctx): + return f"// {op['summary'] or op['op_id']}\n//\n" + ctx.params_comment("php", op) + + +def _setup(cls, extra_uses=(), public=False): + uses = sorted({"GuzzleHttp\\Client", f"WhoisFreaks\\Api\\{cls}", "WhoisFreaks\\ApiException", + "WhoisFreaks\\Configuration", *extra_uses}, key=str.lower) + lines = ["require __DIR__ . '/vendor/autoload.php';", ""] + lines += [f"use {u};" for u in uses] + lines += ["", "// Read the API key from the environment and set it once."] + if public: + lines.append("// (This endpoint is public, so the key is not sent with this request.)") + lines += ["$config = Configuration::getDefaultConfiguration()", + " ->setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY'));", "", + f"$api = new {cls}(new Client(), $config);"] + return lines + + +def example(op, ctx): + cls = ctx.api_class(op["tag"], "php") + method = ctx.method_name(op["op_id"], "php") + args = _args(op, ctx) + call = f"$api->{method}({', '.join(code for _, code in args)});" + if len(args) > 1: + call += " // " + ", ".join(name for name, _ in args) + + uses, pre = [], [] + if op.get("body_model"): + bm = op["body_model"] + uses.append(f"WhoisFreaks\\Model\\{bm}") + pre += ["", f"$request = new {bm}(["] + pre += [f" '{_camel(k)}' => {_lit(v)}," for k, v in _body_fields(op, ctx)] + pre += ["]);"] + + kind = _return_kind(op, ctx) + body = [] + if kind == "file": + name = _download_name(op, ctx) + body = [f" $file = {call}", + " // The SDK streams the download into a temporary file: copy it somewhere permanent.", + f" $saveAs = '{name}';", + " copy($file->getPathname(), $saveAs);", + " echo 'Saved ', realpath($saveAs), ' (', filesize($saveAs), ' bytes)', PHP_EOL;"] + elif kind == "model": + body = [f" $result = {call}", " echo $result, PHP_EOL; // models print as JSON"] + elif kind == "models": + body = [f" $results = {call}", " foreach ($results as $result) {", + " echo $result, PHP_EOL; // models print as JSON", " }"] + elif kind == "strings": + body = [f" $domains = {call}", " echo implode(PHP_EOL, $domains), PHP_EOL;"] + else: + if op["op_id"] == "rotateApiKey": + body = [f" $newKey = {call}", + " // The old key stops working now: store the new one before making more calls.", + " echo 'New API key: ', $newKey, PHP_EOL;"] + else: + body = [f" $result = {call}", " echo $result, PHP_EOL;"] + + lines = ["getCode() . ' ' . $e->getResponseBody() . PHP_EOL);", + " exit(1);", + "}"] + return "\n".join(lines) + "\n" + + +def getting_started(ctx): + pkg = ctx.LANGS["php"]["pkg"] + return [ + "You need PHP 7.4 or later (PHP 8 supported) and [Composer](https://getcomposer.org).", "", + "1. Create a project and install the SDK:", "", + "```bash", + "mkdir whoisfreaks-test && cd whoisfreaks-test", + f"composer require {pkg}", + "```", "", + "2. Create `main.php`:", "", + "```php", + "setApiKey('apiKey', getenv('WHOISFREAKS_API_KEY'));", + "", + "$whois = new WHOISApi(new Client(), $config);", + "$record = $whois->whoisLive('whoisfreaks.com');", + "", + "echo 'Registrar: ', $record->getDomainRegistrar()->getRegistrarName(), PHP_EOL;", + "echo 'Created: ', $record->getCreateDate(), PHP_EOL;", + "echo 'Expires: ', $record->getExpiryDate(), PHP_EOL;", + "```", "", + "3. Set your API key and run it:", "", + "```bash", + 'export WHOISFREAKS_API_KEY="your_api_key"', + "php main.php", + "```", + ] diff --git a/scripts/docs_lang/python.py b/scripts/docs_lang/python.py new file mode 100644 index 0000000..ef6c6cf --- /dev/null +++ b/scripts/docs_lang/python.py @@ -0,0 +1,239 @@ +"""Python example renderer for gen_docs.py (SDK: `whoisfreaks` on PyPI). + +Matches the openapi-generator `python` (pydantic v2) client: + * auth: Configuration().api_key["ApiKeyAuth"], set once, read from WHOISFREAKS_API_KEY + * required params are positional, in spec order, then the request body; + optional params are keyword arguments with snake_case names + * a param that clashes with a Python name gets a `var_` prefix (`date` -> `var_date`); + `type` and `format` keep their names + * `format: date` params take a datetime.date; other dates stay strings + * request bodies are model instances, e.g. BulkWhoisRequest(domain_names=[...]) + * downloads return bytes (a bytearray), written to a file +""" +import json + +LANG = "python" + +# openapi-generator's Python reserved words: a param with one of these names is +# emitted as var_. `type` and `format` are NOT reserved (checked against the SDK). +_RESERVED = { + "and", "as", "assert", "async", "await", "break", "class", "continue", "def", "del", + "elif", "else", "except", "exec", "finally", "for", "from", "global", "if", "import", + "in", "is", "lambda", "nonlocal", "not", "or", "pass", "print", "raise", "return", + "try", "while", "with", "yield", "self", "none", "true", "false", "property", + "schema", "base64", "json", "date", "datetime", "float", +} + +# Optional params worth showing, beyond the always-shown `date` (database +# downloads) and `page` (paginated lookups). None = use the spec example value. +_SHOW_OPTIONAL = { + "domainAvailabilityV2": {"sug": True, "count": None}, + "dnsLive": {"domainName": None}, + "typosquatting": {"keyword": None}, +} + + +def _clean(text): + """One-line text without em/en dashes (house style).""" + return " ".join(str(text).replace(" — ", ": ").replace("—", ", ") + .replace("–", "-").split()) + + +def _shown(op, p): + n = p["name"] + if n == "apiKey": + return False + if p["required"] or n in ("date", "page"): + return True + return n in _SHOW_OPTIONAL.get(op["op_id"], {}) + + +def _value(op, p, ctx): + override = _SHOW_OPTIONAL.get(op["op_id"], {}).get(p["name"]) + return override if override is not None else ctx.example_value(p) + + +def _py_name(name, ctx): + s = ctx.py_snake(name) + return "var_" + s if s in _RESERVED else s + + +def _is_date(p): + return p.get("format") == "date" + + +def _lit(v, p=None): + """A Python literal for v; format: date params become date(Y, M, D).""" + if p is not None and _is_date(p): + y, m, d = (int(x) for x in str(v).split("-")) + return f"date({y}, {m}, {d})" + if isinstance(v, bool): + return "True" if v else "False" + if isinstance(v, (int, float)): + return repr(v) + if isinstance(v, (list, dict, str)): + return json.dumps(v) + return json.dumps(str(v)) + + +def _response_kind(op, ctx): + """binary | model | model_list | string_list | text""" + if op.get("is_binary"): + return "binary" + if op.get("response_schema"): + return "model_list" if op.get("response_is_array") else "model" + resp = ctx.deref(((ctx.spec["paths"][op["path"]][op["method"].lower()].get("responses") or {}) + .get("200")) or {}) + content = resp.get("content") or {} + if "text/plain" in content: + return "text" + sch = ctx.deref((content.get("application/json") or {}).get("schema") or {}) + if sch.get("type") == "array": + return "string_list" + return "model" + + +def download_filename(op, ctx): + return ctx.download_name(op) + + +def _type_label(p): + if _is_date(p): + return "datetime.date" + return {"integer": "int", "boolean": "bool", "number": "float"}.get(p.get("type"), "str") + + +def _params_comment(op, ctx, method, ind): + lines = [f"{ind}# {method} parameters:"] + req = [p for p in op["params"] if p["name"] != "apiKey" and p["required"]] + opt = [p for p in op["params"] if p["name"] != "apiKey" and not p["required"]] + def line(p, kind): + t = _type_label(p) + extra = [] + if p.get("enum"): + extra.append("one of " + ", ".join(str(e) for e in p["enum"])) + if p.get("default") is not None: + extra.append(f"default {_lit(p['default'])}") + desc = _clean(p.get("desc") or "").rstrip(".") + if len(desc) > 80: + desc = desc[:77] + "..." + tail = "; ".join(x for x in [desc] + extra if x) + return f"{ind}# {_py_name(p['name'], ctx)} ({t}, {kind})" + (f": {tail}" if tail else "") + for p in req: + lines.append(line(p, "required")) + if op.get("body_model"): + lines.append(f"{ind}# {ctx.py_snake(op['body_model'])} ({op['body_model']}, required): request body") + for p in opt: + lines.append(line(p, "optional, keyword")) + if len(lines) == 1: + return [f"{ind}# {method} takes no parameters."] + return lines + + +def _call_lines(op, ctx, ind): + """(pre_lines, call_expr, uses_date) for the SDK call.""" + m = ctx.method_name(op["op_id"], LANG) + args, kwargs, pre, uses_date = [], [], [], False + for p in op["params"]: + if _shown(op, p) and p["required"]: + args.append(_lit(_value(op, p, ctx), p)) + uses_date |= _is_date(p) + bm = op.get("body_model") + if bm: + fields = ", ".join(f"{ctx.py_snake(k)}={_lit(v)}" for k, v in ctx.body_example(op).items()) + pre.append(f"{ind}body = whoisfreaks.{bm}({fields})") + args.append("body") + for p in op["params"]: + if _shown(op, p) and not p["required"]: + kwargs.append(f"{_py_name(p['name'], ctx)}={_lit(_value(op, p, ctx), p)}") + uses_date |= _is_date(p) + return pre, f"api.{m}({', '.join(args + kwargs)})", uses_date + + +def _header(op, run_file): + run = (["Run it (public endpoint, no API key needed):", f" python {run_file}"] if op["public"] else + ["Run it with your API key in the environment:", + f" WHOISFREAKS_API_KEY=your_api_key python {run_file}"]) + return [f'"""{_clean(op["summary"] or op["op_id"])}: {op["method"]} {op["server"]}{op["path"]}', ""] \ + + run + ['"""'] + + +def example(op, ctx): + cls = ctx.api_class(op["tag"], LANG) + m = ctx.method_name(op["op_id"], LANG) + kind = _response_kind(op, ctx) + ind = " " + pre, call, uses_date = _call_lines(op, ctx, ind) + imports = [] + if kind in ("model", "model_list"): + imports.append("import json") + if kind == "binary" or not op["public"]: + imports.append("import os") + if uses_date: + imports.append("from datetime import date") + out = _header(op, f"{ctx.pascal(op['op_id'])}.py") + out += imports + ["", "import whoisfreaks", ""] + out.append("config = whoisfreaks.Configuration()") + if op["public"]: + out.append("# Public endpoint: no API key needed.") + else: + out.append('config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request') + out += ["", "with whoisfreaks.ApiClient(config) as client:", f"{ind}api = whoisfreaks.{cls}(client)", ""] + out += _params_comment(op, ctx, m, ind) + out += pre + if kind == "binary": + fname = download_filename(op, ctx) + out += [f"{ind}data = {call} # the file's raw bytes", + f'{ind}path = "{fname}"', + f'{ind}with open(path, "wb") as f:', + f"{ind} f.write(data)", + f'{ind}print(f"Saved {{len(data)}} bytes to {{os.path.abspath(path)}}")'] + elif kind == "model_list": + out += [f"{ind}results = {call}", + f"{ind}print(json.dumps([item.to_dict() for item in results], indent=2))"] + elif kind == "string_list": + out += [f"{ind}domains = {call}", + f'{ind}print(f"{{len(domains)}} domains")', + f'{ind}print("\\n".join(domains[:10]))'] + elif kind == "text": + out += [f"{ind}new_key = {call} # use this key from now on", + f'{ind}print("New API key:", new_key)'] + else: + out += [f"{ind}result = {call}", + f"{ind}print(json.dumps(result.to_dict(), indent=2))"] + return "\n".join(out) + + +def getting_started(ctx): + pkg = ctx.LANGS[LANG]["pkg"] + cls = ctx.api_class("WHOIS", LANG) + m = ctx.method_name("whoisLive", LANG) + return [ + "1. Create a project folder with a virtual environment and install the SDK:", "", + "```bash", + "mkdir whoisfreaks-test && cd whoisfreaks-test", + "python3 -m venv .venv", + "source .venv/bin/activate # Windows: .venv\\Scripts\\activate", + f"pip install {pkg}", + "```", "", + "2. Create `main.py`:", "", + "```python", + "import os", + "", + "import whoisfreaks", + "", + "config = whoisfreaks.Configuration()", + 'config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] # set once for every request', + "", + "with whoisfreaks.ApiClient(config) as client:", + f' record = whoisfreaks.{cls}(client).{m}("whoisfreaks.com")', + ' print("Domain: ", record.domain_name)', + ' print("Created:", record.create_date)', + ' print("Expires:", record.expiry_date)', + "```", "", + "3. Set your API key and run it:", "", + "```bash", + 'export WHOISFREAKS_API_KEY="your_api_key" # PowerShell: $env:WHOISFREAKS_API_KEY="your_api_key"', + "python main.py", + "```", + ] diff --git a/scripts/docs_lang/ruby.py b/scripts/docs_lang/ruby.py new file mode 100644 index 0000000..af91938 --- /dev/null +++ b/scripts/docs_lang/ruby.py @@ -0,0 +1,192 @@ +"""Ruby example renderer for gen_docs.py (SDK: the whoisfreaks gem). + +Matches the generated Ruby client: required params are positional (spec order, +then the request body), optional params go in the trailing opts hash as +snake_case keywords, API classes are named like WhoisFreaks::WHOISApi, and +downloads come back as a Tempfile that is deleted when the program exits. +""" +import re + +FILES_HOST = "files.whoisfreaks.com" +# Optional params worth showing; every other optional param is left at its default. +SHOWN_OPTIONALS = {"domainName", "keyword", "sug", "count", "page"} +VALUE_OVERRIDES = {"sug": True} # suggestions only matter when turned on + + +# ---- shared helpers (kept local to this module) ----------------------------- +def _is_db(op): + return FILES_HOST in (op.get("server") or "") + + +def _shown(op, p): + if p["required"] or p["name"] in SHOWN_OPTIONALS: + return True + return p["name"] == "date" and _is_db(op) + + +def _value(p, ctx): + return VALUE_OVERRIDES.get(p["name"], ctx.example_value(p)) + + +def _params(op): + return [p for p in op["params"] if p["name"] != "apiKey"] + + +def _response(op, ctx): + item = ctx.spec["paths"][op["path"]][op["method"].lower()] + return ctx.deref((item.get("responses") or {}).get("200") or {}) + + +def _return_kind(op, ctx): + """file | model | models | strings | string""" + if op.get("is_binary"): + return "file" + if op.get("response_schema"): + return "models" if op.get("response_is_array") else "model" + for c in (_response(op, ctx).get("content") or {}).values(): + sch = ctx.deref(c.get("schema") or {}) + return "strings" if sch.get("type") == "array" else "string" + return "string" + + +def _download_name(op, ctx): + return ctx.download_name(op) + + +def _body_fields(op, ctx): + """[(jsonField, value)] for the request body, in the model's property order.""" + ex = ctx.body_example(op) + order = list(((op.get("body_schema") or {}).get("properties") or {}).keys()) + return sorted(ex.items(), key=lambda kv: order.index(kv[0]) if kv[0] in order else len(order)) + + +# ---- Ruby rendering ---------------------------------------------------------- +def _lit(v, p=None): + if p is not None and p.get("format") == "date" and isinstance(v, str): + return f'Date.parse("{v}")' # the generated client documents Date for these + if isinstance(v, bool): + return "true" if v else "false" + if v is None: + return "nil" + if isinstance(v, (int, float)): + return str(v) + if isinstance(v, (list, tuple)): + return "[" + ", ".join(_lit(x) for x in v) + "]" + return '"' + str(v).replace("\\", "\\\\").replace('"', '\\"').replace("#{", "\\#{") + '"' + + +def _call_args(op, ctx): + params = _params(op) + pos = [_lit(_value(p, ctx), p) for p in params if p["required"]] + if op.get("body_model"): + pos.append("request") + opts = [f"{ctx.py_snake(p['name'])}: {_lit(_value(p, ctx), p)}" + for p in params if not p["required"] and _shown(op, p)] + return ", ".join(pos + opts) + + +def _uses_date(op, ctx): + return any(p.get("format") == "date" and _shown(op, p) for p in _params(op)) + + +def _header(op, ctx): + # parameter names as the Ruby client spells them (snake_case) + cmt = re.sub(r"^(# - )(\w+)", lambda m: m.group(1) + ctx.py_snake(m.group(2)), + ctx.params_comment("ruby", op), flags=re.M) + return f"# {op['summary'] or op['op_id']}\n#\n" + cmt + + +def example(op, ctx): + cls = ctx.api_class(op["tag"], "ruby") + method = ctx.method_name(op["op_id"], "ruby") + args = _call_args(op, ctx) + call = f"api.{method}({args})" if args else f"api.{method}" + kind = _return_kind(op, ctx) + + requires = [] + if _uses_date(op, ctx): + requires.append("date") + if kind == "file": + requires.append("fileutils") + if kind in ("model", "models"): + requires.append("json") + lines = [_header(op, ctx), ""] + lines += [f'require "{r}"' for r in sorted(requires)] + ['require "whoisfreaks"', ""] + lines += ["# Read the API key from the environment and set it once."] + if op.get("public"): + lines.append("# (This endpoint is public, so the key is not sent with this request.)") + lines += ["WhoisFreaks.configure do |config|", + ' config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY")', + "end", "", + f"api = WhoisFreaks::{cls}.new"] + if op.get("body_model"): + fields = ", ".join(f"{ctx.py_snake(k)}: {_lit(v)}" for k, v in _body_fields(op, ctx)) + lines += ["", f"request = WhoisFreaks::{op['body_model']}.new({fields})"] + + if kind == "file": + body = [f" file = {call}", + " # The SDK returns a Tempfile that is deleted when the program exits: copy it.", + f' save_as = "{_download_name(op, ctx)}"', + " FileUtils.cp(file.path, save_as)", + ' puts "Saved #{File.expand_path(save_as)} (#{File.size(save_as)} bytes)"'] + elif kind == "model": + body = [f" result = {call}", " puts JSON.pretty_generate(result.to_hash)"] + elif kind == "models": + body = [f" results = {call}", " puts JSON.pretty_generate(results.map(&:to_hash))"] + elif kind == "strings": + body = [f" domains = {call}", " puts domains"] + elif op["op_id"] == "rotateApiKey": + body = [f" new_key = {call}", + " # The old key stops working now: store the new one before making more calls.", + ' puts "New API key: #{new_key}"'] + else: + body = [f" result = {call}", " puts result"] + + lines += ["", "begin"] + body + [ + "rescue WhoisFreaks::ApiError => e", + ' warn "Request failed: HTTP #{e.code} #{e.response_body}"', + " exit 1", + "end"] + return "\n".join(lines) + "\n" + + +def getting_started(ctx): + pkg = ctx.LANGS["ruby"]["pkg"] + v = ctx.SDK_VERSION + return [ + "You need Ruby 2.7 or later and Bundler.", "", + "1. Create a project directory:", "", + "```bash", + "mkdir whoisfreaks-test && cd whoisfreaks-test", + "```", "", + "2. Create a `Gemfile` that pins the SDK:", "", + "```ruby", + 'source "https://rubygems.org"', + "", + f'gem "{pkg}", "~> {v}"', + "```", "", + "3. Install it:", "", + "```bash", + "bundle install", + "```", "", + "4. Create `main.rb`:", "", + "```ruby", + 'require "whoisfreaks"', + "", + "# Read the API key from the environment and set it once.", + "WhoisFreaks.configure do |config|", + ' config.api_key["apiKey"] = ENV.fetch("WHOISFREAKS_API_KEY")', + "end", + "", + 'record = WhoisFreaks::WHOISApi.new.whois_live("whoisfreaks.com")', + "", + 'puts "Registrar: #{record.domain_registrar&.registrar_name}"', + 'puts "Created: #{record.create_date}"', + 'puts "Expires: #{record.expiry_date}"', + "```", "", + "5. Set your API key and run it:", "", + "```bash", + 'export WHOISFREAKS_API_KEY="your_api_key"', + "bundle exec ruby main.rb", + "```", + ] diff --git a/scripts/docs_lang/swift.py b/scripts/docs_lang/swift.py new file mode 100644 index 0000000..ad85f7c --- /dev/null +++ b/scripts/docs_lang/swift.py @@ -0,0 +1,209 @@ +"""Swift example renderer for gen_docs.py (SDK: github.com/WhoisFreaks/whoisfreaks-swift). + +Matches the generated Swift client: async/await class methods on API types +named like WHOISAPI, labels in the generated order (required params in spec +order, then the request body, then optional params in spec order), typed enums +for enum params, OpenAPIDateWithoutTime for date params, the key set once on +WhoisFreaksAPI.apiKey, and downloads returned as a file URL. Examples are +top-level code for an executable target's main.swift. +""" +import re + +FILES_HOST = "files.whoisfreaks.com" +# Optional params worth showing; every other optional param is left at its default. +SHOWN_OPTIONALS = {"domainName", "keyword", "sug", "count", "page"} +VALUE_OVERRIDES = {"sug": True} # suggestions only matter when turned on +TOOLS_VERSION = "5.7" # top-level await in main.swift needs Swift 5.7 + + +# ---- shared helpers (kept local to this module) ----------------------------- +def _is_db(op): + return FILES_HOST in (op.get("server") or "") + + +def _shown(op, p): + if p["required"] or p["name"] in SHOWN_OPTIONALS: + return True + return p["name"] == "date" and _is_db(op) + + +def _value(p, ctx): + return VALUE_OVERRIDES.get(p["name"], ctx.example_value(p)) + + +def _params(op): + return [p for p in op["params"] if p["name"] != "apiKey"] + + +def _response(op, ctx): + item = ctx.spec["paths"][op["path"]][op["method"].lower()] + return ctx.deref((item.get("responses") or {}).get("200") or {}) + + +def _return_kind(op, ctx): + """file | model | models | strings | string""" + if op.get("is_binary"): + return "file" + if op.get("response_schema"): + return "models" if op.get("response_is_array") else "model" + for c in (_response(op, ctx).get("content") or {}).values(): + sch = ctx.deref(c.get("schema") or {}) + return "strings" if sch.get("type") == "array" else "string" + return "string" + + +def _download_name(op, ctx): + return ctx.download_name(op) + + +def _body_fields(op, ctx): + """[(jsonField, value)] for the request body, in the model's property order.""" + ex = ctx.body_example(op) + order = list(((op.get("body_schema") or {}).get("properties") or {}).keys()) + return sorted(ex.items(), key=lambda kv: order.index(kv[0]) if kv[0] in order else len(order)) + + +def _camel(name): + parts = [w for w in re.split(r"[^A-Za-z0-9]+", name) if w] + return parts[0][:1].lower() + parts[0][1:] + "".join(w[:1].upper() + w[1:] for w in parts[1:]) + + +# ---- Swift rendering --------------------------------------------------------- +def _str(v): + return '"' + str(v).replace("\\", "\\\\").replace('"', '\\"') + '"' + + +def _lit(v, p=None): + if p is not None: + if p.get("enum"): + return "." + _camel(str(v)) # typed enum case, e.g. .a + if p.get("format") == "date": + return f"OpenAPIDateWithoutTime(rawValue: {_str(v)})!" + if isinstance(v, bool): + return "true" if v else "false" + if v is None: + return "nil" + if isinstance(v, (int, float)): + return str(v) + if isinstance(v, (list, tuple)): + return "[" + ", ".join(_lit(x) for x in v) + "]" + return _str(v) + + +def _call_args(op, ctx): + params = _params(op) + args = [f"{p['name']}: {_lit(_value(p, ctx), p)}" for p in params if p["required"]] + if op.get("body_model"): + bm = op["body_model"] + args.append(f"{bm[:1].lower() + bm[1:]}: request") + args += [f"{p['name']}: {_lit(_value(p, ctx), p)}" + for p in params if not p["required"] and _shown(op, p)] + return ", ".join(args) + + +def _header(op, ctx): + return (f"// {op['summary'] or op['op_id']}\n//\n" + ctx.params_comment("swift", op) + "\n//\n" + "// Top-level code for Sources//main.swift (see Getting Started).") + + +SETUP = ["import Foundation", "import WhoisFreaks", "", + "// Read the API key from the environment and set it once.", + 'WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"]'] + +CATCH = ["} catch ErrorResponse.error(let status, let data, _, let underlying) {", + ' let body = data.map { String(decoding: $0, as: UTF8.self) } ?? "\\(underlying)"', + ' print("Request failed: HTTP \\(status) \\(body)")', + " exit(1)", + "} catch {", + ' print("Request failed: \\(error)")', + " exit(1)", + "}"] + + +def example(op, ctx): + cls = ctx.api_class(op["tag"], "swift") + method = ctx.method_name(op["op_id"], "swift") + call = f"try await {cls}.{method}({_call_args(op, ctx)})" + kind = _return_kind(op, ctx) + + lines = [_header(op, ctx), ""] + SETUP + if op.get("public"): + lines.append("// (This endpoint is public, so the key is not sent with this request.)") + if op.get("body_model"): + fields = ", ".join(f"{_camel(k)}: {_lit(v)}" for k, v in _body_fields(op, ctx)) + lines += ["", f"let request = {op['body_model']}({fields})"] + + if kind == "file": + body = [f" let file = {call}", + " // The SDK saves the download under the caches directory: move it somewhere permanent.", + f' let saveAs = URL(fileURLWithPath: "{_download_name(op, ctx)}")', + " try? FileManager.default.removeItem(at: saveAs)", + " try FileManager.default.moveItem(at: file, to: saveAs)", + ' print("Saved \\(saveAs.path)")'] + elif kind in ("model", "models"): + body = [f" let result = {call}", + " print(String(decoding: try CodableHelper.jsonEncoder.encode(result), as: UTF8.self))"] + elif kind == "strings": + body = [f" let domains = {call}", ' print(domains.joined(separator: "\\n"))'] + elif op["op_id"] == "rotateApiKey": + body = [f" let newKey = {call}", + " // The old key stops working now: store the new one before making more calls.", + ' print("New API key: \\(newKey)")'] + else: + body = [f" let result = {call}", " print(result)"] + + lines += ["", "do {"] + body + CATCH + return "\n".join(lines) + "\n" + + +def getting_started(ctx): + pkg = ctx.LANGS["swift"]["pkg"] + repo = pkg.rsplit("/", 1)[-1] # SwiftPM package identity, e.g. whoisfreaks-swift + v = ctx.SDK_VERSION + return [ + f"You need Swift {TOOLS_VERSION} or later (Xcode 14+) on macOS 10.15 or later. " + "The SDK uses async/await.", "", + "1. Create an executable package:", "", + "```bash", + "mkdir -p whoisfreaks-test/Sources/WhoisFreaksTest", + "cd whoisfreaks-test", + "```", "", + "2. Create `Package.swift` with the SDK as a dependency:", "", + "```swift", + f"// swift-tools-version:{TOOLS_VERSION}", + "import PackageDescription", + "", + "let package = Package(", + ' name: "WhoisFreaksTest",', + " platforms: [.macOS(.v10_15)],", + " dependencies: [", + f' .package(url: "https://{pkg}.git", from: "{v}"),', + " ],", + " targets: [", + " .executableTarget(", + ' name: "WhoisFreaksTest",', + f' dependencies: [.product(name: "WhoisFreaks", package: "{repo}")]', + " ),", + " ]", + ")", + "```", "", + "3. Create `Sources/WhoisFreaksTest/main.swift`:", "", + "```swift", + "import Foundation", + "import WhoisFreaks", + "", + "// Read the API key from the environment and set it once.", + 'WhoisFreaksAPI.apiKey = ProcessInfo.processInfo.environment["WHOISFREAKS_API_KEY"]', + "", + 'let record = try await WHOISAPI.whoisLive(domainName: "whoisfreaks.com")', + "", + 'print("Registrar:", record.domainRegistrar?.registrarName ?? "-")', + 'print("Created: ", record.createDate ?? "-")', + 'print("Expires: ", record.expiryDate ?? "-")', + "```", "", + "4. Set your API key and run it:", "", + "```bash", + 'export WHOISFREAKS_API_KEY="your_api_key"', + "swift run", + "```", + ] diff --git a/scripts/docs_lang/typescript.py b/scripts/docs_lang/typescript.py new file mode 100644 index 0000000..2fe4b7b --- /dev/null +++ b/scripts/docs_lang/typescript.py @@ -0,0 +1,245 @@ +"""TypeScript example renderer for gen_docs.py (SDK: `whoisfreaks` on npm). + +Matches the openapi-generator `typescript-fetch` client: + * auth: new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY }), set once + * every operation with parameters takes ONE request object, e.g. + whoisLive({ domainName }); the body goes in it under the camelCase model + name (bulkWhois({ bulkWhoisRequest })); operations without parameters take none + * `format: date` params are typed Date: new Date("2026-10-01") (sent as yyyy-MM-dd); + other dates (threat feeds) are plain strings + * request bodies are object literals typed with the model interface + * downloads resolve to a Blob, written with fs/promises writeFile + * code runs inside async main(), so it works as CommonJS or ESM with `npx tsx` + and type-checks under `tsc --strict` +""" +import json + +LANG = "typescript" + +# Optional params worth showing, beyond the always-shown `date` (database +# downloads) and `page` (paginated lookups). None = use the spec example value. +_SHOW_OPTIONAL = { + "domainAvailabilityV2": {"sug": True, "count": None}, + "dnsLive": {"domainName": None}, + "typosquatting": {"keyword": None}, +} + + +def _clean(text): + """One-line text without em/en dashes (house style).""" + return " ".join(str(text).replace(" — ", ": ").replace("—", ", ") + .replace("–", "-").split()) + + +def _shown(op, p): + n = p["name"] + if n == "apiKey": + return False + if p["required"] or n in ("date", "page"): + return True + return n in _SHOW_OPTIONAL.get(op["op_id"], {}) + + +def _value(op, p, ctx): + override = _SHOW_OPTIONAL.get(op["op_id"], {}).get(p["name"]) + return override if override is not None else ctx.example_value(p) + + +def _lit(v, p=None): + if p is not None and p.get("format") == "date": + return f"new Date({json.dumps(str(v))})" + if isinstance(v, bool): + return "true" if v else "false" + if isinstance(v, (int, float)): + return repr(v) + if isinstance(v, list): + return "[" + ", ".join(_lit(x) for x in v) + "]" + return json.dumps(str(v)) + + +def _response_kind(op, ctx): + """binary | model | model_list | string_list | text""" + if op.get("is_binary"): + return "binary" + if op.get("response_schema"): + return "model_list" if op.get("response_is_array") else "model" + resp = ctx.deref(((ctx.spec["paths"][op["path"]][op["method"].lower()].get("responses") or {}) + .get("200")) or {}) + content = resp.get("content") or {} + if "text/plain" in content: + return "text" + sch = ctx.deref((content.get("application/json") or {}).get("schema") or {}) + if sch.get("type") == "array": + return "string_list" + return "model" + + +def download_filename(op, ctx): + return ctx.download_name(op) + + +def _type_label(p): + if p.get("format") == "date": + return "Date" + if p.get("enum"): + return " | ".join(json.dumps(str(e)) for e in p["enum"]) + return {"integer": "number", "boolean": "boolean", "number": "number"}.get(p.get("type"), "string") + + +def _body_key(model): + return model[0].lower() + model[1:] + + +def _params_comment(op, ctx, method): + params = [p for p in op["params"] if p["name"] != "apiKey"] + bm = op.get("body_model") + if not params and not bm: + return [f"// {method}() takes no parameters."] + keys = [p["name"] for p in params if p["required"]] + keys += [_body_key(bm)] if bm else [] + keys += [p["name"] + "?" for p in params if not p["required"]] + lines = [f"// {method}({{ {', '.join(keys)} }})"] + def line(p, kind): + extra = [] + if p.get("default") is not None: + extra.append(f"default {_lit(p['default'])}") + desc = _clean(p.get("desc") or "").rstrip(".") + if len(desc) > 80: + desc = desc[:77] + "..." + tail = "; ".join(x for x in [desc] + extra if x) + return f"// {p['name']} ({_type_label(p)}, {kind})" + (f": {tail}" if tail else "") + for p in params: + if p["required"]: + lines.append(line(p, "required")) + if bm: + lines.append(f"// {_body_key(bm)} ({bm}, required): request body") + for p in params: + if not p["required"]: + lines.append(line(p, "optional")) + return lines + + +def _header(op, run_file): + run = (f"// Run (public endpoint, no API key needed): npx tsx {run_file}" if op["public"] else + f"// Run: WHOISFREAKS_API_KEY=your_api_key npx tsx {run_file}") + return [f"// {_clean(op['summary'] or op['op_id'])}: {op['method']} {op['server']}{op['path']}", run] + + +def example(op, ctx): + cls = ctx.api_class(op["tag"], LANG) + m = ctx.method_name(op["op_id"], LANG) + kind = _response_kind(op, ctx) + bm = op.get("body_model") + ind = " " + + fields, pre = [], [] + for p in op["params"]: + if _shown(op, p) and p["required"]: + fields.append(f"{p['name']}: {_lit(_value(op, p, ctx), p)}") + if bm: + bf = ", ".join(f"{k}: {_lit(v)}" for k, v in ctx.body_example(op).items()) + pre.append(f"{ind}const body: {bm} = {{ {bf} }};") + fields.append(f"{_body_key(bm)}: body") + for p in op["params"]: + if _shown(op, p) and not p["required"]: + fields.append(f"{p['name']}: {_lit(_value(op, p, ctx), p)}") + call = f"api.{m}({{ {', '.join(fields)} }})" if fields else f"api.{m}()" + + values = ([] if op["public"] else ["Configuration"]) + [cls, "ResponseError"] + imp = ", ".join(values + ([f"type {bm}"] if bm else [])) + out = _header(op, f"{ctx.pascal(op['op_id'])}.ts") + if kind == "binary": + out += ['import { writeFile } from "node:fs/promises";', 'import { resolve } from "node:path";'] + out.append(f'import {{ {imp} }} from "{ctx.LANGS[LANG]["pkg"]}";') + out.append("") + if op["public"]: + out += ["// Public endpoint: no API key needed.", f"const api = new {cls}();"] + else: + out += ["// Set the API key once; the client adds it to every request.", + "const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY });", + f"const api = new {cls}(config);"] + out.append("") + out += _params_comment(op, ctx, m) + out.append("async function main(): Promise {") + out += pre + if kind == "binary": + fname = download_filename(op, ctx) + out += [f"{ind}const blob = await {call}; // a Blob with the file's bytes", + f'{ind}const file = "{fname}";', + f"{ind}await writeFile(file, new Uint8Array(await blob.arrayBuffer()));", + f"{ind}console.log(`Saved ${{blob.size}} bytes to ${{resolve(file)}}`);"] + elif kind == "model_list": + out += [f"{ind}const results = await {call};", + f"{ind}console.log(JSON.stringify(results, null, 2));"] + elif kind == "string_list": + out += [f"{ind}const domains = await {call};", + f"{ind}console.log(`${{domains.length}} domains`);", + f'{ind}console.log(domains.slice(0, 10).join("\\n"));'] + elif kind == "text": + out += [f"{ind}const newKey = await {call}; // use this key from now on", + f'{ind}console.log("New API key:", newKey);'] + else: + out += [f"{ind}const result = await {call};", + f"{ind}console.log(JSON.stringify(result, null, 2));"] + out += ["}", "", + "main().catch(async (err: unknown) => {", + " // API errors carry the HTTP response", + " if (err instanceof ResponseError) {", + " console.error(`HTTP ${err.response.status}: ${await err.response.text()}`);", + " } else {", + " console.error(err);", + " }", + " process.exitCode = 1;", + "});"] + return "\n".join(out) + + +def getting_started(ctx): + pkg = ctx.LANGS[LANG]["pkg"] + cls = ctx.api_class("WHOIS", LANG) + m = ctx.method_name("whoisLive", LANG) + return [ + "1. Create a project and install the SDK (Node.js 18 or later), plus " + "[tsx](https://tsx.is) to run TypeScript files directly:", "", + "```bash", + "mkdir whoisfreaks-test && cd whoisfreaks-test", + "npm init -y", + f"npm install {pkg}", + "npm install -D tsx @types/node", + "```", "", + "2. Create `main.ts`:", "", + "```typescript", + f'import {{ Configuration, {cls}, ResponseError }} from "{pkg}";', + "", + "// Set the API key once; the client adds it to every request.", + "const config = new Configuration({ apiKey: process.env.WHOISFREAKS_API_KEY });", + f"const api = new {cls}(config);", + "", + "async function main(): Promise {", + f' const record = await api.{m}({{ domainName: "whoisfreaks.com" }});', + ' console.log("Domain: ", record.domain_name);', + ' console.log("Created:", record.create_date);', + ' console.log("Expires:", record.expiry_date);', + "}", + "", + "main().catch(async (err: unknown) => {", + " if (err instanceof ResponseError) {", + " console.error(`HTTP ${err.response.status}: ${await err.response.text()}`);", + " } else {", + " console.error(err);", + " }", + " process.exitCode = 1;", + "});", + "```", "", + "3. Set your API key and run it:", "", + "```bash", + 'export WHOISFREAKS_API_KEY="your_api_key" # PowerShell: $env:WHOISFREAKS_API_KEY="your_api_key"', + "npx tsx main.ts", + "```", "", + "`tsx` runs the file without a separate compile step. To type-check as well, " + "add the compiler and run it in strict mode:", "", + "```bash", + "npm install -D typescript", + "npx tsc --noEmit --strict --module nodenext --types node main.ts", + "```", + ] diff --git a/scripts/gen_docs.py b/scripts/gen_docs.py index 95076b0..6760821 100644 --- a/scripts/gen_docs.py +++ b/scripts/gen_docs.py @@ -16,7 +16,10 @@ SPEC = sys.argv[1] if len(sys.argv) > 1 else "spec/whoisfreaks-openapi.yaml" OUT = pathlib.Path(sys.argv[2] if len(sys.argv) > 2 else "docs-repo") -OWNER = os.environ.get("OWNER", "whoisfreaks") +# GitHub org that owns the SDK repos; Go module and Swift package paths use it. +OWNER = os.environ.get("OWNER", "WhoisFreaks") +# SDK release these docs describe; install lines pin to it. +SDK_VERSION = os.environ.get("SDK_VERSION", "0.23.0") spec = yaml.safe_load(open(SPEC)) comps = spec.get("components", {}) @@ -35,16 +38,16 @@ def deref(node): "javascript": {"label": "JavaScript", "registry": "npm", "pkg": "whoisfreaks-js"}, "typescript": {"label": "TypeScript", "registry": "npm", "pkg": "whoisfreaks"}, "java": {"label": "Java", "registry": "Maven Central", "pkg": "com.whoisfreaks:whoisfreaks"}, - "kotlin": {"label": "Kotlin", "registry": "Maven Central", "pkg": "com.whoisfreaks:whoisfreaks"}, + "kotlin": {"label": "Kotlin", "registry": "Maven Central", "pkg": "com.whoisfreaks:whoisfreaks-kotlin"}, "csharp": {"label": "C# / .NET", "registry": "NuGet", "pkg": "WhoisFreaks"}, "ruby": {"label": "Ruby", "registry": "RubyGems", "pkg": "whoisfreaks"}, "go": {"label": "Go", "registry": "Go modules", "pkg": f"github.com/{OWNER}/whoisfreaks-go"}, "swift": {"label": "Swift", "registry": "Swift PM", "pkg": f"github.com/{OWNER}/whoisfreaks-swift"}, - "php": {"label": "PHP", "registry": "Packagist", "pkg": f"{OWNER}/whoisfreaks-php"}, + "php": {"label": "PHP", "registry": "Packagist", "pkg": "whoisfreaks/whoisfreaks-php"}, # Packagist names are lowercase } LANG_ORDER = list(LANGS.keys()) -def install_snippet(lang, version="LATEST"): +def install_snippet(lang, version=SDK_VERSION): m = LANGS[lang]; pkg = m["pkg"] if lang == "python": return "bash", f"pip install {pkg}" @@ -71,272 +74,6 @@ def install_snippet(lang, version="LATEST"): return "bash", "" # ---- per-language "create a new project" walkthrough ------------------------ -def getting_started(lang): - """Full copy-paste steps: make a fresh project, add the SDK, and run. - Written so someone with only the language's toolchain installed can go - from empty directory to a running program.""" - m = LANGS[lang]; pkg = m["pkg"] - S = [] # list of (markdown) lines - - if lang == "python": - S += [ - "```bash", - "mkdir whoisfreaks-test && cd whoisfreaks-test", - "python3 -m venv .venv", - "source .venv/bin/activate # Windows: .venv\\Scripts\\activate", - f"pip install {pkg}", - "```", - "", - "Create `main.py`:", "", - "```python", - "from whoisfreaks import Configuration, ApiClient", - "from whoisfreaks.api.whois_api import WHOISApi", - "", - "config = Configuration()", - 'config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once', - "api = WHOISApi(ApiClient(config))", - "", - 'result = api.whois_live(domain_name="example.com")', - "print(result)", - "```", - "", - "Run it:", "", - "```bash", "python main.py", "```", - ] - elif lang in ("javascript", "typescript"): - ext = "js" if lang == "javascript" else "ts" - S += [ - "```bash", - "mkdir whoisfreaks-test && cd whoisfreaks-test", - "npm init -y", - f"npm install {pkg}", - ] - if lang == "typescript": - S += ["npm install -D typescript ts-node @types/node"] - S += ["```", ""] - if lang == "typescript": - # TS package is ESM - S += ["Set `\"type\": \"module\"` in `package.json`, then create " - f"`main.{ext}`:", "", f"```{ext}", - f'import {{ Configuration, WHOISApi }} from "{pkg}";', "", - 'const config = new Configuration({ apiKey: "YOUR_API_KEY" }); // set once', - "const api = new WHOISApi(config);", "", - 'const result = await api.whoisLive({ domainName: "example.com" });', - "console.log(result);", "```", "", "Run it:", "", - "```bash", f"npx ts-node main.{ext}", "```"] - else: - # JS package uses the `javascript` generator: apiKey set once on ApiClient. - S += [f"Create `main.{ext}`:", "", f"```{ext}", - f'import pkg from "{pkg}";', - "const { ApiClient, WHOISApi } = pkg;", - f'// or: const {{ ApiClient, WHOISApi }} = require("{pkg}");', "", - "const client = ApiClient.instance;", - 'client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once', - "const api = new WHOISApi(client);", "", - 'api.whoisLive("example.com")', - " .then(data => console.log(data))", - " .catch(err => console.error(err));", "```", "", "Run it:", "", - "```bash", f"node main.{ext}", "```"] - elif lang == "csharp": - S += [ - "```bash", - "mkdir whoisfreaks-test && cd whoisfreaks-test", - "dotnet new console", - f"dotnet add package {pkg}", - "```", - "", - "Replace `Program.cs` with:", "", - "```csharp", - "using System;", - "using WhoisFreaks.Api;", - "using WhoisFreaks.Client;", - "", - "var config = new Configuration { BasePath = \"https://api.whoisfreaks.com\" };", - "config.AddApiKey(\"ApiKeyAuth\", \"YOUR_API_KEY\"); // set once", - "var api = new WHOISApi(config);", - "", - 'var result = api.WhoisLive("example.com");', - "Console.WriteLine(result);", - "```", - "", - "Run it:", "", - "```bash", "dotnet run", "```", - ] - elif lang == "go": - mod = pkg # github.com//whoisfreaks-go - S += [ - "```bash", - "mkdir whoisfreaks-test && cd whoisfreaks-test", - "go mod init whoisfreaks-test # creates go.mod (required)", - f"go get {mod}", - "```", - "", - "> **Note:** `go get` only works inside a module. If you see " - "*'go.mod file not found'*, run `go mod init ` first (as above).", - "", - "Create `main.go`:", "", - "```go", - "package main", - "", - "import (", - " \"context\"", - " \"encoding/json\"", - " \"fmt\"", - f" wf \"{mod}\"", - ")", - "", - "func main() {", - " cfg := wf.NewConfiguration()", - " client := wf.NewAPIClient(cfg)", - " // apiKey is set once via the request context", - " ctx := context.WithValue(context.Background(), wf.ContextAPIKeys,", - " map[string]wf.APIKey{\"ApiKeyAuth\": {Key: \"YOUR_API_KEY\"}})", - " result, _, err := client.WHOISAPI.WhoisLive(ctx).DomainName(\"example.com\").Execute()", - " if err != nil { panic(err) }", - " b, _ := json.MarshalIndent(result, \"\", \" \")", - " fmt.Println(string(b))", - "}", - "```", - "", - "Run it:", "", - "```bash", "go mod tidy", "go run main.go", "```", - ] - elif lang == "java": - g, a = pkg.split(":") - S += [ - "Create a Maven project and add the dependency to `pom.xml`:", "", - "```xml", - "", - f" {g}", - f" {a}", - " LATEST ", - "", - "```", - "", - "`src/main/java/Main.java`:", "", - "```java", - "import com.whoisfreaks.client.ApiClient;", - "import com.whoisfreaks.client.Configuration;", - "import com.whoisfreaks.client.auth.ApiKeyAuth;", - "import com.whoisfreaks.client.api.WhoisApi;", - "", - "public class Main {", - " public static void main(String[] args) throws Exception {", - " ApiClient client = Configuration.getDefaultApiClient();", - " client.setBasePath(\"https://api.whoisfreaks.com\");", - " ((ApiKeyAuth) client.getAuthentication(\"ApiKeyAuth\")).setApiKey(\"YOUR_API_KEY\"); // set once", - " WhoisApi api = new WhoisApi(client);", - " var result = api.whoisLive(\"example.com\");", - " System.out.println(result);", - " }", - "}", - "```", - "", - "Build and run with `mvn compile exec:java -Dexec.mainClass=Main` " - "(or your IDE).", - ] - elif lang == "kotlin": - S += [ - "In a Gradle project, add to `build.gradle.kts`:", "", - "```kotlin", - "repositories { mavenCentral() }", - "dependencies {", - f' implementation("{pkg}:LATEST") // pin to a real version, e.g. 1.0.0', - "}", - "```", - "", - "`src/main/kotlin/Main.kt`:", "", - "```kotlin", - "import com.whoisfreaks.client.apis.WhoisApi", - "import com.whoisfreaks.client.infrastructure.ApiClient", - "", - "fun main() {", - " ApiClient.apiKey[\"apiKey\"] = \"YOUR_API_KEY\" // set once", - " val api = WhoisApi()", - " val result = api.whoisLive(\"example.com\")", - " println(result)", - "}", - "```", - "", - "Run with `./gradlew run` (with the application plugin) or your IDE.", - ] - elif lang == "ruby": - S += [ - "```bash", - "mkdir whoisfreaks-test && cd whoisfreaks-test", - f"gem install {pkg}", - "```", - "", - "Create `main.rb`:", "", - "```ruby", - "require 'whoisfreaks'", - "", - "WhoisFreaks.configure do |config|", - " config.api_key[\"apiKey\"] = \"YOUR_API_KEY\" # set once", - "end", - "", - "api = WhoisFreaks::WhoisApi.new", - "result = api.whois_live(\"example.com\")", - "puts result", - "```", - "", - "Run it:", "", - "```bash", "ruby main.rb", "```", - ] - elif lang == "php": - S += [ - "```bash", - "mkdir whoisfreaks-test && cd whoisfreaks-test", - "composer init --no-interaction", - f"composer require {pkg}", - "```", - "", - "Create `main.php`:", "", - "```php", - "setApiKey(\"apiKey\", \"YOUR_API_KEY\"); // set once", - "$api = new WhoisFreaks\\Api\\WhoisApi(new GuzzleHttp\\Client(), $config);", - "$result = $api->whoisLive(\"example.com\");", - "print_r($result);", - "```", - "", - "Run it:", "", - "```bash", "php main.php", "```", - ] - elif lang == "swift": - S += [ - "```bash", - "mkdir whoisfreaks-test && cd whoisfreaks-test", - "swift package init --type executable", - "```", - "", - "Add the dependency to `Package.swift`:", "", - "```swift", - f'.package(url: "https://{pkg}.git", from: "1.0.0"),', - "```", - "", - "…and list `WhoisFreaks` as a target dependency. Then in " - "`Sources/.../main.swift`:", "", - "```swift", - "import WhoisFreaks", - "", - "WhoisFreaksAPI.apiKey = \"YOUR_API_KEY\" // set once", - "", - "do {", - " let result = try await WHOISAPI.whoisLive(domainName: \"example.com\")", - " print(result)", - "} catch {", - " print(error)", - "}", - "```", - "", - "Run it:", "", - "```bash", "swift run", "```", - ] - return S # ---- operationId -> per-language method name -------------------------------- def split_words(op_id): @@ -359,44 +96,30 @@ def method_name(op_id, lang): return op_id # ---- collect operations, grouped by tag ------------------------------------- -import subprocess, glob - -def _java_body_models(): - """Authoritative operationId->bodyModel map, read from a generated Java SDK - if available (sdks/java). The generated code is the source of truth for the - exact model class name (e.g. bulkDomainAvailabilityV2 -> BulkDomainAvailabilityRequest, - NOT the spec-derived guess). Falls back to {} if no SDK present.""" - mp = {} - roots = glob.glob("sdks/java/**/api/*.java", recursive=True) - pat = re.compile(r"public\s+\S+\s+([a-zA-Z0-9]+)\(String apiKey,\s+([A-Za-z0-9]+Request)\s") - for fp in roots: - try: - txt = open(fp).read() - except Exception: - continue - for mth, model in pat.findall(txt): - mp[mth] = model - return mp - -_BODY_MAP = _java_body_models() +import json +# Inline request bodies become models named Request, except that +# openapi-generator reuses the first model when two inline schemas are identical +# (bulkIpReputation's body is the same as bulkGeolocation's: BulkGeolocationRequest). +_INLINE_BODY_NAMES = {} def _body_model(op): rb = op.get("requestBody") if not rb: return None - # 1) authoritative: name from generated Java SDK, keyed by operationId - oid = op.get("operationId") or "" - if oid in _BODY_MAP: - return _BODY_MAP[oid] - # 2) $ref in the spec - rb = deref(rb) - sch = ((rb.get("content") or {}).get("application/json") or {}).get("schema") or {} + sch = ((deref(rb).get("content") or {}).get("application/json") or {}).get("schema") or {} if sch.get("$ref"): return sch["$ref"].split("/")[-1] - # 3) last-resort synth (inline body, no generated SDK to consult) - words = re.sub(r"(.)([A-Z][a-z]+)", r"\1 \2", oid) - words = re.sub(r"([a-z0-9])([A-Z])", r"\1 \2", words) - return "".join(w.capitalize() for w in re.split(r"[\s_]+", words) if w) + "Request" + key = json.dumps({k: v for k, v in sch.items() if k != "example"}, sort_keys=True) + if key not in _INLINE_BODY_NAMES: + oid = op.get("operationId") or "" + _INLINE_BODY_NAMES[key] = oid[:1].upper() + oid[1:] + "Request" + return _INLINE_BODY_NAMES[key] + +def _body_schema(op): + rb = op.get("requestBody") + if not rb: + return None + return deref(((deref(rb).get("content") or {}).get("application/json") or {}).get("schema") or {}) def collect(): out = {} @@ -416,6 +139,8 @@ def collect(): "type": sc.get("type", "string"), "enum": sc.get("enum"), "default": sc.get("default"), + "format": sc.get("format"), + "example": pa.get("example", sc.get("example")), "desc": (pa.get("description") or "").strip(), }) # detect binary/file-download responses (application/octet-stream @@ -429,6 +154,7 @@ def collect(): ) # resolve the 200 JSON response schema name (for a response-fields table) _resp_schema = None + _resp_is_array = False for _ct, _cv in _content.items(): if _ct.startswith("application/json"): _sc = deref(_cv).get("schema") or {} @@ -436,7 +162,9 @@ def collect(): _resp_schema = _sc["$ref"].split("/")[-1] elif _sc.get("type") == "array" and "$ref" in (_sc.get("items") or {}): _resp_schema = _sc["items"]["$ref"].split("/")[-1] + _resp_is_array = True break + _servers = op.get("servers") or item.get("servers") or spec["servers"] out.setdefault(tag, []).append({ "tag": tag, "method": method.upper(), @@ -447,8 +175,12 @@ def collect(): "params": params, "request_body": bool(op.get("requestBody")), "body_model": _body_model(op), + "body_schema": _body_schema(op), "is_binary": _is_binary, "response_schema": _resp_schema, + "response_is_array": _resp_is_array, + "server": _servers[0]["url"], + "public": op.get("security") == [], }) return out @@ -457,6 +189,54 @@ def collect(): def slug(tag): return re.sub(r"[^a-z0-9]+", "-", tag.lower()).strip("-") +# ---- example values shared by the per-language renderers -------------------- +FALLBACK_EXAMPLES = {"domainName": "whoisfreaks.com", "domain": "whoisfreaks.com", + "ip": "8.8.8.8", "ipAddress": "8.8.8.8", "asn": "AS15169", + "keyword": "whoisfreaks", "value": "8.8.8.8"} +def example_value(p): + """A realistic value for parameter p as a Python value: the spec example, else + the default, else a fallback by name/type. Dates are 'YYYY-MM-DD' strings; + p['format'] == 'date' tells a renderer to use the language's date type.""" + if p.get("example") is not None: + return p["example"] + if p.get("default") is not None: + return p["default"] + if p["name"] in FALLBACK_EXAMPLES: + return FALLBACK_EXAMPLES[p["name"]] + if p.get("enum"): + return p["enum"][0] + if p.get("format") == "date": + return "2026-10-01" + return {"boolean": True, "integer": 1}.get(p["type"], "example") + +def download_name(op): + """File name a download example saves to: plus the extension the + spec's 200 response description names (CSV, ZIP archive, JSON, JSON gzipped).""" + r = deref(((spec["paths"][op["path"]][op["method"].lower()].get("responses") or {}).get("200")) or {}) + d = (r.get("description") or "").lower() + if "gzip" in d: + ext = "json.gz" if "json" in d else "gz" + elif "zip" in d: + ext = "zip" + elif "json" in d: + ext = "json" + elif "csv" in d: + ext = "csv" + else: + ext = "bin" + return f"{_pascal(op['op_id'])}.{ext}" + +BODY_EXAMPLES = {"domainNames": ["whoisfreaks.com", "example.com"], "ips": ["8.8.8.8", "1.1.1.1"]} +def body_example(op): + """Example request body as {jsonFieldName: value}: the spec example if any, + else the required fields (or the main list field) with sample values.""" + sch = op.get("body_schema") or {} + if sch.get("example"): + return dict(sch["example"]) + props = sch.get("properties") or {} + fields = sch.get("required") or [k for k in BODY_EXAMPLES if k in props][:1] + return {k: BODY_EXAMPLES.get(k, ["example"]) for k in fields} + # ---- example call renderer (per language) ----------------------------------- def api_class(tag, lang): """Generated API class/type name for a tag. VERIFIED against all 10 real @@ -499,112 +279,11 @@ def py_module(cls): s = re.sub(r"([A-Z]+)([A-Z][a-z])", r"\1_\2", s) return s.lower() -def py_param(name): - """Python parameter name as the generator emits it. openapi-generator - prefixes 'var_' when a param collides with a Python builtin/type/keyword - (e.g. 'date' -> 'var_date'). Used only for call keyword args, NOT for - module/model names.""" - s = py_snake(name) - PY_RESERVED = {"date", "datetime", "time", "type", "id", "hash", - "input", "list", "dict", "set", "str", "bytes", "object", - "class", "def", "from", "import", "global", "property"} - return "var_" + s if s in PY_RESERVED else s - -def param_value(p): - name = p["name"] - # date-typed params get distinct sentinels resolved per-language: - # date -> yesterday (runtime) - # after -> 2000-01-01 (fixed lower bound) - # before -> today (runtime) - if name == "after": - return "__DATE_2000__" - if name == "before": - return "__TODAY__" - if name == "date" or p.get("format") == "date": - return "__YESTERDAY__" - if name.lower() == "whois" and p["type"] == "boolean": - return "false" # whois flag defaults to false - if name.lower() == "exact" and p["type"] == "boolean": - return "true" # exact defaults to true - if "domain" in name.lower(): - return "example.com" - if "ip" in name.lower(): - return "8.8.8.8" - if name.lower() == "asn": - return "AS15169" - if p["enum"]: - return p["enum"][0] - if p["type"] == "boolean": - return "false" # all other booleans default false - if p["type"] == "integer": - return "1" - return "value" # yesterday-at-runtime expression + value literal per language ---------------- -YESTERDAY_EXPR = { - "python": "str(date.today() - timedelta(days=1))", - "javascript": "new Date(Date.now()-86400000).toISOString().slice(0,10)", - "typescript": "new Date(Date.now()-86400000).toISOString().slice(0,10)", - "java": "java.time.LocalDate.now().minusDays(1).toString()", - "kotlin": "java.time.LocalDate.now().minusDays(1).toString()", - "csharp": "DateTime.UtcNow.AddDays(-1).ToString(\"yyyy-MM-dd\")", - "ruby": "(Date.today - 1).to_s", - "go": "time.Now().AddDate(0,0,-1).Format(\"2006-01-02\")", - "php": "(new DateTime(\"yesterday\"))->format(\"Y-m-d\")", - "swift": "String(ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: -1, to: Date())!).prefix(10))", -} -TODAY_EXPR = { - "python": "str(date.today())", - "javascript": "new Date().toISOString().slice(0,10)", - "typescript": "new Date().toISOString().slice(0,10)", - "java": "java.time.LocalDate.now().toString()", - "kotlin": "java.time.LocalDate.now().toString()", - "csharp": "DateTime.UtcNow.ToString(\"yyyy-MM-dd\")", - "ruby": "Date.today.to_s", - "go": "time.Now().Format(\"2006-01-02\")", - "php": "(new DateTime(\"today\"))->format(\"Y-m-d\")", - "swift": "String(ISO8601DateFormatter().string(from: Date()).prefix(10))", -} # fixed lower-bound date for `after`; a plain quoted literal in every language -DATE_2000 = "2000-01-01" # languages whose date expressions need extra imports / the 'time' package -YESTERDAY_IMPORT = { - "python": "from datetime import date, timedelta", - "ruby": "require 'date'", - "go": None, # 'time' added to import block by the go renderer -} -def _uses_runtime_date(v): - return v in ("__YESTERDAY__", "__TODAY__") - -def lang_literal(lang, value, p): - """Render a param value as a code literal for the given language. - Handles date sentinels (yesterday/today/fixed-2000), booleans, strings.""" - is_bool = p.get("type") == "boolean" - if value == "__YESTERDAY__": - return YESTERDAY_EXPR.get(lang, '"2000-01-01"'), True - if value == "__TODAY__": - return TODAY_EXPR.get(lang, '"2000-01-01"'), True - if value == "__DATE_2000__": - return f'"{DATE_2000}"', False # fixed literal, quoted like a string - if is_bool: - truthy = str(value).lower() == "true" - if lang == "python": - return ("True" if truthy else "False"), True - return ("true" if truthy else "false"), True - return f'"{value}"', False - -def ordered_args(op, include_key=True): - """Ordered (name, value) for the call: required params first (incl apiKey).""" - out = [] - for p in op["params"]: - if p["name"] == "apiKey": - if include_key: - out.append(("apiKey", "YOUR_API_KEY", p)) - continue - if p["required"] or p["name"] in ("domainName", "ipAddress", "asn"): - out.append((p["name"], param_value(p), p)) - return out COMMENT_PREFIX = { "python": "# ", "ruby": "# ", "go": "// ", "php": "// ", @@ -619,7 +298,7 @@ def params_comment(lang, op): any_p = False for p in op["params"]: any_p = True - req = "required" if (p["required"] or p["name"] in ("apiKey","domainName","ipAddress","asn")) else "optional" + req = "required" if p["required"] else "optional" t = p.get("type") or "string" if p.get("enum"): t += " (one of: " + ", ".join(str(e) for e in p["enum"]) + ")" @@ -629,331 +308,36 @@ def params_comment(lang, op): if desc: line += f": {desc}" lines.append(line) if op.get("body_model"): - lines.append(f"{pre} - body: {op['body_model']} (required) -- request body object") + lines.append(f"{pre} - body: {op['body_model']} (required): request body object") if not any_p and not op.get("body_model"): - lines.append(f"{pre} (no parameters; the API key is set on the client)") + lines.append(f"{pre} (no parameters" + ("; no API key required)" if op.get("public") + else "; the API key is set on the client)")) return "\n".join(lines) def _pascal(op_id): return "".join(w.capitalize() for w in split_words(op_id)) or "Example" -def _full_args(op): - """Every argument in the SDK method's positional order: - apiKey, required query/path params, requestBody (if any), then optionals. - Value is None for optional params (rendered as null/None).""" - required = [] - optional = [] - for p in op["params"]: - if p["name"] == "apiKey": - required.append(("apiKey", "YOUR_API_KEY", p)); continue - if p["required"] or p["name"] in ("domainName", "ipAddress", "asn"): - required.append((p["name"], param_value(p), p)) - elif p["name"] in ("date", "after", "before") or p.get("format") == "date": - # date params are commonly the key input for download endpoints; - # always show them even when technically optional. - required.append((p["name"], param_value(p), p)) - elif p["name"].lower() in ("whois", "exact") and p["type"] == "boolean": - # show these flags with their chosen defaults (whois=false, exact=true) - required.append((p["name"], param_value(p), p)) - else: - optional.append((p["name"], None, p)) - body = [] - if op.get("body_model"): - # generator puts the body param right after apiKey & path/query requireds - bm = op["body_model"] - bname = bm[0].lower() + bm[1:] # e.g. BulkWhoisRequest -> bulkWhoisRequest - body = [("__BODY__:" + bname, bm, {"in": "body", "required": True, "name": bname})] - return required + body + optional - -def _body_ctor(lang, model): - """A minimal request-body construction line, or (None,None).""" - if not model: return None - if lang=="python": return f"{model}()" - if lang in ("javascript","typescript"): return "{}" - if lang=="java": return f"new {model}()" - if lang=="kotlin": return f"{model}()" - if lang=="csharp": return f"new {model}()" - if lang=="ruby": return f"WhoisFreaks::{model}.new" - if lang=="go": return f"*wf.New{model}()" - if lang=="php": return f"new WhoisFreaks\\Model\\{model}()" - if lang=="swift": return f"{model}()" - return None -def runnable_example(lang, op): - m = method_name(op["op_id"], lang) - cls = api_class(op["tag"], lang) - P = _pascal(op["op_id"]) - args = _full_args(op) # ordered (name, value, param) - bm = op.get("body_model") - - def is_body(k): return k.startswith("__BODY__:") - def lit(v, p=None): - if v is None: return "null" - if p is not None: - code, _ = lang_literal(lang, v, p) - return code - return f'"{v}"' - # track whether any date/yesterday expr is used (for imports) - uses_yesterday = any(v in ("__YESTERDAY__","__TODAY__") for _, v, _ in args) - pcmt_all = params_comment(lang, op) +# ---- per-language renderers: scripts/docs_lang/.py --------------------- +# Each module defines example(op, ctx) and getting_started(ctx); ctx carries the +# shared helpers below. +import importlib, types +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +CTX = types.SimpleNamespace( + OWNER=OWNER, SDK_VERSION=SDK_VERSION, LANGS=LANGS, spec=spec, deref=deref, + install_snippet=install_snippet, method_name=method_name, api_class=api_class, + go_accessor=go_accessor, py_snake=py_snake, py_module=py_module, + params_comment=params_comment, pascal=_pascal, split_words=split_words, + example_value=example_value, body_example=body_example, download_name=download_name) - if lang == "python": - mod = py_module(cls) - parts=[]; pre=""; needs_date=False - for k,v,p in args: - if is_body(k): - var = py_snake(bm) - pre = f"{var} = {bm}() # populate fields as needed\n" - parts.append(f"{py_snake(k.split(':')[1])}={var}") - elif v is None: - continue # optional -> omit (has default) - else: - lit_v, _isc = lang_literal("python", v, p) - if v in ("__YESTERDAY__","__TODAY__"): needs_date=True - parts.append(f"{py_param(k)}={lit_v}") - date_imp = (YESTERDAY_IMPORT["python"] + "\n") if needs_date else "" - pcmt = params_comment("python", op) + "\n" - imp = f"from whoisfreaks.models.{py_snake(bm)} import {bm}\n" if bm else "" - if op.get("is_binary"): - fname = (op["op_id"] or "download") + ".gz" - return (f'"""Runnable example: {op["summary"]} ({op["method"]} {op["path"]}).\n' - f'Returns raw bytes (a compressed/binary file) -- write to disk, do not print."""\n' - f"{date_imp}from whoisfreaks import Configuration, ApiClient\n" - f"from whoisfreaks.api.{mod} import {cls}\n\n" - f"{pcmt}" - f"config = Configuration()\n" - f'config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once\n' - f"api = {cls}(ApiClient(config))\n\n" - f"data = api.{m}({', '.join(parts)}) # bytes\n" - f'with open("{fname}", "wb") as f:\n' - f" f.write(data)\n" - f'print(f"saved {{len(data)}} bytes to {fname}")\n') - return (f'"""Runnable example: {op["summary"]} ({op["method"]} {op["path"]})."""\n' - f"{date_imp}from whoisfreaks import Configuration, ApiClient\n" - f"from whoisfreaks.api.{mod} import {cls}\n{imp}\n" - f"{pcmt}" - f"config = Configuration()\n" - f'config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" # set once\n' - f"api = {cls}(ApiClient(config))\n\n" - f"{pre}result = api.{m}({', '.join(parts)})\n" - f"print(result)\n") - - if lang in ("javascript","typescript"): - obj=[] - for k,v,p in args: - if is_body(k): - obj.append(f"{k.split(':')[1]}: {{}}") - elif v is None: - obj.append(f"{k}: undefined") - else: - cv,_=lang_literal(lang,v,p); obj.append(f'{k}: {cv}') - objs = ", ".join(obj) - if lang == "typescript": - # TS package is ESM: named imports work. apiKey set once in Configuration. - return (f'// Runnable example: {op["summary"]} ({op["method"]} {op["path"]})\n' - f"{pcmt_all}\n" - f'import {{ Configuration, {cls} }} from "whoisfreaks";\n\n' - f'const config = new Configuration({{ apiKey: "YOUR_API_KEY" }}); // set once\n' - f'const api = new {cls}(config);\n\n' - f"async function main() {{\n" - f" const result = await api.{m}({{ {objs} }});\n" - f" console.log(result);\n" - f"}}\nmain().catch(console.error);\n") - # JavaScript package (whoisfreaks-js) uses the `javascript` generator: - # no Configuration class; apiKey is passed positionally; methods return - # Promises. Config/auth lives on ApiClient (ApiClient.instance by default). - # Build positional args: apiKey, required params, then an opts object for optionals. - pos = [] - opts = [] - for k, v, p in args: - if is_body(k): - pos.append("{}") - elif v is None: - cv = "undefined" - opts.append(f"{k}: undefined") - else: - cv, _ = lang_literal("javascript", v, p) - # first positional args are the required ones (apiKey/domain/etc.) - if p.get("required") or k in ("apiKey", "domainName", "ipAddress", "asn") \ - or k in ("date","after","before") or (p.get("type")=="boolean" and k.lower() in ("whois","exact")): - pos.append(cv) - else: - opts.append(f"{k}: {cv}") - pos_str = ", ".join(pos) - real_opts = [o for o in opts if not o.endswith(": undefined")] - opts_str = (", { " + ", ".join(real_opts) + " }") if real_opts else "" - return (f'// Runnable example: {op["summary"]} ({op["method"]} {op["path"]})\n' - f"{pcmt_all}\n" - f'// whoisfreaks-js is CommonJS; apiKey is set once on the ApiClient\n' - f'import pkg from "whoisfreaks-js";\n' - f"const {{ ApiClient, {cls} }} = pkg;\n" - f'// or: const {{ ApiClient, {cls} }} = require("whoisfreaks-js");\n\n' - f"const client = ApiClient.instance;\n" - f'client.authentications["ApiKeyAuth"].apiKey = "YOUR_API_KEY"; // set once\n' - f"const api = new {cls}(client);\n\n" - f"api.{m}({pos_str}{opts_str})\n" - f" .then(data => console.log(data))\n" - f" .catch(err => console.error(err));\n") - - if lang == "java": - pos=", ".join(f"new {bm}()" if is_body(k) else lit(v,p) for k,v,p in args) - imp = f"import com.whoisfreaks.client.model.{bm};\n" if bm else "" - return (f"// Runnable example: {op['summary']} ({op['method']} {op['path']})\n" - f"{pcmt_all}\n" - f"import com.whoisfreaks.client.ApiClient;\n" - f"import com.whoisfreaks.client.Configuration;\n" - f"import com.whoisfreaks.client.auth.ApiKeyAuth;\n" - f"import com.whoisfreaks.client.api.{cls};\n{imp}\n" - f"public class {P} {{\n" - f" public static void main(String[] args) throws Exception {{\n" - f" ApiClient client = Configuration.getDefaultApiClient();\n" - f' client.setBasePath("https://api.whoisfreaks.com");\n' - f' ((ApiKeyAuth) client.getAuthentication("ApiKeyAuth")).setApiKey("YOUR_API_KEY"); // set once\n' - f" {cls} api = new {cls}(client);\n" - f" var result = api.{m}({pos});\n" - f" System.out.println(result);\n" - f" }}\n}}\n") - - if lang == "kotlin": - pos=", ".join(f"{bm}()" if is_body(k) else lit(v,p) for k,v,p in args) - imp = f"import com.whoisfreaks.client.models.{bm}\n" if bm else "" - return (f"// Runnable example: {op['summary']} ({op['method']} {op['path']})\n" - f"{pcmt_all}\n" - f"import com.whoisfreaks.client.apis.{cls}\n" - f"import com.whoisfreaks.client.infrastructure.ApiClient\n{imp}\n" - f"fun main() {{\n" - f' ApiClient.apiKey["apiKey"] = "YOUR_API_KEY" // set once\n' - f" val api = {cls}()\n" - f" val result = api.{m}({pos})\n" - f" println(result)\n" - f"}}\n") - - if lang == "csharp": - pos=", ".join(f"new {bm}()" if is_body(k) else lit(v,p) for k,v,p in args) - imp = "using WhoisFreaks.Model;\n" if bm else "" - return (f"// Runnable example: {op['summary']} ({op['method']} {op['path']})\n" - f"{pcmt_all}\n" - f"using System;\nusing WhoisFreaks.Api;\nusing WhoisFreaks.Client;\n{imp}\n" - f"class {P} {{\n" - f" static void Main() {{\n" - f' var config = new Configuration {{ BasePath = "https://api.whoisfreaks.com" }};\n' - f' config.AddApiKey("ApiKeyAuth", "YOUR_API_KEY"); // set once\n' - f" var api = new {cls}(config);\n" - f" var result = api.{m}({pos});\n" - f" Console.WriteLine(result);\n" - f" }}\n}}\n") - - if lang == "ruby": - pos=[]; opts=[] - for k,v,p in args: - if is_body(k): - pos.append(f"WhoisFreaks::{bm}.new") - elif v is None: - continue - else: - cv,_=lang_literal('ruby',v,p) - # required params are positional; optional ones go in the opts hash - if p.get("required") or k in ("apiKey","domainName","ipAddress","asn") \ - or k in ("date","after","before") or (p.get("type")=="boolean" and k.lower() in ("whois","exact")): - pos.append(cv) - else: - opts.append(f"{py_snake(k)}: {cv}") - call = ", ".join(pos) - if opts: - call += ", { " + ", ".join(opts) + " }" - return (f"# Runnable example: {op['summary']} ({op['method']} {op['path']})\n" - f"{pcmt_all}\n" - + ("require 'date'\n" if uses_yesterday else "") - + f"require 'whoisfreaks'\n\n" - f"WhoisFreaks.configure do |config|\n" - f' config.api_key["apiKey"] = "YOUR_API_KEY" # set once\n' - f"end\n\n" - f"api = WhoisFreaks::{cls}.new\n" - f"result = api.{m}({call})\n" - f"puts result\n") +def _lang_module(lang): + return importlib.import_module(f"docs_lang.{lang}") - if lang == "go": - builder="" - for k,v,p in args: - if k=="apiKey": continue - if is_body(k): - builder+=f".{k.split(':')[1][0].upper()+k.split(':')[1][1:]}(*wf.New{bm}())" - elif v is None: - continue - else: - cv,_=lang_literal("go",v,p); builder+=f'.{k[0].upper()+k[1:]}({cv})' - _time_imp = ' "time"\n' if uses_yesterday else '' - call = (f'client.{go_accessor(op["tag"])}.{m}(ctx)' - f'{builder}.Execute()') - ctx_setup = (' // apiKey is set once via the request context\n' - ' ctx := context.WithValue(context.Background(), wf.ContextAPIKeys,\n' - ' map[string]wf.APIKey{"ApiKeyAuth": {Key: "YOUR_API_KEY"}})\n') - if op.get("is_binary"): - fname = (op["op_id"] or "download") + ".gz" - return (f"// Runnable example: {op['summary']} ({op['method']} {op['path']})\n" - f"{pcmt_all}\n" - f"package main\n\n" - f'import (\n "context"\n "fmt"\n "os"\n{_time_imp} wf "github.com/{OWNER}/whoisfreaks-go"\n)\n\n' - f"func main() {{\n" - f" cfg := wf.NewConfiguration()\n" - f" client := wf.NewAPIClient(cfg)\n" - f"{ctx_setup}" - f" // returns raw bytes (compressed/binary file) -- write to disk\n" - f" data, _, err := {call}\n" - f" if err != nil {{ panic(err) }}\n" - f' if err := os.WriteFile("{fname}", data, 0644); err != nil {{ panic(err) }}\n' - f' fmt.Printf("saved %d bytes to {fname}\\n", len(data))\n' - f"}}\n") - return (f"// Runnable example: {op['summary']} ({op['method']} {op['path']})\n" - f"{pcmt_all}\n" - f"package main\n\n" - f'import (\n "context"\n "encoding/json"\n "fmt"\n{_time_imp} wf "github.com/{OWNER}/whoisfreaks-go"\n)\n\n' - f"func main() {{\n" - f" cfg := wf.NewConfiguration()\n" - f" client := wf.NewAPIClient(cfg)\n" - f"{ctx_setup}" - f" result, _, err := {call}\n" - f" if err != nil {{ panic(err) }}\n" - f' b, _ := json.MarshalIndent(result, "", " ")\n' - f" fmt.Println(string(b))\n" - f"}}\n") - - if lang == "php": - pos=", ".join(f"new WhoisFreaks\\Model\\{bm}()" if is_body(k) else lit(v,p) for k,v,p in args) - return (f"setApiKey("apiKey", "YOUR_API_KEY"); // set once\n' - f"$api = new WhoisFreaks\\Api\\{cls}(new GuzzleHttp\\Client(), $config);\n" - f"$result = $api->{m}({pos});\n" - f"print_r($result);\n") +def runnable_example(lang, op): + return _lang_module(lang).example(op, CTX) - if lang == "swift": - parts=[] - for k,v,p in args: - if is_body(k): - parts.append(f"{k.split(':')[1]}: {bm}()") - elif v is None: - parts.append(f"{k}: nil") # Swift uses nil, not null - else: - parts.append(f"{k}: {lit(v,p)}") - found_imp = "import Foundation\n" if uses_yesterday else "" - # The Swift SDK uses async/await (async throws). The apiKey (query security - # scheme) is configured once on the WhoisFreaksAPI client. - return (f"// Runnable example: {op['summary']} ({op['method']} {op['path']})\n" - f"{pcmt_all}\n" - f"{found_imp}import WhoisFreaks\n\n" - f'// Set your API key once (applied to every request)\n' - f'WhoisFreaksAPI.apiKey = "YOUR_API_KEY"\n\n' - f"do {{\n" - f" let result = try await {cls}.{m}({', '.join(parts)})\n" - f" print(result)\n" - f"}} catch {{\n" - f" print(error)\n" - f"}}\n") - - return "// unsupported\n" +def getting_started(lang): + return _lang_module(lang).getting_started(CTX) # unify: doc snippets use the same full-signature renderer as runnable files # (render_example forwards to runnable_example; see its definition above) @@ -975,15 +359,31 @@ def w(path, text): p.write_text(text.rstrip() + "\n") def param_table(params): - rows = ["| Parameter | In | Required | Type | Description |", - "|-----------|----|----------|------|-------------|"] + if not params: + return "None. The API key is set once on the client." + rows = ["| Parameter | In | Required | Type | Default | Description |", + "|-----------|----|----------|------|---------|-------------|"] for p in params: allowed = f" (one of: {', '.join(map(str, p['enum']))})" if p["enum"] else "" req = "yes" if p["required"] else "no" - rows.append(f"| `{p['name']}` | {p['in']} | {req} | {p['type']} | " + typ = p["type"] + (f" ({p['format']})" if p.get("format") else "") + default = "" if p.get("default") is None else f"`{str(p['default']).lower() if isinstance(p['default'], bool) else p['default']}`" + rows.append(f"| `{p['name']}` | {p['in']} | {req} | {typ} | {default} | " f"{(p['desc'] or '').replace('|','\\|')}{allowed} |") return "\n".join(rows) +def body_table(op): + sch = op.get("body_schema") or {} + req = set(sch.get("required") or []) + rows = ["| Field | Type | Required | Description |", "|-------|------|----------|-------------|"] + for k, v in (sch.get("properties") or {}).items(): + t = v.get("type", "any") + if t == "array": + t = f"array<{(v.get('items') or {}).get('type', 'any')}>" + note = f"Up to {v['maxItems']} items." if v.get("maxItems") else "" + rows.append(f"| `{k}` | {t} | {'yes' if k in req else 'no'} | {(v.get('description') or note).strip()} |") + return "\n".join(rows) + "\n\nExample: `" + json.dumps(body_example(op)) + "`" + TOTAL_OPS = sum(len(v) for v in OPS.values()) INFO = spec["info"] # flatten the multi-line spec description into a single clean sentence @@ -998,7 +398,7 @@ def param_table(params): "Subdomains", "IP Reputation", "Domain Reputation", "ASN WHOIS", "IP WHOIS"]), ("Databases", "Bulk data feeds and downloadable database snapshots for large-scale " - "processing — newly registered, expiring/dropped, and full WHOIS/DNS/IP datasets.", + "processing: newly registered, expiring/dropped, and full WHOIS/DNS/IP datasets.", ["Databases - Newly Registered", "Databases - Expiring & Dropped", "Databases - WHOIS", "Databases - DNS", "Databases - Subdomains", "Databases - IP Geolocation", "Databases - ASN WHOIS", @@ -1035,7 +435,8 @@ def type_of(v): for k, v in schema["properties"].items(): desc = (v.get("description") or "").replace("\n", " ").strip() rows.append(f"| `{k}` | {type_of(v)} | {desc} |") - out = [f"**Response** (`{name}`)", "", "\n".join(rows), ""] + label = f"array of `{name}`" if op.get("response_is_array") else f"`{name}`" + out = [f"**Response** ({label})", "", "\n".join(rows), ""] # expand nested object schemas one level (unique refs referenced above) nested = [] seen = set() @@ -1065,15 +466,20 @@ def type_of(v): body += [f"*Section: {section_of(tag)}*", ""] if TAG_DESC := next((t.get("description") for t in spec.get("tags", []) if t.get("name") == tag), None): body += [TAG_DESC, ""] - body += [f"{len(ops)} endpoint(s). All requests require your API key — see " - f"[Authentication](../authentication.md).", ""] + body += [f"{len(ops)} endpoint{'s' if len(ops) != 1 else ''}. Requests need your API key " + f"unless noted otherwise. See [Authentication](../authentication.md).", ""] for op in ops: anchor = op["op_id"] or op["path"] body += [f"## {op['summary'] or op['op_id']}", ""] - body += [f"`{op['method']} {op['path']}`", ""] + body += [f"`{op['method']} {op['server']}{op['path']}`", ""] + if op["public"]: + body += ["Public endpoint: no API key required.", ""] if op["description"]: body += [op["description"], ""] body += ["**Parameters**", "", param_table(op["params"]), ""] + if op.get("body_schema"): + body += [f"**Request body** (`application/json`, model `{op['body_model']}`)", "", + body_table(op), ""] # response fields table (from the spec response schema), when not a binary download if not op.get("is_binary"): rt = response_fields_table(op) @@ -1099,10 +505,12 @@ def type_of(v): continue total = sum(len(OPS[t]) for t in present) cat += [f"## {sec_name}", "", sec_desc, "", - f"{total} endpoints across {len(present)} categories " - f"— see the [{sec_name} overview]({slug(sec_name)}.md).", ""] + f"{total} endpoint{'s' if total != 1 else ''} across {len(present)} " + f"categor{'ies' if len(present) != 1 else 'y'}. See the " + f"[{sec_name} overview]({slug(sec_name)}.md).", ""] for t in present: - cat.append(f"- [{t}]({slug(t)}.md) — {len(OPS[t])} endpoint(s)") + n = len(OPS[t]) + cat.append(f"- [{t}]({slug(t)}.md): {n} endpoint{'s' if n != 1 else ''}") cat.append("") cat += ["## Full endpoint list", "", "| Section | Category | Method | Path | Operation |", @@ -1120,9 +528,9 @@ def type_of(v): continue total = sum(len(OPS[t]) for t in present) sb = [f"# {sec_name}", "", sec_desc, "", - f"**{total} endpoints** across **{len(present)} categories**. " - f"All requests require your API key — see " - f"[Authentication](../authentication.md).", "", + f"**{total} endpoint{'s' if total != 1 else ''}** across **{len(present)} " + f"categor{'ies' if len(present) != 1 else 'y'}**. Requests need your API key " + f"unless noted otherwise. See [Authentication](../authentication.md).", "", "## Categories", ""] for t in present: tag_desc = next((td.get("description") for td in spec.get("tags", []) @@ -1131,9 +539,10 @@ def type_of(v): sb.append("") if tag_desc: sb += [tag_desc, ""] - sb += [f"{len(OPS[t])} endpoint(s):", ""] + n = len(OPS[t]) + sb += [f"{n} endpoint{'s' if n != 1 else ''}:", ""] for op in OPS[t]: - sb.append(f"- **{op['summary'] or op['op_id']}** — " + sb.append(f"- **{op['summary'] or op['op_id']}**: " f"`{op['method']} {op['path']}`") sb.append("") w(f"docs/endpoints/{slug(sec_name)}.md", "\n".join(sb)) @@ -1141,9 +550,10 @@ def type_of(v): # ---------- authentication.md ------------------------------------------------ auth = f"""# Authentication -Every WhoisFreaks API request requires an **API key**, passed as the `apiKey` -query parameter. Each SDK exposes a configuration hook so you set the key once -and it is attached to every request automatically. +Every WhoisFreaks API request needs an **API key**, passed as the `apiKey` +query parameter. The one exception is the public database file status check +(`GET /v3.4/status`). Each SDK exposes a configuration hook so you set the key +once and it is attached to every request automatically. ## Get an API key @@ -1153,15 +563,17 @@ def type_of(v): 1. Sign in at . 2. Copy your API key from the dashboard. -3. Keep it secret — do **not** commit it to source control. Prefer an - environment variable (e.g. `WHOISFREAKS_API_KEY`). +3. Keep it secret. Do **not** commit it to source control; the examples read it + from the `WHOISFREAKS_API_KEY` environment variable. ## Base URLs | Purpose | Base URL | |---------|----------| -| Live API lookups | `{spec['servers'][0]['url']}` | -| Database file downloads | `{spec['servers'][1]['url']}` | +| Live lookups, bulk lookups and account | `{spec['servers'][0]['url']}` | +| Database downloads, threat feeds and database file status | `{spec['servers'][1]['url']}` | + +The SDKs pick the right host for each endpoint; every endpoint page shows its full URL. ## Setting the key per language @@ -1176,7 +588,7 @@ def type_of(v): # ---------- SEO metadata + build-from-source per language -------------------- def _about(lang): label = LANGS[lang]["label"] - return (f"The official **WhoisFreaks {label} SDK** — a complete client for " + return (f"The official **WhoisFreaks {label} SDK**: a complete client for " f"WHOIS, DNS, SSL, domain availability, subdomain, IP geolocation, IP " f"reputation, ASN, typosquatting, and domain reputation lookups, plus " f"bulk database downloads. Query real-time and historical domain data, " @@ -1240,8 +652,8 @@ def build_from_source(lang): "## Install", "", f"```{fence_i}", inst, "```", "", "## Build from Source", "", "Prefer to build the SDK yourself instead of installing from " - f"{m['registry']}? Clone the monorepo and build the {m['label']} " - "package locally:", ""] + f"{m['registry']}? Clone the {m['label']} SDK repository and build it " + "locally:", ""] body += build_from_source(lang) body += ["", "## Getting Started", "", @@ -1284,24 +696,24 @@ def build_from_source(lang): continue _tot = sum(len(OPS[t]) for t in _present) _cats = ", ".join(f"[{t}](docs/endpoints/{slug(t)}.md)" for t in _present) - _sr.append(f"### [{_sn}](docs/endpoints/{slug(_sn)}.md) — {_tot} endpoints\n\n{_sd}\n\n{_cats}\n") + _sr.append(f"### [{_sn}](docs/endpoints/{slug(_sn)}.md) ({_tot} endpoints)\n\n{_sd}\n\n{_cats}\n") section_rows = "\n".join(_sr) readme = f"""# WhoisFreaks SDK Documentation -Official documentation for the **WhoisFreaks** SDKs — one API, {len(LANGS)} +Official documentation for the **WhoisFreaks** SDKs: one API, {len(LANGS)} languages, {TOTAL_OPS} endpoints. Every SDK is generated from the same -[OpenAPI specification](https://whoisfreaks.com/documentation) and published to +[OpenAPI specification](spec/whoisfreaks-openapi.yaml) and published to its language's standard registry. -> {DESC1} +> {DESC1.replace(" \u2014 ", ": ")} ## Contents -- [Authentication](docs/authentication.md) — get and configure your API key -- [Language guides](#language-guides) — install + usage for each SDK -- [Endpoint reference](docs/endpoints/README.md) — all {TOTAL_OPS} endpoints, grouped by category -- [Runnable examples](examples/README.md) — copy-paste, ready-to-run example for every endpoint in every language +- [Authentication](docs/authentication.md): get and configure your API key +- [Language guides](#language-guides): install + usage for each SDK +- [Endpoint reference](docs/endpoints/README.md): all {TOTAL_OPS} endpoints, grouped by category +- [Runnable examples](examples/README.md): copy-paste, ready-to-run example for every endpoint in every language ## Language guides @@ -1319,45 +731,46 @@ def build_from_source(lang): ``` ```python +import os import whoisfreaks -from whoisfreaks import Configuration, ApiClient -config = Configuration() -config.api_key["ApiKeyAuth"] = "YOUR_API_KEY" -client = ApiClient(config) +config = whoisfreaks.Configuration() +config.api_key["ApiKeyAuth"] = os.environ["WHOISFREAKS_API_KEY"] -result = client.{method_name(first_op['op_id'], 'python')}(domainName="example.com") -print(result) +with whoisfreaks.ApiClient(config) as client: + record = whoisfreaks.WHOISApi(client).whois_live("example.com") + print(record.domain_registrar.registrar_name, record.expiry_date) ``` The equivalent for every other language is in its [language guide](#language-guides). ## Endpoint sections -The API is organized into three sections. See the [full endpoint reference](docs/endpoints/README.md) for every operation with parameters, response fields, and per-language examples. +The API is organized into three sections. See the [full endpoint reference](docs/endpoints/README.md) for every operation with its URL, parameters, response fields and Python, TypeScript and Go examples. The [language guides](#language-guides) show every operation in all {len(LANGS)} languages. {section_rows} ## Authentication at a glance -All requests require an `apiKey` query parameter. Get a key at -, then configure it once via each SDK's -configuration object — see [Authentication](docs/authentication.md). +Every request except the public database file status check needs an `apiKey` +query parameter. Get a key at , then configure it +once via each SDK's configuration object. See [Authentication](docs/authentication.md). Base URLs: | Purpose | URL | |---------|-----| -| Live lookups | `{spec['servers'][0]['url']}` | -| Database downloads | `{spec['servers'][1]['url']}` | +| Live lookups, bulk lookups and account | `{spec['servers'][0]['url']}` | +| Database downloads, threat feeds and database file status | `{spec['servers'][1]['url']}` | ## About these docs These docs are generated from the OpenAPI spec by `scripts/gen_docs.py`, so they -stay in sync with the API. To regenerate after a spec change: +stay in sync with the API. To regenerate after a spec change or an SDK release +(`SDK_VERSION` sets the version in install lines): ```bash -python3 scripts/gen_docs.py path/to/whoisfreaks-openapi.yaml . +SDK_VERSION={SDK_VERSION} python3 scripts/gen_docs.py spec/whoisfreaks-openapi.yaml . ``` ## Support @@ -1368,7 +781,7 @@ def build_from_source(lang): ## License -{spec.get('info', {}).get('license', {}).get('name', 'MIT')} — see individual SDK repositories for details. +{spec.get('info', {}).get('license', {}).get('name', 'MIT')}. See individual SDK repositories for details. """ w("README.md", readme) @@ -1386,19 +799,28 @@ def build_from_source(lang): def write_examples(): count=0 + written=set() for tag, ops in OPS.items(): for op in ops: P=_pascal(op["op_id"]) for lang in LANG_ORDER: code=runnable_example(lang, op) w(f"examples/{lang}/{P}.{EXT[lang]}", code) + written.add(f"examples/{lang}/{P}.{EXT[lang]}") count+=1 + # drop examples for operations that no longer exist in the spec + for lang in LANG_ORDER: + for f in (OUT / "examples" / lang).glob(f"*.{EXT[lang]}"): + if f"examples/{lang}/{f.name}" not in written: + f.unlink() + print(f"removed stale example {f.relative_to(OUT)}") # index idx=["# Runnable Examples","", f"Copy-paste, ready-to-run examples for **every one of the {TOTAL_OPS} " f"endpoints** in **all {len(LANGS)} languages** ({count} files).","", - "Set `YOUR_API_KEY` to your key (from ) " - "and run. Layout: `examples//.`.","", + "Set the `WHOISFREAKS_API_KEY` environment variable to your key (from " + ") and run. Layout: " + "`examples//.`.","", "| Endpoint | Operation | Example file (per language) |", "|----------|-----------|------------------------------|"] for tag, ops in OPS.items(): @@ -1408,14 +830,14 @@ def write_examples(): idx.append(f"| {op['summary']} | `{op['op_id']}` | {links} |") # per-language example index for lang in LANG_ORDER: - li=[f"# {LANGS[lang]['label']} — Runnable Examples","", + li=[f"# {LANGS[lang]['label']} Runnable Examples","", f"Install: see the [{LANGS[lang]['label']} guide](../../docs/languages/{lang}.md). " - f"Set `YOUR_API_KEY` and run any file below.",""] + f"Set the `WHOISFREAKS_API_KEY` environment variable and run any file below.",""] for tag, ops in OPS.items(): li.append(f"## {tag}") for op in ops: P=_pascal(op["op_id"]) - li.append(f"- [`{P}.{EXT[lang]}`]({P}.{EXT[lang]}) — {op['summary']} (`{op['method']} {op['path']}`)") + li.append(f"- [`{P}.{EXT[lang]}`]({P}.{EXT[lang]}): {op['summary']} (`{op['method']} {op['path']}`)") li.append("") w(f"examples/{lang}/README.md", "\n".join(li)) w("examples/README.md","\n".join(idx)) diff --git a/spec/whoisfreaks-openapi.yaml b/spec/whoisfreaks-openapi.yaml index d5d6b06..00f48e8 100644 --- a/spec/whoisfreaks-openapi.yaml +++ b/spec/whoisfreaks-openapi.yaml @@ -1,7 +1,8 @@ openapi: 3.0.3 info: title: WhoisFreaks API - description: "Complete WhoisFreaks API \u2014 WHOIS, DNS, SSL, Geolocation, Typosquatting,\nIP Intelligence,\ + description: + "Complete WhoisFreaks API: WHOIS, DNS, SSL, Geolocation, Typosquatting,\nIP Intelligence,\ \ Domain Reputation, and bulk database downloads.\n\n## Authentication\nAll requests require an `apiKey`\ \ query parameter.\n\n## Resources\n- Docs: https://whoisfreaks.com/documentation\n- Billing: https://billing.whoisfreaks.com\n\ - Support: support@whoisfreaks.com\n" @@ -14,93 +15,95 @@ info: name: MIT url: https://opensource.org/licenses/MIT servers: -- url: https://api.whoisfreaks.com - description: API Solutions (live lookups) -- url: https://files.whoisfreaks.com - description: Database file downloads + - url: https://api.whoisfreaks.com + description: API Solutions (live lookups) + - url: https://files.whoisfreaks.com + description: Database file downloads security: -- ApiKeyAuth: [] + - ApiKeyAuth: [] tags: -- name: WHOIS - description: WHOIS lookup APIs (live, historical, reverse, bulk) -- name: DNS - description: DNS lookup APIs (live, historical, reverse, bulk) -- name: Domain Availability - description: Check domain availability -- name: Typosquatting - description: Detect typo variants of brand domains -- name: SSL - description: SSL certificate lookup -- name: Geolocation - description: IP geolocation lookup -- name: Subdomains - description: Subdomain enumeration -- name: IP Reputation - description: IP threat intelligence -- name: Domain Reputation - description: Real-time domain threat assessment and trust scoring -- name: ASN WHOIS - description: Autonomous System Number WHOIS -- name: IP WHOIS - description: IP address WHOIS -- name: Account - description: Account, API key, and usage utilities -- name: Databases - Newly Registered - description: Newly registered domain downloads -- name: Databases - Expiring & Dropped - description: Expiring and dropped domain downloads -- name: Databases - WHOIS - description: WHOIS database snapshots -- name: Databases - DNS - description: DNS database snapshots -- name: Databases - Subdomains - description: Subdomain database snapshots -- name: Databases - IP Geolocation - description: IP geolocation database snapshots -- name: Databases - ASN WHOIS - description: ASN WHOIS database snapshots -- name: Databases - IP WHOIS - description: IP WHOIS database snapshots -- name: Databases - IP Security - description: IP security database snapshots + - name: WHOIS + description: WHOIS lookup APIs (live, historical, reverse, bulk) + - name: DNS + description: DNS lookup APIs (live, historical, reverse, bulk) + - name: Domain Availability + description: Check domain availability + - name: Typosquatting + description: Detect typo variants of brand domains + - name: SSL + description: SSL certificate lookup + - name: Geolocation + description: IP geolocation lookup + - name: Subdomains + description: Subdomain enumeration + - name: IP Reputation + description: IP threat intelligence + - name: Domain Reputation + description: Real-time domain threat assessment and trust scoring + - name: ASN WHOIS + description: Autonomous System Number WHOIS + - name: IP WHOIS + description: IP address WHOIS + - name: Account + description: Account, API key, and usage utilities + - name: Databases - Newly Registered + description: Newly registered domain downloads + - name: Databases - Expiring & Dropped + description: Expiring and dropped domain downloads + - name: Databases - WHOIS + description: WHOIS database snapshots + - name: Databases - DNS + description: DNS database snapshots + - name: Databases - Subdomains + description: Subdomain database snapshots + - name: Databases - IP Geolocation + description: IP geolocation database snapshots + - name: Databases - ASN WHOIS + description: ASN WHOIS database snapshots + - name: Databases - IP WHOIS + description: IP WHOIS database snapshots + - name: Databases - IP Security + description: IP security database snapshots + - name: Databases - Threat Feed + description: Daily phishing, malware and spam threat feeds paths: /v2.0/whois/live: get: tags: - - WHOIS + - WHOIS summary: Live WHOIS Lookup description: Real-time WHOIS lookup from authoritative servers. Cost 1 credit. operationId: whoisLive parameters: - - name: domainName - in: query - schema: - type: string - required: true - example: whoisfreaks.com - - $ref: '#/components/parameters/Format' + - name: domainName + in: query + schema: + type: string + required: true + example: whoisfreaks.com + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/WhoisResponse' - '401': - $ref: '#/components/responses/Unauthorized' - '404': - $ref: '#/components/responses/NotFound' - '429': - $ref: '#/components/responses/RateLimited' + $ref: "#/components/schemas/WhoisResponse" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "429": + $ref: "#/components/responses/RateLimited" /v2.0/bulkwhois/live: post: tags: - - WHOIS + - WHOIS summary: Bulk WHOIS Lookup description: Up to 100 domains in one request. 1 credit per successful domain. operationId: bulkWhois parameters: - - $ref: '#/components/parameters/Format' + - $ref: "#/components/parameters/Format" requestBody: required: true content: @@ -108,7 +111,7 @@ paths: schema: type: object required: - - domainNames + - domainNames properties: domainNames: type: array @@ -117,149 +120,158 @@ paths: maxItems: 100 example: domainNames: - - whoisfreaks.com - - jfreaks.com + - whoisfreaks.com + - jfreaks.com responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/BulkWhoisResponse' + $ref: "#/components/schemas/BulkWhoisResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v2.0/dns/live: get: tags: - - DNS + - DNS summary: Live DNS Lookup description: Real-time DNS record lookup. 1 credit per query. operationId: dnsLive parameters: - - name: domainName - in: query - schema: - type: string - - name: ipAddress - in: query - schema: - type: string - description: Use for PTR lookups - - name: type - in: query - schema: - type: string - default: all - required: true - description: 'all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME' - - $ref: '#/components/parameters/Format' + - name: domainName + in: query + schema: + type: string + example: whoisfreaks.com + - name: ipAddress + in: query + schema: + type: string + description: Use for PTR lookups + example: 8.8.8.8 + - name: type + in: query + schema: + type: string + default: all + required: true + description: "all or comma-separated: A,MX,NS,TXT,SOA,SPF,AAAA,CNAME" + example: "A,MX,TXT" + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/DnsResponse' - '401': - $ref: '#/components/responses/Unauthorized' - '429': - $ref: '#/components/responses/RateLimited' + $ref: "#/components/schemas/DnsResponse" + "401": + $ref: "#/components/responses/Unauthorized" + "429": + $ref: "#/components/responses/RateLimited" /v2.0/dns/historical: get: tags: - - DNS + - DNS summary: Historical DNS Lookup description: All historical DNS records. 2 credits per page (100 records/page). operationId: dnsHistorical parameters: - - name: domainName - in: query - schema: - type: string - required: true - - name: type - in: query - schema: - type: string - default: all - required: true - - name: page - in: query - schema: - type: integer - default: 1 - - $ref: '#/components/parameters/Format' + - name: domainName + in: query + schema: + type: string + required: true + example: whoisfreaks.com + - name: type + in: query + schema: + type: string + default: all + required: true + example: "A,MX,TXT" + - name: page + in: query + schema: + type: integer + default: 1 + example: 1 + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/HistoricalDnsResponse' + $ref: "#/components/schemas/HistoricalDnsResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v2.1/dns/reverse: get: tags: - - DNS + - DNS summary: Reverse DNS Lookup description: Search domains by IP or DNS value. 5 credits per page. operationId: dnsReverse parameters: - - name: value - in: query - schema: - type: string - required: true - description: IP, CIDR, or record value - - name: type - in: query - schema: - type: string - enum: - - a - - mx - - cname - - ns - - aaaa - - txt - - soa - required: true - - name: exact - in: query - schema: - type: boolean - default: true - - name: page - in: query - schema: - type: integer - default: 1 - - $ref: '#/components/parameters/Format' + - name: value + in: query + schema: + type: string + required: true + description: IP, CIDR, or record value + example: 8.8.8.8 + - name: type + in: query + schema: + type: string + enum: + - a + - mx + - cname + - ns + - aaaa + - txt + - soa + required: true + - name: exact + in: query + schema: + type: boolean + default: true + - name: page + in: query + schema: + type: integer + default: 1 + example: 1 + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/ReverseDnsResponse' + $ref: "#/components/schemas/ReverseDnsResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v2.0/dns/bulk/live: post: tags: - - DNS + - DNS summary: Bulk DNS Lookup description: Up to 100 domains + 100 IPs in one request. operationId: dnsBulk parameters: - - name: type - in: query - schema: - type: string - default: all - required: true - - $ref: '#/components/parameters/Format' + - name: type + in: query + schema: + type: string + default: all + required: true + example: "A,MX,TXT" + - $ref: "#/components/parameters/Format" requestBody: required: true content: @@ -276,182 +288,188 @@ paths: items: type: string responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/BulkDnsResponse' + $ref: "#/components/schemas/BulkDnsResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v2.0/domain/availability: get: tags: - - Domain Availability + - Domain Availability summary: Domain Availability Check with Suggestions - description: Check availability of a single domain and optionally get suggestions across multiple + description: + Check availability of a single domain and optionally get suggestions across multiple TLDs. 1 credit per domain checked. sug=false checks only the queried domain; sug=true returns up to `count` (max 100) TLD suggestions. operationId: domainAvailabilityV2 parameters: - - name: domain - in: query - schema: - type: string - required: true - description: The domain name to check - example: google.com - - name: sug - in: query - schema: - type: boolean - default: false - description: Whether to return TLD suggestions alongside the queried domain. - - name: count - in: query - schema: - type: integer - default: 5 - minimum: 1 - maximum: 100 - description: Number of TLD suggestions to return when sug=true. Maximum is 100. - - $ref: '#/components/parameters/Format' + - name: domain + in: query + schema: + type: string + required: true + description: The domain name to check + example: google.com + - name: sug + in: query + schema: + type: boolean + default: false + description: Whether to return TLD suggestions alongside the queried domain. + - name: count + in: query + schema: + type: integer + default: 5 + minimum: 1 + maximum: 100 + description: Number of TLD suggestions to return when sug=true. Maximum is 100. + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/DomainAvailabilityResponse' - '400': - $ref: '#/components/responses/BadRequest' - '401': - $ref: '#/components/responses/Unauthorized' - '429': - $ref: '#/components/responses/RateLimited' + $ref: "#/components/schemas/DomainAvailabilityResponse" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "429": + $ref: "#/components/responses/RateLimited" post: tags: - - Domain Availability + - Domain Availability summary: Bulk Domain Availability Check - description: 'Two bulk modes. Mode 1: POST domainNames array. Mode 2: POST tld array plus domain - query param. Max 100 domains per request. 1 credit per domain checked.' + description: + "Two bulk modes. Mode 1: POST domainNames array. Mode 2: POST tld array plus domain + query param. Max 100 domains per request. 1 credit per domain checked." operationId: bulkDomainAvailabilityV2 parameters: - - name: domain - in: query - schema: - type: string - description: Required for TLD-mode bulk check (base domain). - example: google.com - - $ref: '#/components/parameters/Format' + - name: domain + in: query + schema: + type: string + description: Required for TLD-mode bulk check (base domain). + example: google.com + - $ref: "#/components/parameters/Format" requestBody: required: true content: application/json: schema: - $ref: '#/components/schemas/BulkDomainAvailabilityRequest' + $ref: "#/components/schemas/BulkDomainAvailabilityRequest" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/BulkDomainAvailabilityResponse' - '400': - $ref: '#/components/responses/BadRequest' - '401': - $ref: '#/components/responses/Unauthorized' - '429': - $ref: '#/components/responses/RateLimited' + $ref: "#/components/schemas/BulkDomainAvailabilityResponse" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "429": + $ref: "#/components/responses/RateLimited" /v3.0/domain/typos: get: tags: - - Typosquatting + - Typosquatting summary: Typosquatting Lookup description: Find typo variants of a brand. 5 credits per page. operationId: typosquatting parameters: - - name: keyword - in: query - schema: - type: string - - name: pattern - in: query - schema: - type: string - - name: pageToken - in: query - schema: - type: string + - name: keyword + in: query + schema: + type: string + example: whoisfreaks + - name: pattern + in: query + schema: + type: string + example: "whois*" + - name: pageToken + in: query + schema: + type: string responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/TyposquattingResponse' - '400': - $ref: '#/components/responses/BadRequest' - '401': - $ref: '#/components/responses/Unauthorized' + $ref: "#/components/schemas/TyposquattingResponse" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" /v1.0/ssl/live: get: tags: - - SSL + - SSL summary: SSL Certificate Lookup description: Real-time SSL cert with optional chain. operationId: sslLookup parameters: - - name: domainName - in: query - schema: - type: string - required: true - - name: chain - in: query - schema: - type: boolean - default: false - - name: sslRaw - in: query - schema: - type: boolean - default: false - - $ref: '#/components/parameters/Format' + - name: domainName + in: query + schema: + type: string + required: true + example: whoisfreaks.com + - name: chain + in: query + schema: + type: boolean + default: false + - name: sslRaw + in: query + schema: + type: boolean + default: false + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/SslResponse' + $ref: "#/components/schemas/SslResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v1.0/geolocation: get: tags: - - Geolocation + - Geolocation summary: IP Geolocation Lookup description: Get location, ASN, currency for an IP. 1 credit. operationId: geolocation parameters: - - name: ip - in: query - schema: - type: string - required: true + - name: ip + in: query + schema: + type: string + required: true + example: 8.8.8.8 responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/GeolocationResponse' + $ref: "#/components/schemas/GeolocationResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" post: tags: - - Geolocation + - Geolocation summary: Bulk IP Geolocation description: Up to 100 IPs. operationId: bulkGeolocation @@ -463,7 +481,7 @@ paths: schema: type: object required: - - ips + - ips properties: ips: type: array @@ -471,86 +489,91 @@ paths: type: string maxItems: 100 responses: - '200': + "200": description: Successful response content: application/json: schema: type: array items: - $ref: '#/components/schemas/GeolocationResponse' + $ref: "#/components/schemas/GeolocationResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v1.0/subdomains: get: tags: - - Subdomains + - Subdomains summary: Subdomains Lookup description: All subdomains including nested. 2 credits per query. operationId: subdomains parameters: - - name: domain - in: query - schema: - type: string - required: true - - name: after - in: query - schema: - type: string - format: date - - name: before - in: query - schema: - type: string - format: date - - name: status - in: query - schema: - type: string - enum: - - active - - inactive - - name: page - in: query - schema: - type: integer - default: 1 - - $ref: '#/components/parameters/Format' + - name: domain + in: query + schema: + type: string + required: true + example: whoisfreaks.com + - name: after + in: query + schema: + type: string + format: date + example: "2026-01-01" + - name: before + in: query + schema: + type: string + format: date + example: "2026-10-01" + - name: status + in: query + schema: + type: string + enum: + - active + - inactive + - name: page + in: query + schema: + type: integer + default: 1 + example: 1 + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/SubdomainsResponse' + $ref: "#/components/schemas/SubdomainsResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v1.0/security: get: tags: - - IP Reputation + - IP Reputation summary: IP Reputation Lookup - description: "Threat intel for IP \u2014 VPN, proxy, Tor, bots. 1 credit." + description: "Threat intel for IP: VPN, proxy, Tor, bots. 1 credit." operationId: ipReputation parameters: - - name: ip - in: query - schema: - type: string - required: true + - name: ip + in: query + schema: + type: string + required: true + example: 8.8.8.8 responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/IpReputationResponse' + $ref: "#/components/schemas/IpReputationResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" post: tags: - - IP Reputation + - IP Reputation summary: Bulk IP Reputation description: Up to 100 IPs. operationId: bulkIpReputation @@ -562,7 +585,7 @@ paths: schema: type: object required: - - ips + - ips properties: ips: type: array @@ -570,110 +593,112 @@ paths: type: string maxItems: 100 responses: - '200': + "200": description: Successful response content: application/json: schema: type: array items: - $ref: '#/components/schemas/IpReputationResponse' + $ref: "#/components/schemas/IpReputationResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v1/domain/security: get: tags: - - Domain Reputation + - Domain Reputation summary: Domain Reputation Lookup - description: Real-time domain threat assessment. Returns risk verdict, trust score, DGA analysis, + description: + Real-time domain threat assessment. Returns risk verdict, trust score, DGA analysis, threat intelligence matches, and security signals. 1 credit. operationId: domainReputation parameters: - - name: domainName - in: query - schema: - type: string - required: true - description: The domain name to assess - example: amazon.com - - $ref: '#/components/parameters/Format' + - name: domainName + in: query + schema: + type: string + required: true + description: The domain name to assess + example: amazon.com + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/DomainReputationResponse' - '400': - $ref: '#/components/responses/BadRequest' - '401': - $ref: '#/components/responses/Unauthorized' - '404': - $ref: '#/components/responses/NotFound' - '429': - $ref: '#/components/responses/RateLimited' + $ref: "#/components/schemas/DomainReputationResponse" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "404": + $ref: "#/components/responses/NotFound" + "429": + $ref: "#/components/responses/RateLimited" /v2.0/asn-whois: get: tags: - - ASN WHOIS + - ASN WHOIS summary: ASN WHOIS Lookup description: WHOIS for an ASN. 1 credit. operationId: asnWhois parameters: - - name: asn - in: query - schema: - type: string - required: true - example: as15169 - - $ref: '#/components/parameters/Format' + - name: asn + in: query + schema: + type: string + required: true + example: as15169 + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/AsnWhoisResponse' + $ref: "#/components/schemas/AsnWhoisResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v1.0/ip-whois: get: tags: - - IP WHOIS + - IP WHOIS summary: IP WHOIS Lookup description: WHOIS for an IP address. 1 credit. operationId: ipWhois parameters: - - name: ip - in: query - schema: - type: string - required: true - - $ref: '#/components/parameters/Format' + - name: ip + in: query + schema: + type: string + required: true + example: 8.8.8.8 + - $ref: "#/components/parameters/Format" responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/IpWhoisResponse' + $ref: "#/components/schemas/IpWhoisResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" /v1.0/api-key/rotate: get: tags: - - Account + - Account summary: Rotate API Key operationId: rotateApiKey parameters: [] responses: - '200': + "200": description: Key rotated content: text/plain: schema: type: string - '401': + "401": description: Not allowed content: text/plain: @@ -683,41 +708,43 @@ paths: /v1.0/whoisapi/usage: get: tags: - - Account + - Account summary: Account Usage operationId: accountUsage parameters: [] responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/AccountUsageResponse' + $ref: "#/components/schemas/AccountUsageResponse" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Account Usage. Returns the file/snapshot described by this operation. /v3.1/download/domainer/gtld: servers: &id001 - - url: https://files.whoisfreaks.com + - url: https://files.whoisfreaks.com get: tags: - - Databases - Newly Registered + - Databases - Newly Registered summary: Newly Registered gTLD (CSV) operationId: dbNewlyGtld parameters: - - name: whois - in: query - schema: - type: boolean - required: true - - $ref: '#/components/parameters/DateParam' - - name: tlds - in: query - schema: - type: string + - name: whois + in: query + schema: + type: boolean + required: true + example: true + - $ref: "#/components/parameters/DateParam" + - name: tlds + in: query + schema: + type: string + example: "com,net" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -725,28 +752,30 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Newly Registered gTLD (CSV). Returns the file/snapshot described by this operation. /v3.1/download/domainer/cctld: servers: *id001 get: tags: - - Databases - Newly Registered + - Databases - Newly Registered summary: Newly Registered ccTLD (CSV) operationId: dbNewlyCctld parameters: - - name: whois - in: query - schema: - type: boolean - required: true - - $ref: '#/components/parameters/DateParam' - - name: tlds - in: query - schema: - type: string + - name: whois + in: query + schema: + type: boolean + required: true + example: true + - $ref: "#/components/parameters/DateParam" + - name: tlds + in: query + schema: + type: string + example: "com,net" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -754,19 +783,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Newly Registered ccTLD (CSV). Returns the file/snapshot described by this operation. /v3.1/download/domainer/gtld/cleaned: servers: *id001 get: tags: - - Databases - Newly Registered + - Databases - Newly Registered summary: Newly Registered gTLD Cleaned WHOIS (CSV) operationId: dbNewlyGtldCleaned parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -774,20 +803,21 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' - description: Newly Registered gTLD Cleaned WHOIS (CSV). Returns the file/snapshot described by this + $ref: "#/components/responses/ErrorResponse" + description: + Newly Registered gTLD Cleaned WHOIS (CSV). Returns the file/snapshot described by this operation. /v3.1/download/domainer/cctld/cleaned: servers: *id001 get: tags: - - Databases - Newly Registered + - Databases - Newly Registered summary: Newly Registered ccTLD Cleaned WHOIS (CSV) operationId: dbNewlyCctldCleaned parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -795,24 +825,26 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' - description: Newly Registered ccTLD Cleaned WHOIS (CSV). Returns the file/snapshot described by + $ref: "#/components/responses/ErrorResponse" + description: + Newly Registered ccTLD Cleaned WHOIS (CSV). Returns the file/snapshot described by this operation. /v3.1/domains/newly/gtld: servers: *id001 get: tags: - - Databases - Newly Registered + - Databases - Newly Registered summary: Newly Registered gTLD (JSON) operationId: dbNewlyGtldJson parameters: - - $ref: '#/components/parameters/DateParam' - - name: tlds - in: query - schema: - type: string + - $ref: "#/components/parameters/DateParam" + - name: tlds + in: query + schema: + type: string + example: "com,net" responses: - '200': + "200": description: JSON array of domains content: application/json: @@ -821,23 +853,24 @@ paths: items: type: string 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Newly Registered gTLD (JSON). Returns the file/snapshot described by this operation. /v3.1/domains/newly/cctld: servers: *id001 get: tags: - - Databases - Newly Registered + - Databases - Newly Registered summary: Newly Registered ccTLD (JSON) operationId: dbNewlyCctldJson parameters: - - $ref: '#/components/parameters/DateParam' - - name: tlds - in: query - schema: - type: string + - $ref: "#/components/parameters/DateParam" + - name: tlds + in: query + schema: + type: string + example: "com,net" responses: - '200': + "200": description: JSON array of domains content: application/json: @@ -846,19 +879,19 @@ paths: items: type: string 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Newly Registered ccTLD (JSON). Returns the file/snapshot described by this operation. /v3.1/download/domainer/newly/dns: servers: *id001 get: tags: - - Databases - Newly Registered + - Databases - Newly Registered summary: Newly Registered With DNS operationId: dbNewlyDns parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: JSON array of domains with DNS content: application/octet-stream: @@ -866,24 +899,25 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Newly Registered With DNS. Returns the file/snapshot described by this operation. /v3.1/download/domainer/expired: servers: *id001 get: tags: - - Databases - Expiring & Dropped + - Databases - Expiring & Dropped summary: Expiring Domains operationId: dbExpired parameters: - - name: whois - in: query - schema: - type: boolean - required: true - - $ref: '#/components/parameters/DateParam' + - name: whois + in: query + schema: + type: boolean + required: true + example: true + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -891,19 +925,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Expiring Domains. Returns the file/snapshot described by this operation. /v3.1/download/domainer/expired/cleaned: servers: *id001 get: tags: - - Databases - Expiring & Dropped + - Databases - Expiring & Dropped summary: Expiring Cleaned WHOIS operationId: dbExpiredCleaned parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -911,24 +945,25 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Expiring Cleaned WHOIS. Returns the file/snapshot described by this operation. /v3.1/download/domainer/dropped: servers: *id001 get: tags: - - Databases - Expiring & Dropped + - Databases - Expiring & Dropped summary: Dropped Domains operationId: dbDropped parameters: - - name: whois - in: query - schema: - type: boolean - required: true - - $ref: '#/components/parameters/DateParam' + - name: whois + in: query + schema: + type: boolean + required: true + example: true + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -936,23 +971,24 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Dropped Domains. Returns the file/snapshot described by this operation. /v3.1/domains/dropped: servers: *id001 get: tags: - - Databases - Expiring & Dropped + - Databases - Expiring & Dropped summary: Dropped Domains (JSON) operationId: dbDroppedJson parameters: - - $ref: '#/components/parameters/DateParam' - - name: tlds - in: query - schema: - type: string + - $ref: "#/components/parameters/DateParam" + - name: tlds + in: query + schema: + type: string + example: "com,net" responses: - '200': + "200": description: JSON array of domains content: application/json: @@ -961,23 +997,24 @@ paths: items: type: string 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Dropped Domains (JSON). Returns the file/snapshot described by this operation. /v3.3/download/domainer/dropped/backlinks: servers: *id001 get: tags: - - Databases - Expiring & Dropped + - Databases - Expiring & Dropped summary: Dropped With Backlinks operationId: dbDroppedBacklinks parameters: - - name: whois - in: query - schema: - type: boolean - - $ref: '#/components/parameters/DateParam' + - name: whois + in: query + schema: + type: boolean + example: true + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -985,19 +1022,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Dropped With Backlinks. Returns the file/snapshot described by this operation. /v3.3/download/dbupdate/daily/domains/whois: servers: *id001 get: tags: - - Databases - WHOIS + - Databases - WHOIS summary: WHOIS Database Daily operationId: dbWhoisDaily parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1005,19 +1042,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: WHOIS Database Daily. Returns the file/snapshot described by this operation. /v3.3/download/dbupdate/weekly/domains/whois: servers: *id001 get: tags: - - Databases - WHOIS + - Databases - WHOIS summary: WHOIS Database Weekly operationId: dbWhoisWeekly parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1025,19 +1062,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: WHOIS Database Weekly. Returns the file/snapshot described by this operation. /v3.3/download/dbupdate/monthly/domains/whois: servers: *id001 get: tags: - - Databases - WHOIS + - Databases - WHOIS summary: WHOIS Database Monthly operationId: dbWhoisMonthly parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1045,19 +1082,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: WHOIS Database Monthly. Returns the file/snapshot described by this operation. /v3.2/download/dbupdate/daily/dns: servers: *id001 get: tags: - - Databases - DNS + - Databases - DNS summary: DNS Database Daily operationId: dbDnsDaily parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1065,19 +1102,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: DNS Database Daily. Returns the file/snapshot described by this operation. /v3.2/download/dbupdate/weekly/dns: servers: *id001 get: tags: - - Databases - DNS + - Databases - DNS summary: DNS Database Weekly operationId: dbDnsWeekly parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1085,19 +1122,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: DNS Database Weekly. Returns the file/snapshot described by this operation. /v3.2/download/dbupdate/monthly/dns: servers: *id001 get: tags: - - Databases - DNS + - Databases - DNS summary: DNS Database Monthly operationId: dbDnsMonthly parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1105,19 +1142,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: DNS Database Monthly. Returns the file/snapshot described by this operation. /v3.2/download/dbupdate/daily/subdomains: servers: *id001 get: tags: - - Databases - Subdomains + - Databases - Subdomains summary: Subdomains Daily operationId: dbSubdomainsDaily parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1125,19 +1162,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Subdomains Daily. Returns the file/snapshot described by this operation. /v3.2/download/dbupdate/weekly/subdomains: servers: *id001 get: tags: - - Databases - Subdomains + - Databases - Subdomains summary: Subdomains Weekly operationId: dbSubdomainsWeekly parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1145,19 +1182,19 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Subdomains Weekly. Returns the file/snapshot described by this operation. /v3.2/download/dbupdate/monthly/subdomains: servers: *id001 get: tags: - - Databases - Subdomains + - Databases - Subdomains summary: Subdomains Monthly operationId: dbSubdomainsMonthly parameters: - - $ref: '#/components/parameters/DateParam' + - $ref: "#/components/parameters/DateParam" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1165,42 +1202,43 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: Subdomains Monthly. Returns the file/snapshot described by this operation. /v3.3/status/snapshot/ip/country: servers: *id001 get: tags: - - Databases - IP Geolocation + - Databases - IP Geolocation summary: IP to Country Snapshot Status operationId: dbIpCountryStatus parameters: [] responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/SnapshotStatus' + $ref: "#/components/schemas/SnapshotStatus" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: IP to Country Snapshot Status. Returns the file/snapshot described by this operation. /v3.3/download/snapshot/ip/country: servers: *id001 get: tags: - - Databases - IP Geolocation + - Databases - IP Geolocation summary: IP to Country Snapshot operationId: dbIpCountry parameters: - - name: date - in: query - schema: - type: string - format: date - required: true + - name: date + in: query + schema: + type: string + format: date + required: true + example: "2026-10-01" responses: - '200': + "200": description: ZIP archive content: application/octet-stream: @@ -1208,42 +1246,43 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: IP to Country Snapshot. Returns the file/snapshot described by this operation. /v3.3/status/snapshot/ip/city: servers: *id001 get: tags: - - Databases - IP Geolocation + - Databases - IP Geolocation summary: IP to City Snapshot Status operationId: dbIpCityStatus parameters: [] responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/SnapshotStatus' + $ref: "#/components/schemas/SnapshotStatus" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: IP to City Snapshot Status. Returns the file/snapshot described by this operation. /v3.3/download/snapshot/ip/city: servers: *id001 get: tags: - - Databases - IP Geolocation + - Databases - IP Geolocation summary: IP to City Snapshot operationId: dbIpCity parameters: - - name: date - in: query - schema: - type: string - format: date - required: true + - name: date + in: query + schema: + type: string + format: date + required: true + example: "2026-10-01" responses: - '200': + "200": description: ZIP archive content: application/octet-stream: @@ -1251,24 +1290,25 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: IP to City Snapshot. Returns the file/snapshot described by this operation. /v3.3/download/snapshot/asn/whois: servers: *id001 get: tags: - - Databases - ASN WHOIS + - Databases - ASN WHOIS summary: ASN WHOIS Snapshot operationId: dbAsnWhois parameters: - - name: date - in: query - schema: - type: string - format: date - required: true + - name: date + in: query + schema: + type: string + format: date + required: true + example: "2026-10-01" responses: - '200': + "200": description: JSON gzipped content: application/octet-stream: @@ -1276,42 +1316,43 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: ASN WHOIS Snapshot. Returns the file/snapshot described by this operation. /v3.3/status/snapshot/asn/whois: servers: *id001 get: tags: - - Databases - ASN WHOIS + - Databases - ASN WHOIS summary: ASN WHOIS Snapshot Status operationId: dbAsnWhoisStatus parameters: [] responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/SnapshotStatus' + $ref: "#/components/schemas/SnapshotStatus" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: ASN WHOIS Snapshot Status. Returns the file/snapshot described by this operation. /v3.3/download/snapshot/ip/whois: servers: *id001 get: tags: - - Databases - IP WHOIS + - Databases - IP WHOIS summary: IP WHOIS Snapshot operationId: dbIpWhois parameters: - - name: date - in: query - schema: - type: string - format: date - required: true + - name: date + in: query + schema: + type: string + format: date + required: true + example: "2026-10-01" responses: - '200': + "200": description: JSON gzipped content: application/octet-stream: @@ -1319,42 +1360,43 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: IP WHOIS Snapshot. Returns the file/snapshot described by this operation. /v3.3/status/snapshot/ip/whois: servers: *id001 get: tags: - - Databases - IP WHOIS + - Databases - IP WHOIS summary: IP WHOIS Snapshot Status operationId: dbIpWhoisStatus parameters: [] responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/SnapshotStatus' + $ref: "#/components/schemas/SnapshotStatus" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: IP WHOIS Snapshot Status. Returns the file/snapshot described by this operation. /v3.3/download/snapshot/ip/security: servers: *id001 get: tags: - - Databases - IP Security + - Databases - IP Security summary: IP Security Snapshot operationId: dbIpSecurity parameters: - - name: date - in: query - schema: - type: string - format: date - required: true + - name: date + in: query + schema: + type: string + format: date + required: true + example: "2026-10-01" responses: - '200': + "200": description: CSV content: application/octet-stream: @@ -1362,220 +1404,239 @@ paths: type: string format: binary 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: IP Security Snapshot. Returns the file/snapshot described by this operation. /v3.3/status/snapshot/ip/security: servers: *id001 get: tags: - - Databases - IP Security + - Databases - IP Security summary: IP Security Snapshot Status operationId: dbIpSecurityStatus parameters: [] responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/SnapshotStatus' + $ref: "#/components/schemas/SnapshotStatus" 4XX: - $ref: '#/components/responses/ErrorResponse' + $ref: "#/components/responses/ErrorResponse" description: IP Security Snapshot Status. Returns the file/snapshot described by this operation. /v2.0/whois/history: get: tags: - - WHOIS + - WHOIS operationId: whoisHistory summary: Historical WHOIS records for a domain + description: Every WHOIS record captured for the domain since 1986, in one response (no pagination). Cost 2 credits. parameters: - - name: domainName - in: query - required: true - schema: - type: string - description: Domain to fetch historical WHOIS records for - - name: page - in: query - required: false - schema: - type: integer - description: Page number - - name: format - in: query - required: false - schema: - type: string - enum: - - json - - xml + - name: domainName + in: query + required: true + schema: + type: string + description: Domain to fetch historical WHOIS records for + example: whoisfreaks.com + - name: format + in: query + required: false + schema: + type: string + enum: + - json + - xml responses: - '200': + "200": description: Historical WHOIS records content: application/json: schema: - $ref: '#/components/schemas/WhoisHistoricalResponse' + $ref: "#/components/schemas/WhoisHistoricalResponse" /v2.0/whois/reverse: get: tags: - - WHOIS + - WHOIS operationId: whoisReverse summary: Reverse WHOIS lookup by keyword parameters: - - name: keyword - in: query - required: true - schema: - type: string - description: Keyword to search across WHOIS records - - name: page - in: query - required: false - schema: - type: integer - description: Page number - - name: format - in: query - required: false - schema: - type: string - enum: - - json - - xml + - name: keyword + in: query + required: true + schema: + type: string + description: Keyword to search across WHOIS records + example: whoisfreaks + - name: page + in: query + required: false + schema: + type: integer + description: Page number + example: 1 + - name: format + in: query + required: false + schema: + type: string + enum: + - json + - xml responses: - '200': + "200": description: Reverse WHOIS results (paginated) content: application/json: schema: - $ref: '#/components/schemas/ReverseWhoisResponse' + $ref: "#/components/schemas/ReverseWhoisResponse" /v3.4/download/threat-feed/phishing: + servers: *id001 get: tags: - - Databases - Threat Feed + - Databases - Threat Feed operationId: downloadThreatFeedPhishing summary: Download the daily phishing threat feed (CSV) parameters: - - name: date - in: query - required: false - schema: - type: string - description: Feed date (yyyy-MM-dd); defaults to latest available + - name: date + in: query + required: false + schema: + type: string + description: Feed date (yyyy-MM-dd); omit for the full dump of the feed + example: "2026-10-01" responses: - '200': + "200": description: Phishing threat feed as CSV (domain,threat_type,confidence,first_seen,last_seen,No_of_threat_matched_pivots) content: application/octet-stream: schema: type: string format: binary + 4XX: + $ref: "#/components/responses/ErrorResponse" /v3.4/download/threat-feed/phishing/sample: + servers: *id001 get: tags: - - Databases - Threat Feed + - Databases - Threat Feed operationId: downloadThreatFeedPhishingSample summary: Download a sample of the phishing threat feed (CSV) parameters: [] responses: - '200': + "200": description: Sample phishing threat feed as CSV content: application/octet-stream: schema: type: string format: binary + 4XX: + $ref: "#/components/responses/ErrorResponse" /v3.4/download/threat-feed/malware: + servers: *id001 get: tags: - - Databases - Threat Feed + - Databases - Threat Feed operationId: downloadThreatFeedMalware summary: Download the daily malware threat feed (CSV) parameters: - - name: date - in: query - required: false - schema: - type: string - description: Feed date (yyyy-MM-dd); defaults to latest available + - name: date + in: query + required: false + schema: + type: string + description: Feed date (yyyy-MM-dd); omit for the full dump of the feed + example: "2026-10-01" responses: - '200': + "200": description: Malware threat feed as CSV (domain,threat_type,confidence,first_seen,last_seen,No_of_threat_matched_pivots) content: application/octet-stream: schema: type: string format: binary + 4XX: + $ref: "#/components/responses/ErrorResponse" /v3.4/download/threat-feed/malware/sample: + servers: *id001 get: tags: - - Databases - Threat Feed + - Databases - Threat Feed operationId: downloadThreatFeedMalwareSample summary: Download a sample of the malware threat feed (CSV) parameters: [] responses: - '200': + "200": description: Sample malware threat feed as CSV content: application/octet-stream: schema: type: string format: binary + 4XX: + $ref: "#/components/responses/ErrorResponse" /v3.4/download/threat-feed/spam: + servers: *id001 get: tags: - - Databases - Threat Feed + - Databases - Threat Feed operationId: downloadThreatFeedSpam summary: Download the daily spam threat feed (CSV) parameters: - - name: date - in: query - required: false - schema: - type: string - description: Feed date (yyyy-MM-dd); defaults to latest available + - name: date + in: query + required: false + schema: + type: string + description: Feed date (yyyy-MM-dd); omit for the full dump of the feed + example: "2026-10-01" responses: - '200': + "200": description: Spam threat feed as CSV (domain,threat_type,confidence,first_seen,last_seen,No_of_threat_matched_pivots) content: application/octet-stream: schema: type: string format: binary + 4XX: + $ref: "#/components/responses/ErrorResponse" /v3.4/download/threat-feed/spam/sample: + servers: *id001 get: tags: - - Databases - Threat Feed + - Databases - Threat Feed operationId: downloadThreatFeedSpamSample summary: Download a sample of the spam threat feed (CSV) parameters: [] responses: - '200': + "200": description: Sample spam threat feed as CSV content: application/octet-stream: schema: type: string format: binary + 4XX: + $ref: "#/components/responses/ErrorResponse" /v3.4/status: servers: *id001 get: tags: - - Account + - Account summary: Database File Status (Public) description: No API key required. Returns freshness of all downloadable files. operationId: databaseFileStatus security: [] responses: - '200': + "200": description: Successful response content: application/json: schema: - $ref: '#/components/schemas/DatabaseFileStatus' - '429': - $ref: '#/components/responses/RateLimited' + $ref: "#/components/schemas/DatabaseFileStatus" + "429": + $ref: "#/components/responses/RateLimited" components: securitySchemes: ApiKeyAuth: @@ -1589,8 +1650,8 @@ components: schema: type: string enum: - - json - - xml + - json + - xml default: json DateParam: name: date @@ -1599,37 +1660,38 @@ components: type: string format: date description: yyyy-MM-dd; omit for latest + example: "2026-10-01" responses: Unauthorized: description: Invalid API key content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" NotFound: description: Not found content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" BadRequest: description: Bad request content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" RateLimited: description: Too many requests content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" ErrorResponse: description: Error response (4XX) content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + $ref: "#/components/schemas/ErrorResponse" schemas: RegistrarInformation: type: object @@ -1741,7 +1803,7 @@ components: expiry_date: type: string domain_registrar: - $ref: '#/components/schemas/RegistrarInformation' + $ref: "#/components/schemas/RegistrarInformation" name_servers: type: array items: @@ -1750,8 +1812,9 @@ components: type: array items: type: string - whois_raw_domain: + whois_raw_registery: type: string + description: Raw registry WHOIS text (field name spelled as the API returns it) additionalProperties: true WhoisResponse: type: object @@ -1777,21 +1840,21 @@ components: expiry_date: type: string domain_registrar: - $ref: '#/components/schemas/RegistrarInformation' + $ref: "#/components/schemas/RegistrarInformation" reseller_contact: - $ref: '#/components/schemas/ResellerContact' + $ref: "#/components/schemas/ResellerContact" registrant_contact: - $ref: '#/components/schemas/PersonalInformation' + $ref: "#/components/schemas/PersonalInformation" administrative_contact: - $ref: '#/components/schemas/PersonalInformation' + $ref: "#/components/schemas/PersonalInformation" technical_contact: - $ref: '#/components/schemas/PersonalInformation' + $ref: "#/components/schemas/PersonalInformation" billing_contact: - $ref: '#/components/schemas/PersonalInformation' + $ref: "#/components/schemas/PersonalInformation" eligibility_info: - $ref: '#/components/schemas/EligibilityInfo' + $ref: "#/components/schemas/EligibilityInfo" abuse_contact: - $ref: '#/components/schemas/RegistrarInformation' + $ref: "#/components/schemas/RegistrarInformation" name_servers: type: array items: @@ -1803,7 +1866,7 @@ components: whois_raw_domain: type: string registry_data: - $ref: '#/components/schemas/RegistryData' + $ref: "#/components/schemas/RegistryData" additionalProperties: true description: Live WHOIS lookup response (DomainInfo). WhoisHistoricalItem: @@ -1832,21 +1895,21 @@ components: expiry_date: type: string domain_registrar: - $ref: '#/components/schemas/RegistrarInformation' + $ref: "#/components/schemas/RegistrarInformation" reseller_contact: - $ref: '#/components/schemas/ResellerContact' + $ref: "#/components/schemas/ResellerContact" registrant_contact: - $ref: '#/components/schemas/PersonalInformation' + $ref: "#/components/schemas/PersonalInformation" administrative_contact: - $ref: '#/components/schemas/PersonalInformation' + $ref: "#/components/schemas/PersonalInformation" technical_contact: - $ref: '#/components/schemas/PersonalInformation' + $ref: "#/components/schemas/PersonalInformation" billing_contact: - $ref: '#/components/schemas/PersonalInformation' + $ref: "#/components/schemas/PersonalInformation" eligibility_info: - $ref: '#/components/schemas/EligibilityInfo' + $ref: "#/components/schemas/EligibilityInfo" abuse_contact: - $ref: '#/components/schemas/RegistrarInformation' + $ref: "#/components/schemas/RegistrarInformation" name_servers: type: array items: @@ -1858,7 +1921,7 @@ components: whois_raw_domain: type: string registry_data: - $ref: '#/components/schemas/RegistryData' + $ref: "#/components/schemas/RegistryData" additionalProperties: true WhoisHistoricalResponse: type: object @@ -1872,24 +1935,23 @@ components: whois_domains_historical: type: array items: - $ref: '#/components/schemas/WhoisHistoricalItem' + $ref: "#/components/schemas/WhoisHistoricalItem" additionalProperties: true ReverseWhoisResponse: type: object properties: - Total_Result: + total_Result: type: integer - Total_Pages: + total_Pages: type: integer - Current_Page: + current_Page: type: integer whois_domains_historical: type: array items: - $ref: '#/components/schemas/WhoisHistoricalItem' + $ref: "#/components/schemas/WhoisHistoricalItem" additionalProperties: true - description: Reverse WHOIS response. Pagination keys are capitalized (Total_Result/Total_Pages/Current_Page) - as returned by the API. + description: Reverse WHOIS response. Pagination keys (total_Result, total_Pages, current_Page) are spelled as the API returns them. BulkWhoisItem: type: object properties: @@ -1899,25 +1961,81 @@ components: type: string error: type: string + query_time: + type: string + whois_server: + type: string + domain_registered: + type: string + secure_dns: + type: boolean + domain_handle: + type: string + create_date: + type: string + update_date: + type: string + expiry_date: + type: string + domain_registrar: + $ref: "#/components/schemas/RegistrarInformation" + reseller_contact: + $ref: "#/components/schemas/ResellerContact" + registrant_contact: + $ref: "#/components/schemas/PersonalInformation" + administrative_contact: + $ref: "#/components/schemas/PersonalInformation" + technical_contact: + $ref: "#/components/schemas/PersonalInformation" + billing_contact: + $ref: "#/components/schemas/PersonalInformation" + eligibility_info: + $ref: "#/components/schemas/EligibilityInfo" + abuse_contact: + $ref: "#/components/schemas/RegistrarInformation" + name_servers: + type: array + items: + type: string + domain_status: + type: array + items: + type: string + whois_raw_domain: + type: string + registry_data: + $ref: "#/components/schemas/RegistryData" additionalProperties: true - description: One bulk WHOIS result; success items also carry all WhoisResponse fields. + description: One bulk WHOIS result. Successful items carry the same fields as a live WHOIS lookup. BulkWhoisResponse: type: object properties: bulk_whois_response: type: array items: - $ref: '#/components/schemas/BulkWhoisItem' + $ref: "#/components/schemas/BulkWhoisItem" additionalProperties: true DnsRecord: type: object properties: type: + type: integer + description: "Numeric DNS record type: 1 A, 2 NS, 5 CNAME, 6 SOA, 12 PTR, 15 MX, 16 TXT, 28 AAAA, 99 SPF." + dnsType: type: string + description: Record type name, e.g. A, MX, TXT name: type: string ttl: type: integer + rawText: + type: string + description: The record in zone-file format + rRsetType: + type: integer + singleName: + type: string + description: Target host for NS, CNAME and PTR records address: type: string priority: @@ -1936,6 +2054,8 @@ components: type: string serial: type: integer + format: int64 + description: SOA serial; values above 2^31 are common, so it is 64-bit refresh: type: integer retry: @@ -1964,7 +2084,7 @@ components: dnsRecords: type: array items: - $ref: '#/components/schemas/DnsRecord' + $ref: "#/components/schemas/DnsRecord" additionalProperties: true description: Live DNS response (DnsInfo). HistoricalDnsResponse: @@ -1972,16 +2092,15 @@ components: properties: totalPages: type: integer - currenPage: + currentPage: type: integer totalRecords: type: integer - historicalDns: + historicalDnsRecords: type: array items: - $ref: '#/components/schemas/DnsResponse' + $ref: "#/components/schemas/DnsResponse" additionalProperties: true - description: 'Note: ''currenPage'' spelling matches the API.' ReverseDnsResponse: type: object properties: @@ -1994,7 +2113,7 @@ components: reverseDnsRecords: type: array items: - $ref: '#/components/schemas/DnsResponse' + $ref: "#/components/schemas/DnsResponse" additionalProperties: true BulkDnsResponse: type: object @@ -2002,7 +2121,7 @@ components: bulk_dns_info: type: array items: - $ref: '#/components/schemas/DnsResponse' + $ref: "#/components/schemas/DnsResponse" additionalProperties: true Subdomain: type: object @@ -2016,7 +2135,7 @@ components: inactive_from: type: string dns_records: - $ref: '#/components/schemas/DnsResponse' + $ref: "#/components/schemas/DnsResponse" additionalProperties: true SubdomainsResponse: type: object @@ -2036,7 +2155,7 @@ components: subdomains: type: array items: - $ref: '#/components/schemas/Subdomain' + $ref: "#/components/schemas/Subdomain" additionalProperties: true DomainAvailabilityItem: type: object @@ -2060,7 +2179,7 @@ components: domain_available_response: type: array items: - $ref: '#/components/schemas/DomainAvailabilityItem' + $ref: "#/components/schemas/DomainAvailabilityItem" additionalProperties: true BulkDomainAvailabilityResponse: type: object @@ -2068,7 +2187,7 @@ components: bulk_domain_availability_response: type: array items: - $ref: '#/components/schemas/DomainAvailabilityItem' + $ref: "#/components/schemas/DomainAvailabilityItem" additionalProperties: true TyposquattingDomain: type: object @@ -2102,7 +2221,7 @@ components: domains: type: array items: - $ref: '#/components/schemas/TyposquattingDomain' + $ref: "#/components/schemas/TyposquattingDomain" additionalProperties: true SslUnitInfo: type: object @@ -2202,13 +2321,13 @@ components: items: type: string authorityInfoAccess: - $ref: '#/components/schemas/SslAuthorityInfo' + $ref: "#/components/schemas/SslAuthorityInfo" subjectAlternativeNames: - $ref: '#/components/schemas/SslAlternateNames' + $ref: "#/components/schemas/SslAlternateNames" certificatePolicies: type: array items: - $ref: '#/components/schemas/SslCertificatePolicy' + $ref: "#/components/schemas/SslCertificatePolicy" additionalProperties: true SslCertificate: type: object @@ -2226,13 +2345,13 @@ components: signatureAlgorithm: type: string subject: - $ref: '#/components/schemas/SslUnitInfo' + $ref: "#/components/schemas/SslUnitInfo" issuer: - $ref: '#/components/schemas/SslUnitInfo' + $ref: "#/components/schemas/SslUnitInfo" publicKey: - $ref: '#/components/schemas/SslPublicKeyInfo' + $ref: "#/components/schemas/SslPublicKeyInfo" extensions: - $ref: '#/components/schemas/SslExtensionsInfo' + $ref: "#/components/schemas/SslExtensionsInfo" pemRaw: type: string additionalProperties: true @@ -2246,7 +2365,7 @@ components: sslCertificates: type: array items: - $ref: '#/components/schemas/SslCertificate' + $ref: "#/components/schemas/SslCertificate" sslRaw: type: string additionalProperties: true @@ -2752,27 +2871,27 @@ components: inet_nums: type: array items: - $ref: '#/components/schemas/InetNum' + $ref: "#/components/schemas/InetNum" organization: - $ref: '#/components/schemas/WhoisOrganization' + $ref: "#/components/schemas/WhoisOrganization" irt: - $ref: '#/components/schemas/Irt' + $ref: "#/components/schemas/Irt" administrative_contacts: type: array items: - $ref: '#/components/schemas/WhoisPerson' + $ref: "#/components/schemas/WhoisPerson" technical_contacts: type: array items: - $ref: '#/components/schemas/WhoisPerson' + $ref: "#/components/schemas/WhoisPerson" abuse_contacts: type: array items: - $ref: '#/components/schemas/WhoisPerson' + $ref: "#/components/schemas/WhoisPerson" routes: type: array items: - $ref: '#/components/schemas/Route' + $ref: "#/components/schemas/Route" additionalProperties: true AsnPeer: type: object @@ -2816,15 +2935,15 @@ components: downstreams: type: array items: - $ref: '#/components/schemas/AsnPeer' + $ref: "#/components/schemas/AsnPeer" upstreams: type: array items: - $ref: '#/components/schemas/AsnPeer' + $ref: "#/components/schemas/AsnPeer" peers: type: array items: - $ref: '#/components/schemas/AsnPeer' + $ref: "#/components/schemas/AsnPeer" whois_response: type: string additionalProperties: true @@ -2832,9 +2951,9 @@ components: type: object properties: asn: - $ref: '#/components/schemas/AsnInfo' + $ref: "#/components/schemas/AsnInfo" additionalProperties: true - description: "ASN WHOIS v2 (/v2.0/asn-whois) \u2014 pass-through of ipgeolocation ASN data." + description: "ASN WHOIS v2 (/v2.0/asn-whois): pass-through of ipgeolocation ASN data." IpLocation: type: object properties: @@ -2931,11 +3050,11 @@ components: type: object properties: asn: - $ref: '#/components/schemas/GeoAsn' + $ref: "#/components/schemas/GeoAsn" connection_type: type: string company: - $ref: '#/components/schemas/GeoCompany' + $ref: "#/components/schemas/GeoCompany" additionalProperties: true Currency: type: object @@ -2953,13 +3072,13 @@ components: ip: type: string location: - $ref: '#/components/schemas/IpLocation' + $ref: "#/components/schemas/IpLocation" country_metadata: - $ref: '#/components/schemas/CountryMetadata' + $ref: "#/components/schemas/CountryMetadata" network: - $ref: '#/components/schemas/GeoNetwork' + $ref: "#/components/schemas/GeoNetwork" currency: - $ref: '#/components/schemas/Currency' + $ref: "#/components/schemas/Currency" additionalProperties: true IpSecurityNetwork: type: object @@ -3041,13 +3160,13 @@ components: ip: type: string location: - $ref: '#/components/schemas/IpLocation' + $ref: "#/components/schemas/IpLocation" network: - $ref: '#/components/schemas/IpSecurityNetwork' + $ref: "#/components/schemas/IpSecurityNetwork" asn: - $ref: '#/components/schemas/IpSecurityAsn' + $ref: "#/components/schemas/IpSecurityAsn" security: - $ref: '#/components/schemas/IpSecurity' + $ref: "#/components/schemas/IpSecurity" additionalProperties: true DomainReputationInput: type: object @@ -3101,11 +3220,11 @@ components: sources: type: array items: - $ref: '#/components/schemas/ThreatSource' + $ref: "#/components/schemas/ThreatSource" pivot_matches: type: array items: - $ref: '#/components/schemas/PivotMatch' + $ref: "#/components/schemas/PivotMatch" additionalProperties: true DgaFeatures: type: object @@ -3135,7 +3254,7 @@ components: model: type: string features: - $ref: '#/components/schemas/DgaFeatures' + $ref: "#/components/schemas/DgaFeatures" interpretation: type: string additionalProperties: true @@ -3161,15 +3280,15 @@ components: positive: type: array items: - $ref: '#/components/schemas/ReputationSignal' + $ref: "#/components/schemas/ReputationSignal" negative: type: array items: - $ref: '#/components/schemas/ReputationSignal' + $ref: "#/components/schemas/ReputationSignal" neutral: type: array items: - $ref: '#/components/schemas/ReputationSignal' + $ref: "#/components/schemas/ReputationSignal" additionalProperties: true ReputationIndicators: type: object @@ -3205,9 +3324,9 @@ components: trust_band: type: string signals: - $ref: '#/components/schemas/ReputationSignals' + $ref: "#/components/schemas/ReputationSignals" indicators: - $ref: '#/components/schemas/ReputationIndicators' + $ref: "#/components/schemas/ReputationIndicators" additionalProperties: true RelatedIoc: type: object @@ -3229,7 +3348,7 @@ components: related_iocs: type: array items: - $ref: '#/components/schemas/RelatedIoc' + $ref: "#/components/schemas/RelatedIoc" feed_tags: type: array items: @@ -3255,7 +3374,7 @@ components: type: object properties: input: - $ref: '#/components/schemas/DomainReputationInput' + $ref: "#/components/schemas/DomainReputationInput" assessed_at: type: string version: @@ -3263,15 +3382,15 @@ components: processing_time_ms: type: integer risk_category: - $ref: '#/components/schemas/RiskCategory' + $ref: "#/components/schemas/RiskCategory" dga_score: - $ref: '#/components/schemas/DgaScore' + $ref: "#/components/schemas/DgaScore" trust_signals: - $ref: '#/components/schemas/TrustSignals' + $ref: "#/components/schemas/TrustSignals" intelligence: - $ref: '#/components/schemas/ReputationIntelligence' + $ref: "#/components/schemas/ReputationIntelligence" evidence_summary: - $ref: '#/components/schemas/EvidenceSummary' + $ref: "#/components/schemas/EvidenceSummary" errors: type: array items: @@ -3305,9 +3424,9 @@ components: apiKey: type: string apiCredits: - $ref: '#/components/schemas/ApiCredits' + $ref: "#/components/schemas/ApiCredits" apiSubscription: - $ref: '#/components/schemas/ApiSubscription' + $ref: "#/components/schemas/ApiSubscription" additionalProperties: true DateRangeStatus: type: object @@ -3321,65 +3440,65 @@ components: type: object properties: gtld: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" cctld: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" dns: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" cleaned_gtld: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" cleaned_cctld: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" additionalProperties: true UpdateFrequencies: type: object properties: daily: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" weekly: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" monthly: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" additionalProperties: true DatabaseUpdates: type: object properties: domain_whois: - $ref: '#/components/schemas/UpdateFrequencies' + $ref: "#/components/schemas/UpdateFrequencies" dns: - $ref: '#/components/schemas/UpdateFrequencies' + $ref: "#/components/schemas/UpdateFrequencies" subdomains: - $ref: '#/components/schemas/UpdateFrequencies' + $ref: "#/components/schemas/UpdateFrequencies" ip_whois: - $ref: '#/components/schemas/UpdateFrequencies' + $ref: "#/components/schemas/UpdateFrequencies" additionalProperties: true ThreatFeedStatus: type: object properties: phishing: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" malware: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" spam: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" additionalProperties: true DatabaseFileStatus: type: object properties: newly: - $ref: '#/components/schemas/NewlyStatus' + $ref: "#/components/schemas/NewlyStatus" expired: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" cleaned_expired: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" dropped: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" dropped_with_backlinks: - $ref: '#/components/schemas/DateRangeStatus' + $ref: "#/components/schemas/DateRangeStatus" threat_feed: - $ref: '#/components/schemas/ThreatFeedStatus' + $ref: "#/components/schemas/ThreatFeedStatus" database_updates: - $ref: '#/components/schemas/DatabaseUpdates' + $ref: "#/components/schemas/DatabaseUpdates" additionalProperties: true SnapshotStatus: type: object @@ -3410,7 +3529,8 @@ components: code: type: integer additionalProperties: true - description: Error response. `status` may be an integer (e.g. 401), boolean, or string depending + description: + Error response. `status` may be an integer (e.g. 401), boolean, or string depending on the endpoint, so it is intentionally untyped to avoid deserialization failures. BulkDomainAvailabilityRequest: type: object @@ -3420,13 +3540,14 @@ components: items: type: string maxItems: 100 - description: "Mode 1 \u2014 list of full domain names. Cannot be used with tld." + description: "Mode 1: list of full domain names. Cannot be used with tld." tld: type: array items: type: string maxItems: 100 - description: "Mode 2 \u2014 TLDs to check against the domain query param. Cannot be used with\ + description: + "Mode 2: TLDs to check against the domain query param. Cannot be used with\ \ domainNames." description: Request body for POST /v2.0/domain/availability. Use domainNames OR tld. additionalProperties: true