# Bulk Convert IP's Source: https://docs.ip2geo.dev/api/bulk-convert-ips POST /convert This http method allows you to convert multiple IP addresses into their corresponding geolocation data. This method can convert up to 5000 IP addresses in a single request. If you need to convert more than 5000 IPs, consider splitting your requests into smaller batches to avoid exceeding this limit. # Convert IP Source: https://docs.ip2geo.dev/api/convert-ip GET /convert This http method allows you to convert a single IP address into its corresponding geolocation data. # Get Conversion Source: https://docs.ip2geo.dev/api/get-conversion GET /conversions/get This http method allows you to retrieve a single conversion by its unique identifier. # Get Conversions Source: https://docs.ip2geo.dev/api/get-conversions POST /conversions/get This http method allows you to retrieve multiple conversions by their unique identifiers. # Introduction Source: https://docs.ip2geo.dev/api/introduction Our API is a alternative way to access our convertion services directly through HTTP requests. Its recommended to use the SDK unless your environment does not support npm packages. We have simplified the API to make it easy to use with clear endpoints and consistent request/response structures. ## Authentication All API requests require the x-api-key header. You can use either key type: * **Secret key** (i2g\_sk\_...) — for server-side requests. Generated from the Secret Keys section in your dashboard. * **Public key** (i2g\_pk\_...) — for client-side (browser) requests. Generated from the Websites section. Must include a valid Origin header matching the registered domain. ```bash theme={null} # Server-side with secret key curl --request GET \ --url https://api.ip2geo.dev/convert?ip=8.8.8.8 \ --header 'x-api-key: i2g_sk_your_secret_key' # Client-side with public key (browser sends Origin automatically) fetch('https://api.ip2geo.dev/convert?ip=8.8.8.8', { headers: { 'x-api-key': 'i2g_pk_your_public_key' } }) ``` ## When to Use the API Instead of the SDK? * **Environment Limitations:** If your environment doesn't support npm (e.g., a non-JavaScript runtime). * **Direct Control:** If you need direct control over HTTP requests for specific use cases that the SDK doesn't cover. * **Lightweight Needs:** If you want to avoid adding an additional dependency to your project. # List Conversions Source: https://docs.ip2geo.dev/api/list-conversions GET /conversions/list This http method allows you to list your conversions with pagination, filtering, and field selection. # SELECT Source: https://docs.ip2geo.dev/constants/select The SELECT constants allow you to retrieve only the data fields you need instead of the full conversion, reducing payload size and improving performance. They work with both the SDK's and the API. ```typescript TypeScript theme={null} import { GetConversion, SELECT } from '@ip2geo/sdk' const { data } = await GetConversion({ conversionId: 'your-conversion-uuid', select: [ SELECT.COUNTRY_NAME, SELECT.COUNTRY_CODE, SELECT.ASN_NAME ] }) ``` ```ruby Ruby theme={null} result = Ip2Geo.get_conversion( conversion_id: 'your-conversion-uuid', select: [ Ip2Geo.select[:COUNTRY_NAME], Ip2Geo.select[:COUNTRY_CODE], Ip2Geo.select[:ASN_NAME] ] ) ``` ```python Python theme={null} result = ip2geo.get_conversion( conversion_id='your-conversion-uuid', select=[ ip2geo.SELECT['COUNTRY_NAME'], ip2geo.SELECT['COUNTRY_CODE'], ip2geo.SELECT['ASN_NAME'] ] ) ``` ```php PHP theme={null} $result = Ip2Geo::getConversion( conversionId: 'your-conversion-uuid', select: [ Ip2Geo::SELECT['COUNTRY_NAME'], Ip2Geo::SELECT['COUNTRY_CODE'], Ip2Geo::SELECT['ASN_NAME'] ] ); ``` The full list of SELECT constant you can import and use when retrieving data: | Constant | Value | | -------------------------------------- | -------------------------------------------- | | `SELECT.IP` | `'ip'` | | `SELECT.TYPE` | `'type'` | | `SELECT.IS_EU` | `'is_eu'` | | `SELECT.CONTINENT_NAME` | `'continent.name'` | | `SELECT.CONTINENT_CODE` | `'continent.code'` | | `SELECT.CONTINENT_GEONAME_ID` | `'continent.geoname_id'` | | `SELECT.COUNTRY_NAME` | `'continent.country.name'` | | `SELECT.COUNTRY_CODE` | `'continent.country.code'` | | `SELECT.COUNTRY_GEONAME_ID` | `'continent.country.geoname_id'` | | `SELECT.COUNTRY_PHONE_CODE` | `'continent.country.phone_code'` | | `SELECT.COUNTRY_CAPITAL` | `'continent.country.capital'` | | `SELECT.COUNTRY_TLD` | `'continent.country.tld'` | | `SELECT.SUBDIVISION_NAME` | `'continent.country.subdivision.name'` | | `SELECT.SUBDIVISION_CODE` | `'continent.country.subdivision.code'` | | `SELECT.CITY_NAME` | `'continent.country.city.name'` | | `SELECT.CITY_GEONAME_ID` | `'continent.country.city.geoname_id'` | | `SELECT.CITY_LATITUDE` | `'continent.country.city.latitude'` | | `SELECT.CITY_LONGITUDE` | `'continent.country.city.longitude'` | | `SELECT.CITY_ACCURACY_RADIUS` | `'continent.country.city.accuracy_radius'` | | `SELECT.CITY_METRO_CODE` | `'continent.country.city.metro_code'` | | `SELECT.CITY_POSTAL_CODE` | `'continent.country.city.postal_code'` | | `SELECT.TIMEZONE_NAME` | `'continent.country.city.timezone.name'` | | `SELECT.TIMEZONE_TIME_NOW` | `'continent.country.city.timezone.time_now'` | | `SELECT.FLAG_IMG` | `'continent.country.flag.img'` | | `SELECT.FLAG_EMOJI` | `'continent.country.flag.emoji'` | | `SELECT.FLAG_EMOJI_UNICODE` | `'continent.country.flag.emoji_unicode'` | | `SELECT.CURRENCY_NAME` | `'continent.country.currency.name'` | | `SELECT.CURRENCY_CODE` | `'continent.country.currency.code'` | | `SELECT.CURRENCY_SYMBOL` | `'continent.country.currency.symbol'` | | `SELECT.REGISTERED_COUNTRY_NAME` | `'registered_country.name'` | | `SELECT.REGISTERED_COUNTRY_CODE` | `'registered_country.code'` | | `SELECT.REGISTERED_COUNTRY_GEONAME_ID` | `'registered_country.geoname_id'` | | `SELECT.ASN_NUMBER` | `'asn.number'` | | `SELECT.ASN_NAME` | `'asn.name'` | | `SELECT.COMPLETION_TIME_MILISECONDS` | `'completion_time.miliseconds'` | | `SELECT.COMPLETION_TIME_SECONDS` | `'completion_time.seconds'` | The full list of Ip2Geo.select constant you can use when retrieving data: | Constant | Value | | ----------------------------------------------- | -------------------------------------------- | | `Ip2Geo.select[:IP]` | `'ip'` | | `Ip2Geo.select[:TYPE]` | `'type'` | | `Ip2Geo.select[:IS_EU]` | `'is_eu'` | | `Ip2Geo.select[:CONTINENT_NAME]` | `'continent.name'` | | `Ip2Geo.select[:CONTINENT_CODE]` | `'continent.code'` | | `Ip2Geo.select[:CONTINENT_GEONAME_ID]` | `'continent.geoname_id'` | | `Ip2Geo.select[:COUNTRY_NAME]` | `'continent.country.name'` | | `Ip2Geo.select[:COUNTRY_CODE]` | `'continent.country.code'` | | `Ip2Geo.select[:COUNTRY_GEONAME_ID]` | `'continent.country.geoname_id'` | | `Ip2Geo.select[:COUNTRY_PHONE_CODE]` | `'continent.country.phone_code'` | | `Ip2Geo.select[:COUNTRY_CAPITAL]` | `'continent.country.capital'` | | `Ip2Geo.select[:COUNTRY_TLD]` | `'continent.country.tld'` | | `Ip2Geo.select[:SUBDIVISION_NAME]` | `'continent.country.subdivision.name'` | | `Ip2Geo.select[:SUBDIVISION_CODE]` | `'continent.country.subdivision.code'` | | `Ip2Geo.select[:CITY_NAME]` | `'continent.country.city.name'` | | `Ip2Geo.select[:CITY_GEONAME_ID]` | `'continent.country.city.geoname_id'` | | `Ip2Geo.select[:CITY_LATITUDE]` | `'continent.country.city.latitude'` | | `Ip2Geo.select[:CITY_LONGITUDE]` | `'continent.country.city.longitude'` | | `Ip2Geo.select[:CITY_ACCURACY_RADIUS]` | `'continent.country.city.accuracy_radius'` | | `Ip2Geo.select[:CITY_METRO_CODE]` | `'continent.country.city.metro_code'` | | `Ip2Geo.select[:CITY_POSTAL_CODE]` | `'continent.country.city.postal_code'` | | `Ip2Geo.select[:TIMEZONE_NAME]` | `'continent.country.city.timezone.name'` | | `Ip2Geo.select[:TIMEZONE_TIME_NOW]` | `'continent.country.city.timezone.time_now'` | | `Ip2Geo.select[:FLAG_IMG]` | `'continent.country.flag.img'` | | `Ip2Geo.select[:FLAG_EMOJI]` | `'continent.country.flag.emoji'` | | `Ip2Geo.select[:FLAG_EMOJI_UNICODE]` | `'continent.country.flag.emoji_unicode'` | | `Ip2Geo.select[:CURRENCY_NAME]` | `'continent.country.currency.name'` | | `Ip2Geo.select[:CURRENCY_CODE]` | `'continent.country.currency.code'` | | `Ip2Geo.select[:CURRENCY_SYMBOL]` | `'continent.country.currency.symbol'` | | `Ip2Geo.select[:REGISTERED_COUNTRY_NAME]` | `'registered_country.name'` | | `Ip2Geo.select[:REGISTERED_COUNTRY_CODE]` | `'registered_country.code'` | | `Ip2Geo.select[:REGISTERED_COUNTRY_GEONAME_ID]` | `'registered_country.geoname_id'` | | `Ip2Geo.select[:ASN_NUMBER]` | `'asn.number'` | | `Ip2Geo.select[:ASN_NAME]` | `'asn.name'` | | `Ip2Geo.select[:COMPLETION_TIME_MILISECONDS]` | `'completion_time.miliseconds'` | | `Ip2Geo.select[:COMPLETION_TIME_SECONDS]` | `'completion_time.seconds'` | The full list of ip2geo.SELECT constant you can use when retrieving data: | Constant | Value | | ------------------------------------------------ | -------------------------------------------- | | `ip2geo.SELECT['IP']` | `'ip'` | | `ip2geo.SELECT['TYPE']` | `'type'` | | `ip2geo.SELECT['IS_EU']` | `'is_eu'` | | `ip2geo.SELECT['CONTINENT_NAME']` | `'continent.name'` | | `ip2geo.SELECT['CONTINENT_CODE']` | `'continent.code'` | | `ip2geo.SELECT['CONTINENT_GEONAME_ID']` | `'continent.geoname_id'` | | `ip2geo.SELECT['COUNTRY_NAME']` | `'continent.country.name'` | | `ip2geo.SELECT['COUNTRY_CODE']` | `'continent.country.code'` | | `ip2geo.SELECT['COUNTRY_GEONAME_ID']` | `'continent.country.geoname_id'` | | `ip2geo.SELECT['COUNTRY_PHONE_CODE']` | `'continent.country.phone_code'` | | `ip2geo.SELECT['COUNTRY_CAPITAL']` | `'continent.country.capital'` | | `ip2geo.SELECT['COUNTRY_TLD']` | `'continent.country.tld'` | | `ip2geo.SELECT['SUBDIVISION_NAME']` | `'continent.country.subdivision.name'` | | `ip2geo.SELECT['SUBDIVISION_CODE']` | `'continent.country.subdivision.code'` | | `ip2geo.SELECT['CITY_NAME']` | `'continent.country.city.name'` | | `ip2geo.SELECT['CITY_GEONAME_ID']` | `'continent.country.city.geoname_id'` | | `ip2geo.SELECT['CITY_LATITUDE']` | `'continent.country.city.latitude'` | | `ip2geo.SELECT['CITY_LONGITUDE']` | `'continent.country.city.longitude'` | | `ip2geo.SELECT['CITY_ACCURACY_RADIUS']` | `'continent.country.city.accuracy_radius'` | | `ip2geo.SELECT['CITY_METRO_CODE']` | `'continent.country.city.metro_code'` | | `ip2geo.SELECT['CITY_POSTAL_CODE']` | `'continent.country.city.postal_code'` | | `ip2geo.SELECT['TIMEZONE_NAME']` | `'continent.country.city.timezone.name'` | | `ip2geo.SELECT['TIMEZONE_TIME_NOW']` | `'continent.country.city.timezone.time_now'` | | `ip2geo.SELECT['FLAG_IMG']` | `'continent.country.flag.img'` | | `ip2geo.SELECT['FLAG_EMOJI']` | `'continent.country.flag.emoji'` | | `ip2geo.SELECT['FLAG_EMOJI_UNICODE']` | `'continent.country.flag.emoji_unicode'` | | `ip2geo.SELECT['CURRENCY_NAME']` | `'continent.country.currency.name'` | | `ip2geo.SELECT['CURRENCY_CODE']` | `'continent.country.currency.code'` | | `ip2geo.SELECT['CURRENCY_SYMBOL']` | `'continent.country.currency.symbol'` | | `ip2geo.SELECT['REGISTERED_COUNTRY_NAME']` | `'registered_country.name'` | | `ip2geo.SELECT['REGISTERED_COUNTRY_CODE']` | `'registered_country.code'` | | `ip2geo.SELECT['REGISTERED_COUNTRY_GEONAME_ID']` | `'registered_country.geoname_id'` | | `ip2geo.SELECT['ASN_NUMBER']` | `'asn.number'` | | `ip2geo.SELECT['ASN_NAME']` | `'asn.name'` | | `ip2geo.SELECT['COMPLETION_TIME_MILISECONDS']` | `'completion_time.miliseconds'` | | `ip2geo.SELECT['COMPLETION_TIME_SECONDS']` | `'completion_time.seconds'` | The full list of Ip2Geo::SELECT constant you can use when retrieving data: | Constant | Value | | ------------------------------------------------- | -------------------------------------------- | | `Ip2Geo::SELECT['IP']` | `'ip'` | | `Ip2Geo::SELECT['TYPE']` | `'type'` | | `Ip2Geo::SELECT['IS_EU']` | `'is_eu'` | | `Ip2Geo::SELECT['CONTINENT_NAME']` | `'continent.name'` | | `Ip2Geo::SELECT['CONTINENT_CODE']` | `'continent.code'` | | `Ip2Geo::SELECT['CONTINENT_GEONAME_ID']` | `'continent.geoname_id'` | | `Ip2Geo::SELECT['COUNTRY_NAME']` | `'continent.country.name'` | | `Ip2Geo::SELECT['COUNTRY_CODE']` | `'continent.country.code'` | | `Ip2Geo::SELECT['COUNTRY_GEONAME_ID']` | `'continent.country.geoname_id'` | | `Ip2Geo::SELECT['COUNTRY_PHONE_CODE']` | `'continent.country.phone_code'` | | `Ip2Geo::SELECT['COUNTRY_CAPITAL']` | `'continent.country.capital'` | | `Ip2Geo::SELECT['COUNTRY_TLD']` | `'continent.country.tld'` | | `Ip2Geo::SELECT['SUBDIVISION_NAME']` | `'continent.country.subdivision.name'` | | `Ip2Geo::SELECT['SUBDIVISION_CODE']` | `'continent.country.subdivision.code'` | | `Ip2Geo::SELECT['CITY_NAME']` | `'continent.country.city.name'` | | `Ip2Geo::SELECT['CITY_GEONAME_ID']` | `'continent.country.city.geoname_id'` | | `Ip2Geo::SELECT['CITY_LATITUDE']` | `'continent.country.city.latitude'` | | `Ip2Geo::SELECT['CITY_LONGITUDE']` | `'continent.country.city.longitude'` | | `Ip2Geo::SELECT['CITY_ACCURACY_RADIUS']` | `'continent.country.city.accuracy_radius'` | | `Ip2Geo::SELECT['CITY_METRO_CODE']` | `'continent.country.city.metro_code'` | | `Ip2Geo::SELECT['CITY_POSTAL_CODE']` | `'continent.country.city.postal_code'` | | `Ip2Geo::SELECT['TIMEZONE_NAME']` | `'continent.country.city.timezone.name'` | | `Ip2Geo::SELECT['TIMEZONE_TIME_NOW']` | `'continent.country.city.timezone.time_now'` | | `Ip2Geo::SELECT['FLAG_IMG']` | `'continent.country.flag.img'` | | `Ip2Geo::SELECT['FLAG_EMOJI']` | `'continent.country.flag.emoji'` | | `Ip2Geo::SELECT['FLAG_EMOJI_UNICODE']` | `'continent.country.flag.emoji_unicode'` | | `Ip2Geo::SELECT['CURRENCY_NAME']` | `'continent.country.currency.name'` | | `Ip2Geo::SELECT['CURRENCY_CODE']` | `'continent.country.currency.code'` | | `Ip2Geo::SELECT['CURRENCY_SYMBOL']` | `'continent.country.currency.symbol'` | | `Ip2Geo::SELECT['REGISTERED_COUNTRY_NAME']` | `'registered_country.name'` | | `Ip2Geo::SELECT['REGISTERED_COUNTRY_CODE']` | `'registered_country.code'` | | `Ip2Geo::SELECT['REGISTERED_COUNTRY_GEONAME_ID']` | `'registered_country.geoname_id'` | | `Ip2Geo::SELECT['ASN_NUMBER']` | `'asn.number'` | | `Ip2Geo::SELECT['ASN_NAME']` | `'asn.name'` | | `Ip2Geo::SELECT['COMPLETION_TIME_MILISECONDS']` | `'completion_time.miliseconds'` | | `Ip2Geo::SELECT['COMPLETION_TIME_SECONDS']` | `'completion_time.seconds'` | ### Raw Values In case you are using the API instead of our SDKs to call it, here are the raw constants you can use for reference. ```typescript TypeScript theme={null} const SELECT = { IP: 'ip', TYPE: 'type', IS_EU: 'is_eu', CONTINENT_NAME: 'continent.name', CONTINENT_CODE: 'continent.code', CONTINENT_GEONAME_ID: 'continent.geoname_id', COUNTRY_NAME: 'continent.country.name', COUNTRY_CODE: 'continent.country.code', COUNTRY_GEONAME_ID: 'continent.country.geoname_id', COUNTRY_PHONE_CODE: 'continent.country.phone_code', COUNTRY_CAPITAL: 'continent.country.capital', COUNTRY_TLD: 'continent.country.tld', SUBDIVISION_NAME: 'continent.country.subdivision.name', SUBDIVISION_CODE: 'continent.country.subdivision.code', CITY_NAME: 'continent.country.city.name', CITY_GEONAME_ID: 'continent.country.city.geoname_id', CITY_LATITUDE: 'continent.country.city.latitude', CITY_LONGITUDE: 'continent.country.city.longitude', CITY_ACCURACY_RADIUS: 'continent.country.city.accuracy_radius', CITY_METRO_CODE: 'continent.country.city.metro_code', CITY_POSTAL_CODE: 'continent.country.city.postal_code', TIMEZONE_NAME: 'continent.country.city.timezone.name', TIMEZONE_TIME_NOW: 'continent.country.city.timezone.time_now', FLAG_IMG: 'continent.country.flag.img', FLAG_EMOJI: 'continent.country.flag.emoji', FLAG_EMOJI_UNICODE: 'continent.country.flag.emoji_unicode', CURRENCY_NAME: 'continent.country.currency.name', CURRENCY_CODE: 'continent.country.currency.code', CURRENCY_SYMBOL: 'continent.country.currency.symbol', REGISTERED_COUNTRY_NAME: 'registered_country.name', REGISTERED_COUNTRY_CODE: 'registered_country.code', REGISTERED_COUNTRY_GEONAME_ID: 'registered_country.geoname_id', ASN_NUMBER: 'asn.number', ASN_NAME: 'asn.name', COMPLETION_TIME_MILISECONDS: 'completion_time.miliseconds', COMPLETION_TIME_SECONDS: 'completion_time.seconds' } ``` ```ruby Ruby theme={null} SELECT = { IP: 'ip', TYPE: 'type', IS_EU: 'is_eu', CONTINENT_NAME: 'continent.name', CONTINENT_CODE: 'continent.code', CONTINENT_GEONAME_ID: 'continent.geoname_id', COUNTRY_NAME: 'continent.country.name', COUNTRY_CODE: 'continent.country.code', COUNTRY_GEONAME_ID: 'continent.country.geoname_id', COUNTRY_PHONE_CODE: 'continent.country.phone_code', COUNTRY_CAPITAL: 'continent.country.capital', COUNTRY_TLD: 'continent.country.tld', SUBDIVISION_NAME: 'continent.country.subdivision.name', SUBDIVISION_CODE: 'continent.country.subdivision.code', CITY_NAME: 'continent.country.city.name', CITY_GEONAME_ID: 'continent.country.city.geoname_id', CITY_LATITUDE: 'continent.country.city.latitude', CITY_LONGITUDE: 'continent.country.city.longitude', CITY_ACCURACY_RADIUS: 'continent.country.city.accuracy_radius', CITY_METRO_CODE: 'continent.country.city.metro_code', CITY_POSTAL_CODE: 'continent.country.city.postal_code', TIMEZONE_NAME: 'continent.country.city.timezone.name', TIMEZONE_TIME_NOW: 'continent.country.city.timezone.time_now', FLAG_IMG: 'continent.country.flag.img', FLAG_EMOJI: 'continent.country.flag.emoji', FLAG_EMOJI_UNICODE: 'continent.country.flag.emoji_unicode', CURRENCY_NAME: 'continent.country.currency.name', CURRENCY_CODE: 'continent.country.currency.code', CURRENCY_SYMBOL: 'continent.country.currency.symbol', REGISTERED_COUNTRY_NAME: 'registered_country.name', REGISTERED_COUNTRY_CODE: 'registered_country.code', REGISTERED_COUNTRY_GEONAME_ID: 'registered_country.geoname_id', ASN_NUMBER: 'asn.number', ASN_NAME: 'asn.name', COMPLETION_TIME_MILISECONDS: 'completion_time.miliseconds', COMPLETION_TIME_SECONDS: 'completion_time.seconds' } ``` # External Apps Source: https://docs.ip2geo.dev/external-apps Explore Ip2Geo integrations, GPTs, and third-party connections. IP to Geolocation via ChatGPT. Have you built something with Ip2Geo? Let us know and we'll feature it here. # Getting Started Source: https://docs.ip2geo.dev/getting-started A quick introduction to getting started with the Ip2Geo platform for converting IP's to geolocation data from a technical perspective. ## Introduction To convert IPs to geolocation data, you will need to have an account and a project set up. By default, every account comes with a default project. Then, create a secret key for server-side usage or add a website for client-side usage — and you're ready to start converting. ## What's next? See below for some helpful links to get you started. Learn about secret and public keys. Register domains for client-side usage. Read more about rate limiting. Getting started with our SDK. Getting started with our API. Learn about our data Interfaces. Explore available constants. GPTs, connectors, and integrations. # Conversion Interface Source: https://docs.ip2geo.dev/interfaces/conversion When you retrieve conversions using the SDK or API, the conversion data is returned as a structured object. ```typescript theme={null} interface Conversion { id: number uniqueId: string data: Ip status: string startedAt: string completedAt: string | null createdAt: string } ``` # Ip Interface Source: https://docs.ip2geo.dev/interfaces/ip When you interact with our SDK or API, the geolocation data for an IP address is returned as a structured object containing details like country, region, city, coordinates, and similar information. ```typescript theme={null} interface Ip { ip: string | null type: 'ipv4' | 'ipv6' | null is_eu: boolean | null continent: { name: string | null code: string | null geoname_id: number | null country: { name: string | null code: string | null geoname_id: number | null phone_code: string | null capital: string | null tld: string | null subdivision: { name: string | null code: string | null } city: { name: string | null geoname_id: number | null latitude: number | null longitude: number | null accuracy_radius: number | null metro_code: number | null postal_code: string | null timezone: { name: string | null time_now: string | null } } flag: { img: string | null emoji: string | null emoji_unicode: string | null } currency: { name: string | null code: string | null symbol: string | null } } } registered_country: { name: string | null code: string | null geoname_id: number | null } asn: { number: number | null name: string | null } completion_time: { miliseconds: number | null seconds: number | null } } ``` # Rate Limiting Source: https://docs.ip2geo.dev/rate-limiting Currently, we don't enforce strict rate limits on our API or SDK usage. If you can handle the traffic, we won't stand in your way. Our infrastructure is built to process millions of requests efficiently, ensuring reliability, performance, and availability for all users worldwide. While we don't impose hard rate limits, we continuously monitor usage patterns to maintain fair access. If we detect unusual activity that could affect service quality, we may reach out to discuss appropriate usage. # Bulk Convert IP's Source: https://docs.ip2geo.dev/sdk/bulk-convert-ips This function allows you to convert multiple IP addresses in a single request, making it efficient for batch processing. You can provide an array of IP addresses, and the function will return their corresponding geolocation data. You should authenticate/initialize Ip2Geo before using this method. ```typescript TypeScript theme={null} import { ConvertIPs } from '@ip2geo/sdk' const ipAddresses = [ '8.8.8.8', '8.8.4.4', '1.1.1.1', '9.9.9.9', '4.4.4.4', '3.3.3.3' ] const { data, success, message } = await ConvertIPs({ ips: ipAddresses }) ``` ```ruby Ruby theme={null} ip_addresses = [ '8.8.8.8', '8.8.4.4', '1.1.1.1', '9.9.9.9', '4.4.4.4', '3.3.3.3' ] result = Ip2Geo.convert_ips(ips: ip_addresses) # { # 'success' => true, # 'code' => 200, # 'message' => 'Success', # 'data' => [ # { 'ip' => '8.8.8.8', 'conversion' => { ... } }, # { 'ip' => '8.8.4.4', 'conversion' => { ... } }, # ... # ], # '_req' => { 'reqId' => '...', 'resTime' => 123 } # } ``` ```python Python theme={null} import ip2geo ip_addresses = [ '8.8.8.8', '8.8.4.4', '1.1.1.1', '9.9.9.9', '4.4.4.4', '3.3.3.3', ] result = ip2geo.convert_ips(ips=ip_addresses) # { # 'success': True, # 'code': 200, # 'message': 'Success', # 'data': [ # { 'ip': '8.8.8.8', 'conversion': { ... } }, # { 'ip': '8.8.4.4', 'conversion': { ... } }, # ... # ], # '_req': { 'reqId': '...', 'resTime': 123 } # } ``` ```php PHP theme={null} true, // 'code' => 200, // 'message' => 'Success', // 'data' => [ // ['ip' => '8.8.8.8', 'conversion' => [ ... ]], // ['ip' => '8.8.4.4', 'conversion' => [ ... ]], // ... // ], // '_req' => ['reqId' => '...', 'resTime' => 123], // ] ``` ### Parameters An array of IPv4 or IPv6 addresses to convert. Maximum 5000 IPs per request. ### Response Whether the request was successful. Response message describing the result. HTTP status code. An array of conversion results. Each item contains: * ip: The IP address that was converted. * conversion: The geolocation data for the IP (see Ip Interface). Returns null if the conversion failed for that IP Response Interface. Request metadata containing: * reqId: Unique request identifier. * resTime: Response time in milliseconds. ### Parameters An array of IPv4 or IPv6 addresses to convert. Maximum 5000 IPs per request. ### Response Whether the request was successful. Response message describing the result. HTTP status code. An array of conversion results. Each item contains: * 'ip': The IP address that was converted. * 'conversion': The geolocation data for the IP (see Ip Interface). Returns nil if the conversion failed for that IP Response Interface. Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters A list of IPv4 or IPv6 addresses to convert. Maximum 5000 IPs per request. ### Response Whether the request was successful. Response message describing the result. HTTP status code. A list of conversion results. Each item contains: * 'ip': The IP address that was converted. * 'conversion': The geolocation data for the IP (see Ip Interface). Returns None if the conversion failed for that IP Response Interface. Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters An array of IPv4 or IPv6 addresses to convert. Maximum 5000 IPs per request. ### Response Whether the request was successful. Response message describing the result. HTTP status code. An array of conversion results. Each item contains: * 'ip': The IP address that was converted. * 'conversion': The geolocation data for the IP (see Ip Interface). Returns null if the conversion failed for that IP Response Interface. Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. # Changelogs Source: https://docs.ip2geo.dev/sdk/changelogs This page documents version history and updates for our SDKs. We strongly recommend keeping your SDK up to date to benefit from the latest features, security patches, and performance improvements. * Client-side support — use the SDK directly in the browser with public keys (i2g\_pk\_...) tied to your domains * Built-in smart caching layer for successful conversions with stale-while-revalidate (SWR) pattern, LRU eviction, and configurable cache, cacheMaxSize, cacheTTL options on Init * IpValidation helper function to validate IP addresses * GetConversion to retrieve a single conversion by ID * GetConversions to retrieve multiple conversions by IDs * ListConversions with pagination and IP search filtering * New SELECT constants: geoname\_id, subdivision, accuracy\_radius, metro\_code, registered\_country * General improvements and fixes from the previous version * Initial release and base functionality * Init function for SDK configuration * ConvertIP method for single IP address conversion * ConvertIPs method for bulk IP address conversion * Full TypeScript support with type definitions * Built-in client & server side safety and update notifications * Built-in smart caching layer for successful conversions with stale-while-revalidate (SWR) pattern, LRU eviction, and configurable cache, cache\_max\_size, cache\_ttl options on init * Initial public release * init method for SDK configuration * convert\_ip method for single IP address conversion * convert\_ips method for bulk IP address conversion * get\_conversion retrieve a single conversion by ID * get\_conversions method to retrieve multiple conversions by IDs * list\_conversions method with pagination and IP search filtering * ip\_validation helper function to validate IP addresses * SELECT constants for field selection including geoname\_id, subdivision, accuracy\_radius, metro\_code, registered\_country * Version update notifications * Initial public release * init function for SDK configuration * convert\_ip function for single IP address conversion * convert\_ips function for bulk IP address conversion * get\_conversion function to retrieve a single conversion by ID * get\_conversions function to retrieve multiple conversions by IDs * list\_conversions function with pagination and IP search filtering * ip\_validation helper function to validate IP addresses * SELECT constants for field selection including geoname\_id, subdivision, accuracy\_radius, metro\_code, registered\_country * Built-in smart caching layer for successful conversions with stale-while-revalidate (SWR) pattern, LRU eviction, and configurable cache, cache\_max\_size, cache\_ttl options on init * Version update notifications * Initial public release * init method for SDK configuration * convertIp for single IP address conversion * convertIps for bulk IP address conversion * getConversion to retrieve a single conversion by ID * getConversions to retrieve multiple conversions by IDs * listConversions method with pagination and IP search filtering * ipValidation helper function to validate IP addresses * SELECT constants for field selection including geoname\_id, subdivision, accuracy\_radius, metro\_code, registered\_country * Built-in smart caching layer for successful conversions with stale-while-revalidate (SWR) pattern, LRU eviction, and configurable cache, cache\_max\_size, cache\_ttl options on init * Version update notifications # Convert IP Source: https://docs.ip2geo.dev/sdk/convert-ip This function allows you to convert a single IP address into its corresponding geolocation data using, see an example below: You should authenticate/initialize Ip2Geo before using this method. ```typescript TypeScript theme={null} import { ConvertIP } from '@ip2geo/sdk' const ipAddress = '8.8.8.8' const { data, success, message } = await ConvertIP({ ip: ipAddress }) ``` ```ruby Ruby theme={null} converted = Ip2Geo.convert_ip(ip: '8.8.8.8') # { # 'success' => true, # 'code' => 200, # 'message' => 'Success', # 'data' => { ... }, # '_req' => { 'reqId' => '...', 'resTime' => 123 } # } ``` ```python Python theme={null} import ip2geo result = ip2geo.convert_ip(ip='8.8.8.8') # { # 'success': True, # 'code': 200, # 'message': 'Success', # 'data': { ... }, # '_req': { 'reqId': '...', 'resTime': 123 } # } ``` ```php PHP theme={null} true, // 'code' => 200, // 'message' => 'Success', // 'data' => [ ... ], // '_req' => ['reqId' => '...', 'resTime' => 123], // ] ``` ### Parameters The IPv4 or IPv6 address to convert. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The geolocation data for the IP address. See Ip Interface for details. Returns null if the conversion failed, read more about IP Response Interface. Request metadata containing: * reqId: Unique request identifier. * resTime: Response time in milliseconds. ### Parameters The IPv4 or IPv6 address to convert. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The geolocation data for the IP address. See Ip Interface for details. Returns nil if the conversion failed, read more about IP Response Interface. Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters The IPv4 or IPv6 address to convert. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The geolocation data for the IP address. See Ip Interface for details. Returns None if the conversion failed, read more about IP Response Interface. Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters The IPv4 or IPv6 address to convert. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The geolocation data for the IP address. See Ip Interface for details. Returns null if the conversion failed, read more about IP Response Interface. Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. # Get Conversion Source: https://docs.ip2geo.dev/sdk/get-conversion This function allows you to retrieve a single conversion by its unique identifier, see an example below: You should authenticate/initialize Ip2Geo before using this method. ```typescript TypeScript theme={null} import { GetConversion } from '@ip2geo/sdk' const conversionId = 'your-conversion-uuid' const { data, success, message } = await GetConversion({ conversionId: conversionId }) ``` ```ruby Ruby theme={null} result = Ip2Geo.get_conversion(conversion_id: 'your-conversion-uuid') # { # 'success' => true, # 'code' => 200, # 'message' => 'Success', # 'data' => { ... }, # '_req' => { 'reqId' => '...', 'resTime' => 123 } # } ``` ```python Python theme={null} import ip2geo result = ip2geo.get_conversion(conversion_id='your-conversion-uuid') # { # 'success': True, # 'code': 200, # 'message': 'Success', # 'data': { ... }, # '_req': { 'reqId': '...', 'resTime': 123 } # } ``` ```php PHP theme={null} true, // 'code' => 200, // 'message' => 'Success', // 'data' => [ ... ], // '_req' => ['reqId' => '...', 'resTime' => 123], // ] ``` ### With Select Fields You can select specific fields from the conversion data object using the select parameter: ```typescript TypeScript theme={null} import { GetConversion, SELECT } from '@ip2geo/sdk' const { data, success, message } = await GetConversion({ conversionId: 'your-conversion-uuid', select: [ SELECT.COUNTRY_NAME, SELECT.COUNTRY_CODE, SELECT.ASN_NAME ] }) // Response data structure: // { // data: { // continent: { // country: { // name: 'United States', // code: 'US' // } // }, // asn: { // name: 'Cloudflare' // } // } // } ``` ```ruby Ruby theme={null} result = Ip2Geo.get_conversion( conversion_id: 'your-conversion-uuid', select: [ Ip2Geo.select[:COUNTRY_NAME], Ip2Geo.select[:COUNTRY_CODE], Ip2Geo.select[:ASN_NAME] ] ) # Response data structure: # { # 'data' => { # 'continent' => { # 'country' => { # 'name' => 'United States', # 'code' => 'US' # } # }, # 'asn' => { # 'name' => 'Cloudflare' # } # } # } ``` ```python Python theme={null} import ip2geo result = ip2geo.get_conversion( conversion_id='your-conversion-uuid', select=[ ip2geo.SELECT['COUNTRY_NAME'], ip2geo.SELECT['COUNTRY_CODE'], ip2geo.SELECT['ASN_NAME'], ] ) # Response data structure: # { # 'data': { # 'continent': { # 'country': { # 'name': 'United States', # 'code': 'US' # } # }, # 'asn': { # 'name': 'Cloudflare' # } # } # } ``` ```php PHP theme={null} [ // 'continent' => [ // 'country' => [ // 'name' => 'United States', // 'code' => 'US', // ], // ], // 'asn' => [ // 'name' => 'Cloudflare', // ], // ], // ] ``` ### Parameters The unique identifier (UUID) of the conversion to retrieve. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The conversion data. If select was specified, only the selected fields are returned. Returns null if the conversion was not found. Request metadata containing: * reqId: Unique request identifier. * resTime: Response time in milliseconds. ### Parameters The unique identifier (UUID) of the conversion to retrieve. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The conversion data. If select was specified, only the selected data fields are returned. Returns nil if the conversion was not found. Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters The unique identifier (UUID) of the conversion to retrieve. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The conversion data. If select was specified, only the selected data fields are returned. Returns None if the conversion was not found. Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters The unique identifier (UUID) of the conversion to retrieve. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The conversion data. If select was specified, only the selected data fields are returned. Returns null if the conversion was not found. Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. For all available SELECT constants and their values, see the SELECT Constants reference. # Get Conversions Source: https://docs.ip2geo.dev/sdk/get-conversions This function allows you to retrieve multiple conversions by their unique identifiers in a single request, see an example below: You should authenticate/initialize Ip2Geo before using this method. ```typescript TypeScript theme={null} import { GetConversions } from '@ip2geo/sdk' const conversionIds = ['uuid-1', 'uuid-2', 'uuid-3'] const { data, success, message } = await GetConversions({ conversionIds: conversionIds }) // Access the conversions console.log(data.conversions) // Array of conversion objects ``` ```ruby Ruby theme={null} result = Ip2Geo.get_conversions( conversion_ids: ['uuid-1', 'uuid-2', 'uuid-3'] ) # Access the conversions puts result['data']['conversions'] # Array of conversion objects # { # 'success' => true, # 'code' => 200, # 'message' => 'Success', # 'data' => { 'conversions' => [...] }, # '_req' => { 'reqId' => '...', 'resTime' => 123 } # } ``` ```python Python theme={null} import ip2geo result = ip2geo.get_conversions( conversion_ids=['uuid-1', 'uuid-2', 'uuid-3'] ) # Access the conversions print(result['data']['conversions']) # List of conversion objects # { # 'success': True, # 'code': 200, # 'message': 'Success', # 'data': { 'conversions': [...] }, # '_req': { 'reqId': '...', 'resTime': 123 } # } ``` ```php PHP theme={null} true, // 'code' => 200, // 'message' => 'Success', // 'data' => ['conversions' => [...]], // '_req' => ['reqId' => '...', 'resTime' => 123], // ] ``` ### With Select Fields You can select specific fields from the conversion data object using the select parameter: ```typescript TypeScript theme={null} import { GetConversions, SELECT } from '@ip2geo/sdk' const { data, success, message } = await GetConversions({ conversionIds: ['uuid-1', 'uuid-2'], select: [ SELECT.COUNTRY_NAME, SELECT.COUNTRY_CODE, SELECT.ASN_NAME ] }) // Response data structure: // { // conversions: [ // { // data: { // continent: { // country: { name: 'United States', code: 'US' } // }, // asn: { name: 'Cloudflare' } // } // }, // ... // ] // } ``` ```ruby Ruby theme={null} result = Ip2Geo.get_conversions( conversion_ids: ['uuid-1', 'uuid-2'], select: [ Ip2Geo.select[:COUNTRY_NAME], Ip2Geo.select[:COUNTRY_CODE], Ip2Geo.select[:ASN_NAME] ] ) # Response data structure: # { # 'conversions' => [ # { # 'data' => { # 'continent' => { # 'country' => { 'name' => 'United States', 'code' => 'US' } # }, # 'asn' => { 'name' => 'Cloudflare' } # } # }, # ... # ] # } ``` ```python Python theme={null} import ip2geo result = ip2geo.get_conversions( conversion_ids=['uuid-1', 'uuid-2'], select=[ ip2geo.SELECT['COUNTRY_NAME'], ip2geo.SELECT['COUNTRY_CODE'], ip2geo.SELECT['ASN_NAME'], ] ) # Response data structure: # { # 'conversions': [ # { # 'data': { # 'continent': { # 'country': { 'name': 'United States', 'code': 'US' } # }, # 'asn': { 'name': 'Cloudflare' } # } # }, # ... # ] # } ``` ```php PHP theme={null} [ // [ // 'data' => [ // 'continent' => [ // 'country' => ['name' => 'United States', 'code' => 'US'], // ], // 'asn' => ['name' => 'Cloudflare'], // ], // ], // ... // ], // ] ``` ### Parameters An array of unique identifiers (UUIDs) of the conversions to retrieve. Maximum 100 IDs per request. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The response data containing: * conversions: Array of conversion objects (or partial objects if select was used) Request metadata containing: * reqId: Unique request identifier. * resTime: Response time in milliseconds. ### Parameters An array of unique identifiers (UUIDs) of the conversions to retrieve. Maximum 100 IDs per request. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The response data containing: * 'conversions': Array of conversion hashes (or partial hashes if select was used) Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters A list of unique identifiers (UUIDs) of the conversions to retrieve. Maximum 100 IDs per request. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The response data containing: * 'conversions': List of conversion dicts (or partial dicts if select was used) Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters An array of unique identifiers (UUIDs) of the conversions to retrieve. Maximum 100 IDs per request. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The response data containing: * 'conversions': Array of conversion arrays (or partial arrays if select was used) Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. For all available SELECT constants and their values, see the SELECT Constants reference. ### Error Handling If any of the provided conversion IDs are invalid (not valid UUIDs), the request will fail and return the list of invalid IDs: ```typescript TypeScript theme={null} const { data, success, message } = await GetConversions({ conversionIds: ['valid-uuid', 'invalid-id', 'another-bad-id'] }) // Response: // { // success: false, // message: 'conversions.invalid-conversion-ids', // data: { invalidIds: ['invalid-id', 'another-bad-id'] } // } ``` ```ruby Ruby theme={null} result = Ip2Geo.get_conversions( conversion_ids: ['valid-uuid', 'invalid-id', 'another-bad-id'] ) # Response: # { # 'success' => false, # 'message' => 'conversions.invalid-conversion-ids', # 'data' => { 'invalidIds' => ['invalid-id', 'another-bad-id'] } # } ``` ```python Python theme={null} result = ip2geo.get_conversions( conversion_ids=['valid-uuid', 'invalid-id', 'another-bad-id'] ) # Response: # { # 'success': False, # 'message': 'conversions.invalid-conversion-ids', # 'data': { 'invalidIds': ['invalid-id', 'another-bad-id'] } # } ``` ```php PHP theme={null} false, // 'message' => 'conversions.invalid-conversion-ids', // 'data' => ['invalidIds' => ['invalid-id', 'another-bad-id']], // ] ``` # Init Source: https://docs.ip2geo.dev/sdk/init 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. ## 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. ```typescript TypeScript theme={null} import { Init } from '@ip2geo/sdk' await Init(process.env.IP2GEO_API_KEY) ``` ```ruby Ruby theme={null} require 'ip2geo' Ip2Geo.init(ENV['IP2GEO_API_KEY']) ``` ```python Python theme={null} import os import ip2geo ip2geo.init(os.environ['IP2GEO_API_KEY']) ``` ```php PHP theme={null} If you accidentally use a secret key (i2g\_sk\_...) in the browser, the SDK will show a **Client Runtime Detected** warning to let you know your key is exposed. Use a public key instead for client-side usage. ## 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. ```typescript theme={null} import { Init } from '@ip2geo/sdk' await Init(process.env.IP2GEO_PUBLIC_KEY) ``` The SDK automatically detects the 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 only work from the browser. Server-side environments (Node.js, Bun, Deno) do not send the Origin header by default, so public key requests from the server will be rejected. Use a secret key for server-side usage. 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. Once initialized, the SDK works the same way regardless of which key type you used. All methods like ConvertIP, ConvertIPs, GetConversion, and others work identically on both client and server — the only difference is how you authenticate. ## Options You can customize the initialization with optional parameters: ```typescript TypeScript theme={null} import { Init } from '@ip2geo/sdk' await Init(process.env.IP2GEO_API_KEY, { clientRuntimeMessage: false, versionUpdateMessage: false }) ``` ```ruby Ruby theme={null} require 'ip2geo' Ip2Geo.init(ENV['IP2GEO_API_KEY'], version_update_message: false) ``` ```python Python theme={null} import os import ip2geo ip2geo.init(os.environ['IP2GEO_API_KEY'], version_update_message=False) ``` ```php PHP theme={null} false, ]); ``` ## 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 is not affected by caching in any way. You can customize or disable caching through the init options: ```typescript TypeScript theme={null} import { Init } from '@ip2geo/sdk' await Init(process.env.IP2GEO_API_KEY, { cacheMaxSize: 500, cacheTTL: 60000 }) ``` ```ruby Ruby theme={null} require 'ip2geo' Ip2Geo.init(ENV['IP2GEO_API_KEY'], cache_max_size: 500, cache_ttl: 60 ) ``` ```python Python theme={null} import os import ip2geo ip2geo.init(os.environ['IP2GEO_API_KEY'], cache_max_size=500, cache_ttl=60 ) ``` ```php PHP theme={null} 500, 'cache_ttl' => 60, ]); ``` To disable caching entirely, set cache to false. When disabled, every conversion will make a fresh API request. ### 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). ### Parameters The secret key used to authenticate with the Ip2Geo service. 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 seconds. After this duration, cached entries expire and the next request will wait for a fresh response. Must be between 30 (30 seconds) and 86400 (1 day). Defaults to 300 (5 minutes). Ruby does not have client\_runtime\_message option since Ruby only runs server-side. ### Parameters The secret key used to authenticate with the Ip2Geo service. 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 seconds. After this duration, cached entries expire and the next request will wait for a fresh response. Must be between 30 (30 seconds) and 86400 (1 day). Defaults to 300 (5 minutes). Python does not have client\_runtime\_message option since Python only runs server-side. ### Parameters The secret key used to authenticate with the Ip2Geo service. 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 seconds. After this duration, cached entries expire and the next request will wait for a fresh response. Must be between 30 (30 seconds) and 86400 (1 day). Defaults to 300 (5 minutes). PHP does not have client\_runtime\_message option since PHP only runs server-side. # Introduction Source: https://docs.ip2geo.dev/sdk/introduction Our SDKs provide a type-safe way to use our conversion services directly through installable packages. In essence, they're lightweight wrappers around our REST API — but with type safety, auto-completion, and an enhanced developer experience (DX). ## Available SDKs We offer official SDKs for the following languages: | Language | Package | | --------------------- | --------------------------------------------------------------- | | TypeScript/JavaScript | [@ip2geo/sdk](https://npmjs.com/package/@ip2geo/sdk) | | Ruby | [ip2geo](https://rubygems.org/gems/ip2geo) | | Python | [ip2geo-sdk](https://pypi.org/project/ip2geo-sdk/) | | PHP | [ip2geo-dev/sdk](https://packagist.org/packages/ip2geo-dev/sdk) | ## Why Use the SDK Instead of the REST API? * **Type Safety:** Get full TypeScript/Ruby/Python support to catch issues early and reduce runtime errors. * **Simplified Integration:** Includes pre-built functions for requests, authentication, and response handling — no need to manually set up HTTP calls. * **Faster Development:** Focus on your app's logic while the SDK handles the boilerplate. * **Better Documentation:** Clear examples and typings make it easy to discover and use available methods. * **Automatic Updates:** The SDKs stay in sync with the API, giving you access to the latest endpoints and improvements. The only reason not to use the SDK is if your environment doesn't support npm, RubyGems, or PyPI, or if your use case requires direct REST API calls. ## Installation The TypeScript SDK works with all major JavaScript runtimes that support npm, including Node.js, Deno, Bun, and the browser (with public keys). ```bash theme={null} npm install @ip2geo/sdk@latest ``` ```bash theme={null} bun add @ip2geo/sdk@latest ``` ```bash theme={null} deno install @ip2geo/sdk@latest ``` ```bash theme={null} yarn add @ip2geo/sdk@latest ``` ```bash theme={null} pnpm add @ip2geo/sdk@latest ``` The Ruby SDK works with Ruby 2.7 and above. Install via Bundler or directly with gem. Add to your Gemfile: ```ruby theme={null} gem 'ip2geo' ``` Then run: ```bash theme={null} bundle install ``` ```bash theme={null} gem install ip2geo ``` The Python SDK works with Python 3.8 and above. Install via pip. ```bash theme={null} pip install ip2geo-sdk ``` Add to your requirements.txt: ``` ip2geo-sdk ``` Then run: ```bash theme={null} pip install -r requirements.txt ``` The PHP SDK works with PHP 8.0 and above. Install via Composer. ```bash theme={null} composer require ip2geo-dev/sdk ``` # Ip Validation Source: https://docs.ip2geo.dev/sdk/ip-validation This function allows you to validate an IP address and check if it is valid and supported by our conversion services. ```typescript TypeScript theme={null} import { IpValidation } from '@ip2geo/sdk' const ipAddress = '8.8.8.8' const { ip4, ip6 } = await IpValidation(ipAddress) ``` ```ruby Ruby theme={null} result = Ip2Geo.ip_validation('8.8.8.8') # { ip4: true, ip6: false } ``` ```python Python theme={null} import ip2geo result = ip2geo.ip_validation('8.8.8.8') # { 'ip4': True, 'ip6': False } ``` ```php PHP theme={null} true, 'ip6' => false] ``` ### Parameters The IPv4 or IPv6 address to validate. ### Response An object containing validation results: * ip4: boolean - Whether the IP address is a valid IPv4 address. * ip6: boolean - Whether the IP address is a valid IPv6 address. ### Parameters The IPv4 or IPv6 address to validate. ### Response A hash containing validation results: * :ip4: Boolean - Whether the IP address is a valid IPv4 address. * :ip6: Boolean - Whether the IP address is a valid IPv6 address. ### Parameters The IPv4 or IPv6 address to validate. ### Response A dict containing validation results: * 'ip4': bool - Whether the IP address is a valid IPv4 address. * 'ip6': bool - Whether the IP address is a valid IPv6 address. ### Parameters The IPv4 or IPv6 address to validate. ### Response An array containing validation results: * 'ip4': bool - Whether the IP address is a valid IPv4 address. * 'ip6': bool - Whether the IP address is a valid IPv6 address. # List Conversions Source: https://docs.ip2geo.dev/sdk/list-conversions This function allows you to list your conversions with pagination, filtering, and field selection, see an example below: You should authenticate/initialize Ip2Geo before using this method. ```typescript TypeScript theme={null} import { ListConversions } from '@ip2geo/sdk' const { data, success, message } = await ListConversions() ``` ```ruby Ruby theme={null} result = Ip2Geo.list_conversions # { # 'success' => true, # 'code' => 200, # 'message' => 'Success', # 'data' => { # 'conversions' => [...], # 'hasMore' => true, # 'totalCount' => 100 # }, # '_req' => { 'reqId' => '...', 'resTime' => 123 } # } ``` ```python Python theme={null} import ip2geo result = ip2geo.list_conversions() # { # 'success': True, # 'code': 200, # 'message': 'Success', # 'data': { # 'conversions': [...], # 'hasMore': True, # 'totalCount': 100 # }, # '_req': { 'reqId': '...', 'resTime': 123 } # } ``` ```php PHP theme={null} true, // 'code' => 200, // 'message' => 'Success', // 'data' => [ // 'conversions' => [...], // 'hasMore' => true, // 'totalCount' => 100, // ], // '_req' => ['reqId' => '...', 'resTime' => 123], // ] ``` ### With Pagination You can paginate through conversions using offset and limit: ```typescript TypeScript theme={null} import { ListConversions } from '@ip2geo/sdk' const { data, success, message } = await ListConversions({ offset: 0, limit: 20 }) // Access pagination info console.log(data.conversions) // Array of conversions console.log(data.hasMore) // true if there are more conversions console.log(data.totalCount) // Total number of conversions ``` ```ruby Ruby theme={null} result = Ip2Geo.list_conversions(offset: 0, limit: 20) # Access pagination info puts result['data']['conversions'] # Array of conversions puts result['data']['hasMore'] # true if there are more conversions puts result['data']['totalCount'] # Total number of conversions ``` ```python Python theme={null} result = ip2geo.list_conversions(offset=0, limit=20) # Access pagination info print(result['data']['conversions']) # List of conversions print(result['data']['hasMore']) # True if there are more conversions print(result['data']['totalCount']) # Total number of conversions ``` ```php PHP theme={null} ### With IP Search Filter conversions by IP address: ```typescript TypeScript theme={null} import { ListConversions } from '@ip2geo/sdk' const { data, success, message } = await ListConversions({ ipSearch: '8.8.8.8' }) ``` ```ruby Ruby theme={null} result = Ip2Geo.list_conversions(ip_search: '8.8.8.8') ``` ```python Python theme={null} result = ip2geo.list_conversions(ip_search='8.8.8.8') ``` ```php PHP theme={null} ### With Select Fields Select specific fields from the conversion data object: ```typescript TypeScript theme={null} import { ListConversions, SELECT } from '@ip2geo/sdk' const { data, success, message } = await ListConversions({ select: [ SELECT.COUNTRY_NAME, SELECT.COUNTRY_CODE, SELECT.ASN_NAME ] }) ``` ```ruby Ruby theme={null} result = Ip2Geo.list_conversions( select: [ Ip2Geo.select[:COUNTRY_NAME], Ip2Geo.select[:COUNTRY_CODE], Ip2Geo.select[:ASN_NAME] ] ) ``` ```python Python theme={null} result = ip2geo.list_conversions( select=[ ip2geo.SELECT['COUNTRY_NAME'], ip2geo.SELECT['COUNTRY_CODE'], ip2geo.SELECT['ASN_NAME'], ] ) ``` ```php PHP theme={null} ### Parameters The number of conversions to skip for pagination. The maximum number of conversions to return. Maximum value is 50. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. Filter conversions by IP address. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The response data containing: * conversions: Array of conversion objects (or partial objects if select was used) * hasMore: Boolean indicating if there are more conversions to fetch * totalCount: Total number of conversions matching the query Request metadata containing: * reqId: Unique request identifier. * resTime: Response time in milliseconds. ### Parameters The number of conversions to skip for pagination. The maximum number of conversions to return. Maximum value is 50. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. Filter conversions by IP address. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The response data containing: * 'conversions': Array of conversion hashes (or partial hashes if select was used) * 'hasMore': Boolean indicating if there are more conversions to fetch * 'totalCount': Total number of conversions matching the query Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters The number of conversions to skip for pagination. The maximum number of conversions to return. Maximum value is 50. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. Filter conversions by IP address. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The response data containing: * 'conversions': List of conversion dicts (or partial dicts if select was used) * 'hasMore': Boolean indicating if there are more conversions to fetch * 'totalCount': Total number of conversions matching the query Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. ### Parameters The number of conversions to skip for pagination. The maximum number of conversions to return. Maximum value is 50. Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields. Filter conversions by IP address. ### Response Whether the request was successful. Response message describing the result. HTTP status code. The response data containing: * 'conversions': Array of conversion arrays (or partial arrays if select was used) * 'hasMore': Boolean indicating if there are more conversions to fetch * 'totalCount': Total number of conversions matching the query Request metadata containing: * 'reqId': Unique request identifier. * 'resTime': Response time in milliseconds. For all available SELECT constants and their values, see the SELECT Constants reference. # Secret Keys Source: https://docs.ip2geo.dev/secret-keys Secret keys authenticate your project from server-side environments (Node.js, Python, Ruby, etc.). Each key you create in your dashboard is assigned to a project. Create your Ip2Geo account or login to your existing account if you haven't already. You can do that by visiting the Ip2Geo Dashboard. Once logged in, select the project you want to generate a secret key for from your dashboard. Navigate to the Keys section within your project. Click on "Create Key", provide a name for your key, and click "Generate Key" to create your secret key. Use the secret key to authenticate your project when using the SDK or making direct API calls from your server. Keep your secret keys secure and do not share them publicly. If you believe your key has been compromised, you can re-roll it from the dashboard to generate a new one. # Websites Source: https://docs.ip2geo.dev/websites Websites let you use the Ip2Geo SDK and API directly from the browser. When you add a website, a public key is generated and tied to that domain — only requests originating from that domain will be accepted. Create your Ip2Geo account or login to your existing account if you haven't already. You can do that by visiting the Ip2Geo Dashboard. Once logged in, select the project you want to add a website to from your dashboard. Navigate to the Websites section within your project. Click on "Add Website", enter your domain (e.g. myapp.com), and confirm. A public key (i2g\_pk\_...) will be generated automatically. Use the public key to authenticate your project when using the SDK or making direct API calls from your frontend. Public keys are safe to expose in client-side code. They only work from the domain they are registered to, so even if someone copies the key, it won't work from a different origin.