---
title: "API Response Formats: JSON, XML, and Get IP Output | IPGeolocation.io"
slug: "/documentation/api-response-formats.html"
parent: "IP Geolocation API"
description: "Control IPGeolocation.io API response formats. JSON is the default. Request XML using output=xml or Accept header. Includes Get IP endpoint (no auth) with JSON, XML, and plain text output."
---

# 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](https://ipgeolocation.io/documentation/api-authentication.html) for Request Origin (CORS).

* * *

## Related Docs

*   [API Authentication](https://ipgeolocation.io/documentation/api-authentication.html): authenticate requests using `apiKey` or Request Origin (CORS).
*   [IP Geolocation API endpoint](https://ipgeolocation.io/documentation/ip-location-api.html): full geolocation lookup and rich IP intelligence response fields.

* * *

## 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 Preview**

```json
{
  "ip": "1.1.1.1"
}
```

* * *

### 3. XML Response

```
curl -X GET 'https://api.ipgeolocation.io/v3/getip?output=xml'
```

**Response Preview**

```json
<LinkedHashMap>
	<ip>1.1.1.1</ip>
</LinkedHashMap>
```

* * *

### 4. Plain Text Response

```
curl -X GET 'https://api.ipgeolocation.io/v3/getip?output=text'
```

**Response Preview**

```json
1.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](https://ipgeolocation.io/documentation/ip-location-api.html).

## Frequently Asked Questions

### What is the default response format?

**Answer:** JSON is the default response format.

### How do I request XML?

**Answer:**

Use `output=xml` or set `Accept: application/xml` or `Accept: text/xml` .

### What happens if I do not set the output or Accept header?

**Answer:** If you do not set the output URL parameter or Accept header, the API responds in JSON.

### Does Get IP require authentication?

**Answer:** No. Get IP does not require authentication.
