Skip to main content
Before you can start converting IP addresses, you need to authenticate your project with a access key. Each project has unique access tokens that you can generate and use to authorize your requests. This helps us track usage and ensure that only authorized clients can access the service. The initialization function should always be called once at the start of your application — we’ll handle everything else automatically afterward on your behalf for all subsequent requests.
import { Init } from '@ip2geo/sdk'
import { Env } from '@/data'

await Init(Env.IP2GEO_API_KEY)
Once you initialize the SDK with the Init method, you can call any function without needing to manually include your token again.
We also provide some options to customize the initialization, but it’s not recommended, unless you know what you are doing.
import { Init } from '@ip2geo/sdk'
import { Env } from '@/data'

await Init(Env.IP2GEO_API_KEY, {
    clientRuntimeMessage: false,
    versionUpdateMessage: false
})

Parameters

key
string
required
The API key used to authenticate with the Ip2Geo service.
options.clientRuntimeMessage
boolean
Whether to display client runtime messages. Defaults to true.
options.versionUpdateMessage
boolean
Whether to display version update messages. Defaults to true.