# IPQuery Docs

## Basic Request

### GET /

Returns your IP Address.

{% hint style="info" %}
Defaults the response format to `text` when fetching your own ip address. If you want to include additional fields checkout the [#changing-response-formats](#changing-response-formats "mention") section.
{% endhint %}

#### Python Example

```python
import requests

req = requests.get("https://api.ipquery.io/")
print(req.text) # Your ip address
```

#### Response

{% code fullWidth="false" %}

```json
1.1.1.1
```

{% endcode %}

## Query Specific IP Address

### GET /1.1.1.1

Returns the ip address queried along with all of the fields.

{% hint style="info" %}
Defaults the response format to `json` when querying a specific ip address. To change this checkout the [#changing-response-formats](#changing-response-formats "mention") section.
{% endhint %}

#### Python Example

```python
import requests

req = requests.get("https://api.ipquery.io/1.1.1.1")
print(req.text)
```

#### Response

```json
{
    "ip": "1.1.1.1",
    "isp": {
        "asn": "AS13335",
        "org": "Cloudflare, Inc.",
        "isp": "Cloudflare, Inc."
    },
    "location": {
        "country": "Australia",
        "country_code": "AU",
        "city": "Sydney",
        "state": "New South Wales",
        "zipcode": "1001",
        "latitude": -33.854548400186665,
        "longitude": 151.20016200912815,
        "timezone": "Australia/Sydney",
        "localtime": "2024-09-03T22:22:52"
    },
    "risk": {
        "is_mobile": false,
        "is_vpn": false,
        "is_tor": false,
        "is_proxy": false,
        "is_datacenter": true,
        "risk_score": 0
    }
}
```

## Bulk Query A List of IP Address's

IPQuery supports bulk lookups, each address can be seperated with a comma.

{% hint style="warning" %}
The maximum number of allowed lookups in batch mode is capped at 10,000.&#x20;
{% endhint %}

### GET /1.1.1.1,2.2.2.2

#### Python Example

```python
import requests

req = requests.get("https://api.ipquery.io/1.1.1.1,2.2.2.2")
print(req.text)
```

#### Response Example

```json
[
    {
        "ip": "1.1.1.1",
        "isp": {
            "asn": "AS13335",
            "org": "Cloudflare, Inc.",
            "isp": "Cloudflare, Inc."
        },
        "location": {
            "country": "Australia",
            "country_code": "AU",
            "city": "Sydney",
            "state": "New South Wales",
            "zipcode": "1001",
            "latitude": -33.854548400186665,
            "longitude": 151.20016200912815,
            "timezone": "Australia/Sydney",
            "localtime": "2024-09-03T22:23:42"
        },
        "risk": {
            "is_mobile": false,
            "is_vpn": false,
            "is_tor": false,
            "is_proxy": false,
            "is_datacenter": true,
            "risk_score": 0
        }
    },
    ... // Results for 2.2.2.2
]
```

## Changing Response Formats

IPQuery supports the following response formats:

* Text
* JSON
* YAML
* XML

The response format can be changed by adding the `?format=` parameter.

### GET /1.1.1.1?format=yaml

#### Python Example

```python
import requests

req = requests.get("https://api.ipquery.io/1.1.1.1?format=yaml")
print(req.text)
```

#### Response

```yaml
ip: 1.1.1.1
isp:
  asn: AS13335
  org: Cloudflare, Inc.
  isp: Cloudflare, Inc.
location:
  country: Australia
  country_code: AU
  city: Sydney
  state: New South Wales
  zipcode: "1001"
  latitude: -33.854548400186665
  longitude: 151.20016200912815
  timezone: Australia/Sydney
  localtime: 2024-09-03T22:45:50
risk:
  is_mobile: false
  is_vpn: false
  is_tor: false
  is_proxy: false
  is_datacenter: true
  risk_score: 0
```

### GET /1.1.1.1?format=xml

Python Example

```python
import requests

req = requests.get("https://api.ipquery.io/1.1.1.1?format=xml")
print(req.text)
```

#### Response

```xml
<IPInfo>
    <ip>1.1.1.1</ip>
    <isp>
        <asn>AS13335</asn>
        <org>Cloudflare, Inc.</org>
        <isp>Cloudflare, Inc.</isp>
    </isp>
    <location>
        <country>Australia</country>
        <country_code>AU</country_code>
        <city>Sydney</city>
        <state>New South Wales</state>
        <zipcode>1001</zipcode>
        <latitude>-33.854548400186665</latitude>
        <longitude>151.20016200912815</longitude>
        <timezone>Australia/Sydney</timezone>
        <localtime>2024-09-03T22:51:11</localtime>
    </location>
    <risk>
        <is_datacenter>true</is_datacenter>
    </risk>
</IPInfo>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ipquery.gitbook.io/ipquery-docs/ipquery-docs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
