> ## 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.

# Convert IP

This function allows you to convert a single IP address into its corresponding geolocation data using, see an example below:

<Warning>
  You should authenticate/initialize <a href="/sdk/init">Ip2Geo</a> before using this method.
</Warning>

<CodeGroup>
  ```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}
  <?php

  use Ip2Geo\Ip2Geo;

  $result = Ip2Geo::convertIp(ip: '8.8.8.8');

  // [
  //     'success' => true,
  //     'code' => 200,
  //     'message' => 'Success',
  //     'data' => [ ... ],
  //     '_req' => ['reqId' => '...', 'resTime' => 123],
  // ]
  ```
</CodeGroup>

<Tabs>
  <Tab title="TypeScript">
    ### Parameters

    <ParamField path="ip" type="string" required>
      The IPv4 or IPv6 address to convert.
    </ParamField>

    ### Response

    <ResponseField name="success" type="boolean">
      Whether the request was successful.
    </ResponseField>

    <ResponseField name="message" type="string">
      Response message describing the result.
    </ResponseField>

    <ResponseField name="code" type="number">
      HTTP status code.
    </ResponseField>

    <ResponseField name="data" type="Ip | null">
      The geolocation data for the IP address. See <a href="/interfaces/ip">Ip Interface</a> for details. Returns <code>null</code> if the conversion failed, read more about <a href="/interfaces/conversion">IP Response Interface</a>.
    </ResponseField>

    <ResponseField name="_req" type="object">
      Request metadata containing:

      * <code>reqId</code>: Unique request identifier.
      * <code>resTime</code>: Response time in milliseconds.
    </ResponseField>
  </Tab>

  <Tab title="Ruby">
    ### Parameters

    <ParamField path="ip" type="String" required>
      The IPv4 or IPv6 address to convert.
    </ParamField>

    ### Response

    <ResponseField name="success" type="Boolean">
      Whether the request was successful.
    </ResponseField>

    <ResponseField name="message" type="String">
      Response message describing the result.
    </ResponseField>

    <ResponseField name="code" type="Integer">
      HTTP status code.
    </ResponseField>

    <ResponseField name="data" type="Hash | nil">
      The geolocation data for the IP address. See <a href="/interfaces/ip">Ip Interface</a> for details. Returns <code>nil</code> if the conversion failed, read more about <a href="/interfaces/conversion">IP Response Interface</a>.
    </ResponseField>

    <ResponseField name="_req" type="Hash">
      Request metadata containing:

      * <code>'reqId'</code>: Unique request identifier.
      * <code>'resTime'</code>: Response time in milliseconds.
    </ResponseField>
  </Tab>

  <Tab title="Python">
    ### Parameters

    <ParamField path="ip" type="str" required>
      The IPv4 or IPv6 address to convert.
    </ParamField>

    ### Response

    <ResponseField name="success" type="bool">
      Whether the request was successful.
    </ResponseField>

    <ResponseField name="message" type="str">
      Response message describing the result.
    </ResponseField>

    <ResponseField name="code" type="int">
      HTTP status code.
    </ResponseField>

    <ResponseField name="data" type="dict | None">
      The geolocation data for the IP address. See <a href="/interfaces/ip">Ip Interface</a> for details. Returns <code>None</code> if the conversion failed, read more about <a href="/interfaces/conversion">IP Response Interface</a>.
    </ResponseField>

    <ResponseField name="_req" type="dict">
      Request metadata containing:

      * <code>'reqId'</code>: Unique request identifier.
      * <code>'resTime'</code>: Response time in milliseconds.
    </ResponseField>
  </Tab>

  <Tab title="PHP">
    ### Parameters

    <ParamField path="ip" type="string" required>
      The IPv4 or IPv6 address to convert.
    </ParamField>

    ### Response

    <ResponseField name="success" type="bool">
      Whether the request was successful.
    </ResponseField>

    <ResponseField name="message" type="string">
      Response message describing the result.
    </ResponseField>

    <ResponseField name="code" type="int">
      HTTP status code.
    </ResponseField>

    <ResponseField name="data" type="array | null">
      The geolocation data for the IP address. See <a href="/interfaces/ip">Ip Interface</a> for details. Returns <code>null</code> if the conversion failed, read more about <a href="/interfaces/conversion">IP Response Interface</a>.
    </ResponseField>

    <ResponseField name="_req" type="array">
      Request metadata containing:

      * <code>'reqId'</code>: Unique request identifier.
      * <code>'resTime'</code>: Response time in milliseconds.
    </ResponseField>
  </Tab>
</Tabs>
