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.0.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.0.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bigdatacloud-1.0.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.0.0.tar.gz
Algorithm Hash digest
SHA256 075d857bcdae5b640229eeb55cb29bf139e4e5849dfea69ad2b8cdc77b23f732
MD5 0f5e335eb43fc9a0360567ffd092647f
BLAKE2b-256 cb65a1de6c030f490f20b98fc45939a58d41dab8825b8687b107f7c385c85e6c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bigdatacloud-1.0.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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67a850e106629e8a996da0266210377c963bc08ca160c88980df83ad2e891fcc
MD5 f3208d42c75b193727111866a61260e0
BLAKE2b-256 d19f1f717c8a6b3e57369faed686a7efd22acf79acf9679d0491ecb4ac9c115f

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