Before you can start converting IP addresses, you need to authenticate your project with a secret key. The initialization function should always be called once at the start of your application — we’ll handle everything else automatically afterward.Documentation Index
Fetch the complete documentation index at: https://docs.ip2geo.dev/llms.txt
Use this file to discover all available pages before exploring further.
Server-Side (Secret Key)
Use a secret key (i2g_sk_…) when running the SDK on your server. Secret keys are created from the Secret Keys section in your dashboard. Always store them in environment variables — never expose them in client-side code.
Client-Side (Public Key)
Use a public key (i2g_pk_…) when running the SDK in the browser. Public keys are generated from the Websites section in your dashboard — each one is tied to a specific domain.
i2g_pk_ prefix and suppresses the client runtime warning — no need to set clientRuntimeMessage: false.
Browsers automatically send the Origin header on cross-origin requests, which is how we verify the request comes from your allowed domain.
Public keys are safe to include in your frontend code. Even if someone copies your public key, it won’t work from a different domain.
Options
You can customize the initialization with optional parameters:Caching
By default, the SDK caches successful conversions in memory. When you convert an IP that has been converted before, the SDK returns the cached result instantly while refreshing the data in the background. This means your subsequent requests for the same IP are significantly faster, while the data stays up to date. The API request still happens in the background on every call, so your usage and billing are not affected by caching in any way. You can customize or disable caching through the init options:To disable caching entirely, set
cache to false. When disabled, every conversion will make a fresh API request.- TypeScript
- Ruby
- Python
- PHP
Parameters
The secret key used to authenticate with the Ip2Geo service. Can be a secret key (
i2g_sk_…) for server-side or a public key (i2g_pk_…) for client-side usage.Whether to display client runtime warning when using a secret key in the browser. Automatically disabled when using a public key. Defaults to
true.Whether to display version update messages. Defaults to
true.Whether to enable caching for successful conversions. Defaults to
true.Maximum number of cached entries. Must be between
10 and 50000. Defaults to 1000.Cache time-to-live in milliseconds. After this duration, cached entries expire and the next request will wait for a fresh response. Must be between
30000 (30 seconds) and 86400000 (1 day). Defaults to 300000 (5 minutes).