Skip to main content

Official Python SDK for BigDataCloud APIs — IP Geolocation, Reverse Geocoding, Phone & Email Verification, Network Engineering

Project description

BigDataCloud Python SDK

PyPI License: MIT

Official Python SDK for BigDataCloud APIs. Strongly-typed client for IP Geolocation, Reverse Geocoding, Phone & Email Verification, Network Engineering — plus a GraphQL interface for all packages.

Installation

pip install bigdatacloud

API Key

Get a free API key at bigdatacloud.com/login. No credit card required.

Store your key in the BIGDATACLOUD_API_KEY environment variable:

export BIGDATACLOUD_API_KEY=your-key-here

Quick Start

from bigdatacloud import BigDataCloudClient

# Reads BIGDATACLOUD_API_KEY from environment
client = BigDataCloudClient.from_environment()

# Or pass the key directly
# client = BigDataCloudClient("your-key-here")

# IP Geolocation
geo = client.ip_geolocation.get("1.1.1.1")
print(f"{geo.location.city}, {geo.country.name}")

# Full geolocation with hazard report
full = client.ip_geolocation.get_full("1.1.1.1")
print(f"Security: {full.security_threat}")
print(f"Is Tor:   {full.hazard_report.is_known_as_tor_server}")

# Reverse Geocoding
place = client.reverse_geocoding.reverse_geocode(-33.87, 151.21)
print(f"{place.city}, {place.principal_subdivision}, {place.country_name}")

# Phone Validation
phone = client.verification.validate_phone("+61412345678", "AU")
print(f"Valid: {phone.is_valid}, Type: {phone.line_type}")

# Email Verification
email = client.verification.verify_email("user@example.com")
print(f"Valid: {email.is_valid}, Disposable: {email.is_disposable}")

Context Manager

with BigDataCloudClient.from_environment() as client:
    geo = client.ip_geolocation.get("1.1.1.1")

Confidence Area

The confidence_area field may encode multiple polygons. Use the helper:

from bigdatacloud import split_into_polygons

geo = client.ip_geolocation.get_with_confidence_area("1.1.1.1")
polygons = split_into_polygons(geo.confidence_area)
for ring in polygons:
    print(f"Polygon with {len(ring)} points")

GraphQL

BigDataCloud is the only IP geolocation provider with a GraphQL interface. Use the fluent builders to select exactly the fields you need:

# Select only city, country flag, and confidence
result = client.graphql.ip_geolocation.ip_data("1.1.1.1",
    lambda q: q.locality().country(lambda c: c.flag_emoji()).confidence())

print(result["locality"]["city"])

# Reverse geocoding with timezone
loc = client.graphql.reverse_geocoding.location_data(-33.87, 151.21,
    lambda q: q.locality().country().timezone())

# Phone & Email
email = client.graphql.verification.email_verification("user@example.com")
phone = client.graphql.verification.phone_number("+61412345678")

# Network Engineering
asn = client.graphql.network_engineering.asn_info_full("AS13335",
    lambda q: q.basic_info().receiving_from())

Raw queries are also supported:

data = client.graphql.ip_geolocation.query_raw("""
{
    ipData(ip: "1.1.1.1") {
        locality { city }
        country { name }
    }
}
""")

Available APIs

Client Key Methods
client.ip_geolocation get, get_with_confidence_area, get_full, get_country_by_ip, get_country_info, get_all_countries, get_hazard_report, get_user_risk, get_asn_info, get_network_by_ip, get_timezone_by_iana_id, get_timezone_by_ip, parse_user_agent
client.reverse_geocoding reverse_geocode, reverse_geocode_with_timezone, get_timezone_by_location
client.verification validate_phone, validate_phone_by_ip, verify_email
client.network_engineering get_asn_info_extended, get_receiving_from, get_transit_to, get_bgp_prefixes, get_networks_by_cidr, get_asn_rank_list, get_tor_exit_nodes
client.graphql.ip_geolocation ip_data, country_info, user_agent, timezone_info, query_raw
client.graphql.reverse_geocoding location_data, query_raw
client.graphql.verification email_verification, phone_number, query_raw
client.graphql.network_engineering asn_info_full, network_by_ip, query_raw

Samples

python samples/ip_geolocation.py
python samples/reverse_geocoding.py
python samples/verification.py
python samples/network_engineering.py
python samples/graphql_sample.py

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bigdatacloud-1.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bigdatacloud-1.1.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file bigdatacloud-1.1.0.tar.gz.

File metadata

  • Download URL: bigdatacloud-1.1.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for bigdatacloud-1.1.0.tar.gz
Algorithm Hash digest
SHA256 49e63a6cf587cf044fdd895ebd48ee4be4c53016ec48fcaf5d815e3f853c686a
MD5 03eafb3b1890126d47384ceb38e1082e
BLAKE2b-256 747d62cc9ae6fb855dd4157a2b58fc1659c253d4eb0071a4ec47867debe3ac6d

See more details on using hashes here.

File details

Details for the file bigdatacloud-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: bigdatacloud-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for bigdatacloud-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d37cd02e2f530665bcbe5ee30399991b6fdbf0937c32c9d48cd57a0051108716
MD5 0d77794e71df41d28892e0c2b0379d0c
BLAKE2b-256 33f4e97b71b8497dbf659b972dad6daeb74d5dd8a19c88d34520edaffd5f34cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page