Skip to main content
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.
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
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 }
# }
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

use Ip2Geo\Ip2Geo;

$result = Ip2Geo::getConversions(
    conversionIds: ['uuid-1', 'uuid-2', 'uuid-3'],
);

// Access the conversions
print_r($result['data']['conversions']); // Array of conversion arrays

// [
//     'success' => 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:
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' }
//             }
//         },
//         ...
//     ]
// }
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' }
#             }
#         },
#         ...
#     ]
# }
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

use Ip2Geo\Ip2Geo;

$result = Ip2Geo::getConversions(
    conversionIds: ['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'],
//             ],
//         ],
//         ...
//     ],
// ]

Parameters

conversionIds
Array<string>
required
An array of unique identifiers (UUIDs) of the conversions to retrieve. Maximum 100 IDs per request.
select
Array<SelectField>
Select specific data fields to return. If not specified, all data fields are returned. See SELECT Constants for all available fields.

Response

success
boolean
Whether the request was successful.
message
string
Response message describing the result.
code
number
HTTP status code.
data
object | null
The response data containing:
  • conversions: Array of conversion objects (or partial objects if select was used)
_req
object
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:
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'] }
// }
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'] }
# }
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

$result = Ip2Geo::getConversions(
    conversionIds: ['valid-uuid', 'invalid-id', 'another-bad-id'],
);

// Response:
// [
//     'success' => false,
//     'message' => 'conversions.invalid-conversion-ids',
//     'data' => ['invalidIds' => ['invalid-id', 'another-bad-id']],
// ]