# BigQuery

Look up addresses in VPNDetection's databases from inside Google BigQuery: subscribe to a listing, then call a function in any query, with nothing to download.

VPNDetection's databases are published to Google BigQuery through [BigQuery sharing](https://cloud.google.com/bigquery/docs/analytics-hub-introduction), so you look addresses up in SQL with nothing to download. Subscribing adds a read-only dataset to a project of yours, rebuilt from the same build as the downloads, and you query it like your own tables.

Use it when the addresses you want to check are already in BigQuery, such as a table of logins or orders: each table keyed by address has a function, so enriching your own table is one more column. Every listing shows VPNDetection the email address of each account that queries it.

## Before you begin

- A Google Cloud project with BigQuery, where your queries run and bill.
- For any listing but the Open one, a license for that database.

## Subscribe to the Open listing

`VPNDetection Open` holds the Open databases, free under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/):

| Table | Database |
|---|---|
| `tor_ip_v1` | [Tor IP](/database/tor-ip) |
| `relay_ip_v1` | [Relay IP](/database/relay-ip/relay-ip) |
| `relay_provider_v1` | [Relay Provider](/database/relay-ip/relay-provider) |

To subscribe:

1. In the BigQuery console, open **Sharing** and search for VPNDetection.
2. Pick the listing in the region your data lives in: `VPNDetection Open` for the US multi-region, `VPNDetection Open EU` for the EU one, since BigQuery doesn't join across regions.
3. Click **Subscribe** and name the dataset it adds. The examples below call it `vpndetection_open`.

Credit VPNDetection with a link to [vpndetection.io](https://vpndetection.io) wherever you use the data, and share what you build from it under the same license.

## Look up an address

Each table keyed by address has a function of the same name. Pass it an address and it returns the row covering it as a `STRUCT`, or `NULL` when there's none:

```sql
SELECT vpndetection_open.tor_ip_v1('185.220.101.1').confidence
```

Enriching a table of your own is one more column:

```sql
SELECT l.*, vpndetection_open.relay_ip_v1(l.ip).provider AS relay
FROM mydataset.logins AS l
```

Where several rows cover an address, the function returns the narrowest. For every one of them, call the table function named after the table with a `lookup_` prefix. It takes a table with an `ip` column and returns a row per match:

```sql
SELECT ip, provider, confidence
FROM vpndetection_vpn_ip.lookup_vpn_ip_v1((SELECT ip FROM mydataset.logins))
```

Both take IPv4 and IPv6, look up an IPv4-mapped address (`::ffff:1.2.3.4`) as the IPv4 it carries, and treat a value that isn't an address as a miss. On November 28, 2026, a million addresses against VPN IP's 15.9 million ranges took 7 to 9 seconds and read 1,172 MB through `vpn_ip_v1`, and about 3 seconds and 481 MB through `lookup_vpn_ip_v1`, selecting `provider`.

`ip_sample` holds several hundred addresses from the Open tables, picked again every day, so you can try the functions before you bring your own. This query checks that your subscription works:

```sql
SELECT ip,
    vpndetection_open.tor_ip_v1(ip).confidence AS tor,
    vpndetection_open.relay_ip_v1(ip).provider AS relay
FROM vpndetection_open.ip_sample
```

## Subscribe to the other databases

Each database in this table is a listing of its own, with a dataset in each region, under the license you hold for it:

| Listing | Tables |
|---|---|
| [VPN IP](/database/vpn-ip/vpn-ip) | `vpn_ip_v1`, `vpn_provider_v3` |
| [Datacenter Proxy IP](/database/dcproxy-ip/dcproxy-ip-30d) | `dcproxy_ip_1d_v1`, `dcproxy_ip_7d_v1`, `dcproxy_ip_14d_v1`, `dcproxy_ip_30d_v1`, `dcproxy_ip_60d_v1`, `dcproxy_ip_90d_v1`, `dcproxy_provider_v2` |
| [Public Proxy IP](/database/pubproxy-ip/pubproxy-ip-30d) | `pubproxy_ip_1d_v1`, `pubproxy_ip_7d_v1`, `pubproxy_ip_14d_v1`, `pubproxy_ip_30d_v1`, `pubproxy_ip_60d_v1`, `pubproxy_ip_90d_v1` |
| [Hosting IP](/database/hosting-ip/hosting-ip) | `hosting_ip_v1`, `hosting_provider_v1` |
| [Bot IP](/database/bot-ip/bot-ip) | `bot_ip_v1`, `bot_provider_v1` |
| [CDN IP](/database/cdn-ip/cdn-ip) | `cdn_ip_v1`, `cdn_provider_v1` |

Name each dataset after its listing when you subscribe, `vpndetection_vpn_ip` for VPN IP, and the functions of every database you hold combine in one query:

```sql
SELECT l.*,
    vpndetection_vpn_ip.vpn_ip_v1(l.ip).provider AS vpn,
    vpndetection_open.tor_ip_v1(l.ip).confidence AS tor
FROM mydataset.logins AS l
```

To add one of these databases, [ask for a license](https://vpndetection.io/contact?purpose=licensing&subject=Databases+in+BigQuery).

## Tables

Each database is one table named after its database ID, with the same rows and columns as its CSV download. An empty cell is `NULL`. A table keyed by range adds the columns its functions use: `start_ip_bytes`, `end_ip_bytes` and `join_key`. A provider catalog is a plain table beside it.

A table's description gives its row count and the date of its data, and every column has a description of its own.

## Costs and updates

Your queries run and bill in your own project, at BigQuery's usual rates. The tables cost you nothing to store.

A function scans its whole table, however few addresses you pass it: the scalar reads every column, and the table function only the columns it matches on and the ones you select. One address through `vpn_ip_v1` reads as much as a million, and a dry run shows how much a query reads before you run it.

Each table is rebuilt the day its database changes. A subscription always reads the current table, so there's nothing to refresh on your side.

## Troubleshoot

| Symptom | What to do |
| --- | --- |
| A query that joins your table to a listing's fails on location. | BigQuery doesn't join across regions, so subscribe to the listing in your data's region, such as `VPNDetection Open EU` for data in the EU. |
| A function returns `NULL` for an address. | No row covers that address, or the value isn't an address, which the functions treat as a miss. |
| A query reads more than you expected. | A function scans its whole table however few addresses you pass, so prefer the `lookup_` table function and select only the columns you need. A dry run shows the bytes first. |

## Next steps

You can now look addresses up in BigQuery and enrich your own tables. Each table's columns are documented on its database's page in the [Database Reference](/database), and [Check addresses in bulk](/guides/bulk-check) compares BigQuery with the other ways to check many addresses at once.
