dcip logo

dcip

akarca/dcip by us

Django app that detects datacenter, cloud provider and VPN IP addresses

0stars Python MIT last commit 6 hours ago
README.md

django-dcip

Django app for detecting datacenter, cloud provider, and VPN IP addresses.

Live demo & free API: https://ipaddress.world/datacenter-ip-checker/

Installation

pip install git+https://github.com/akarca/dcip.git

Setup

  1. Add to INSTALLED_APPS:
INSTALLED_APPS = [
    ...
    "dcip",
]
  1. Add the database router and SQLite database:
DATABASES = {
    ...
    "server_ip": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": BASE_DIR / "server_ip_db.sqlite3",
    },
}

DATABASE_ROUTERS = [..., "dcip.db_router.DCIPRouter"]
  1. Include URLs (or wire them manually in your urlpatterns):
from django.urls import include, path

urlpatterns = [
    ...
    path("", include("dcip.urls")),
]
  1. Populate the database:
python manage.py migrate --database=server_ip
python manage.py generate_server_ip_db
python manage.py merge_server_ip

Free API

No API key required. Check any IPv4 address:

GET https://ipaddress.world/api/dcip/8.8.8.8/
{
    "ip": "8.8.8.8",
    "is_datacenter": true,
    "provider": "gc",
    "provider_name": "Google"
}

Examples

# curl
curl https://ipaddress.world/api/dcip/8.8.8.8/
# Python
import requests
r = requests.get("https://ipaddress.world/api/dcip/8.8.8.8/")
print(r.json()["is_datacenter"])  # True
// JavaScript
const r = await fetch("https://ipaddress.world/api/dcip/8.8.8.8/")
const data = await r.json()
console.log(data.is_datacenter) // true

Tool Page

Visit /datacenter-ip-checker/ for the web UI with IP input form and results.

Providers

AWS, Google Cloud, Azure, DigitalOcean, Hetzner, Oracle, Linode, Akamai, Vultr, Cloudflare, Alibaba, and 50,000+ other datacenter ranges.

Database updated daily from public sources.

Programmatic Usage

from dcip.views import check_ip

is_datacenter, provider_slug, provider_name = check_ip("8.8.8.8")
# (True, "gc", "Google")

License

MIT