API Response Formats (JSON & XML)

All IPGeolocation.io API endpoints support JSON and XML responses. JSON is the default response format. The only exception is the Get IP endpoint, which also supports plain-text output.


At a Glance

  • Default: JSON
  • XML: output=xml or Accept: application/xml / Accept: text/xml
  • If no output/Accept is set: response is JSON
  • Get IP endpoint: returns public IP address, no auth, supports JSON/XML/plain text via output

JSON (Default)

If you do not specify a response format, the API responds in JSON.

This is the recommended format for most integrations, SDK usage, and backend services.


XML

To request XML, use one of the two supported options below.


1. Option 1: URL Parameter (output=xml)

Pass output=xml as a URL parameter.

curl -X GET 'https://api.ipgeolocation.io/v3/ipgeo?apiKey=API_KEY&ip=1.1.1.1&fields=location.city&output=xml'

2. Option 2: Accept Header

Set the Accept HTTP header to application/xml or text/xml .

curl -X GET 'https://api.ipgeolocation.io/v3/ipgeo?apiKey=API_KEY&ip=1.1.1.1&fields=currency' \
-H 'Accept: text/xml'
Note
If you do not set the output URL parameter or Accept header, the API responds in JSON. If you are building a browser integration, review API Authentication for Request Origin (CORS).

Get IP Endpoint (No Auth)

The Get IP endpoint returns the public IP address of the client where it is called. If called from your server, it returns the server IP. If called from your website (JavaScript), it returns the visitor's IP address. This endpoint does not require authentication and can be used without creating an account.


1. Output Parameter

The optional output query parameter controls the response format:

  • output=json (default): JSON
  • output=xml : XML
  • output=text : plain text

2. JSON Response (Default)

curl -X GET 'https://api.ipgeolocation.io/v3/getip'
Response
1{
2  "ip": "1.1.1.1"
3}

3. XML Response

curl -X GET 'https://api.ipgeolocation.io/v3/getip?output=xml'
Response
1<LinkedHashMap>
2	<ip>1.1.1.1</ip>
3</LinkedHashMap>

4. Plain Text Response

curl -X GET 'https://api.ipgeolocation.io/v3/getip?output=text'
Response
11.1.1.1
Important
Use Get IP when you only need the caller's public IP. For full geolocation data, use the IP Geolocation API endpoint.

Frequently Asked Questions

JSON is the default response format.
Use output=xml or set Accept: application/xml or Accept: text/xml .
If you do not set the output URL parameter or Accept header, the API responds in JSON.
No. Get IP does not require authentication.

Subscribe Our Newsletter

Get the latest in geolocation tech, straight to your inbox.