# Shodan API reference

> The Shodan REST API searches Shodan's database of banners: what its crawlers saw on Internet-facing hosts (open ports, services, software, certificates, organisation, location). It also returns DNS records Shodan has collected for a domain, resolves hostnames and IPs, and can ask Shodan to crawl…

Source: https://osinttools.io/apis/shodan/ (Markdown view of an OSINTtools.io page; append `.md` to any page URL for this format).

Compiled by OSINTtools.io editors from the vendor's docs, updated Nov 29, 2026. Listing: https://osinttools.io/tools/shodan/

- Base URL: https://api.shodan.io
- Authentication: API key in the `key` query parameter. Get a key: https://account.shodan.io/billing All Shodan accounts come with a free API plan; the key is on your account page.
- Free tier: yes
- Pricing: Subscription
- Rate limits: All API plans are subject to a rate limit of 1 request per second.
- Vendor docs: https://developer.shodan.io/api
- OpenAPI spec: https://developer.shodan.io/api/openapi.json
- Python SDK: shodan, https://github.com/achillean/shodan-python

## Overview

The Shodan REST API searches Shodan's database of banners: what its crawlers saw on Internet-facing hosts (open ports, services, software, certificates, organisation, location). It also returns DNS records Shodan has collected for a domain, resolves hostnames and IPs, and can ask Shodan to crawl given IPs on demand.

An investigator uses it to see every service Shodan has recorded on an IP (with history), to count or search hosts matching filters such as `org:`, `hostname:` or `port:`, and to list a domain's subdomains and DNS records. Host lookups, searches and DNS lookups read Shodan's existing data; only the on-demand scan makes Shodan contact the target.

Calls go to `https://api.shodan.io` with your key in the `key` query parameter; responses are JSON, and a non-200 status means an error with a message such as `{"error": "Invalid IP"}`. Searches with a filter, pages past the first and domain DNS lookups use query credits; scans use scan credits (1 per IP). Every account comes with a free API plan; paid API plans add monthly query and scan credits.

## Errors

| Status | Meaning |
| --- | --- |
| 404 | Host lookup: invalid IP ({"error": "Invalid IP"}). The docs say any non-200 status is an error, with the reason in an error field |

## Hosts

### All services Shodan has found on an IP address

`GET /shodan/host/{ip}`

- Takes: IP address
- Footprint: passive (the target is not contacted)

Returns host details (organisation, ISP, ASN, location, hostnames, domains, open ports, tags, OS) and the banner for each service. `history=true` adds every historical banner; `minify=true` returns only the ports and general host information.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ip` | path | string | yes | Host IP address Example: 203.0.113.7 |
| `history` | query | boolean | no | True to return all historical banners Example: false |
| `minify` | query | boolean | no | True to return only the list of ports and general host information, no banners Example: false |

Response fields:

- `ip_str` (string): The IP address
- `hostnames[]` (string): Hostnames seen for the IP
- `domains[]` (string): Domains seen for the IP
- `org` (string): Organisation the IP is assigned to
- `isp` (string): ISP
- `asn` (string): Autonomous system number
- `country_code` (string): Country code
- `city` (string): City
- `ports[]` (integer): Open ports seen
- `last_update` (string): When the host was last updated
- `data[]` (object): One banner per service: port, transport, product, timestamp, raw data and protocol-specific fields

```bash
curl 'https://api.shodan.io/shodan/host/203.0.113.7?key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "ip_str": "203.0.113.7",
  "hostnames": [
    "host7.example.net"
  ],
  "domains": [
    "example.net"
  ],
  "org": "Example Hosting",
  "isp": "Example Networks",
  "asn": "AS64500",
  "country_code": "NL",
  "city": "Amsterdam",
  "latitude": 52.37,
  "longitude": 4.89,
  "os": null,
  "tags": [],
  "ports": [
    22,
    443
  ],
  "last_update": "2026-11-20T04:12:33.000000",
  "data": [
    {
      "port": 443,
      "transport": "tcp",
      "product": "nginx",
      "timestamp": "2026-11-20T04:12:33.000000",
      "data": "HTTP/1.1 200 OK\r\nServer: nginx\r\n"
    }
  ]
}
```

### Search Shodan's banners with filters such as hostname:, org:, net: or port:

`GET /shodan/host/search`

- Takes: IP address, Domain
- Footprint: passive (the target is not contacted)
- Cost: 1 query credit if the query has a filter or reaches past page 1 (1 credit per 100 results past page 1)

Returns matching banners 100 per page, the total count and optional facet summaries. Past page 100, pages must be requested in order. Uses Shodan's search query syntax.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `query` | query | string | yes | Shodan search query, in filter:value syntax Example: hostname:example.com |
| `facets` | query | string | no | Comma-separated properties to summarise; prop:count sets how many values Example: org,port |
| `page` | query | integer | no | Page of results, 100 per page Example: 1 |
| `minify` | query | boolean | no | Whether to truncate some of the larger fields, such as http.html Example: true |
| `fields` | query | string | no | Comma-separated list of fields to return in each result Example: ip_str,port,http.title |

Response fields:

- `matches[]` (object): Matching banners
- `matches[].ip_str` (string): IP address of the service
- `matches[].port` (integer): Port
- `matches[].product` (string): Software detected
- `matches[].org` (string): Organisation
- `matches[].hostnames[]` (string): Hostnames
- `matches[].location` (object): Country, city and coordinates
- `total` (integer): Total number of results
- `facets` (object): For each facet, a list of {count, value}

```bash
curl 'https://api.shodan.io/shodan/host/search?query=hostname%3Aexample.com&key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "matches": [
    {
      "ip_str": "198.51.100.20",
      "port": 443,
      "transport": "tcp",
      "product": "nginx",
      "org": "Example Hosting",
      "hostnames": [
        "www.example.com"
      ],
      "location": {
        "country_code": "DE",
        "city": "Frankfurt am Main"
      },
      "timestamp": "2026-11-18T09:01:44.000000"
    }
  ],
  "facets": {
    "port": [
      {
        "count": 12,
        "value": 443
      }
    ]
  },
  "total": 12
}
```

### Count the hosts matching a search query, with optional facets, without returning results

`GET /shodan/host/count`

- Footprint: passive (the target is not contacted)
- Cost: No query credits

Same query syntax as host search, but returns only the total and facet summaries. Does not use query credits.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `query` | query | string | yes | Shodan search query, in filter:value syntax Example: org:"Example Hosting" port:22 |
| `facets` | query | string | no | Comma-separated properties to summarise; prop:count sets how many values Example: org,os |

Response fields:

- `total` (integer): Number of matching results
- `matches[]` (object): Always empty
- `facets` (object): For each facet, a list of {count, value}

```bash
curl 'https://api.shodan.io/shodan/host/count?query=org%3A%22Example%20Hosting%22%20port%3A22&key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "matches": [],
  "facets": {
    "os": [
      {
        "count": 41,
        "value": "Linux"
      }
    ]
  },
  "total": 57
}
```

## Search helpers

### Break a search query into its filters and free text, to check it before running

`GET /shodan/host/search/tokens`

- Footprint: passive (the target is not contacted)

Shows which filters a query uses, their values, the remaining free text and any errors.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `query` | query | string | yes | The query to tokenise Example: Raspbian port:22 |

Response fields:

- `attributes` (object): Filter values found, e.g. ports
- `errors[]` (string): Problems in the query
- `string` (string): The non-filter text
- `filters[]` (string): Filter names used

```bash
curl 'https://api.shodan.io/shodan/host/search/tokens?query=Raspbian%20port%3A22&key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "attributes": {
    "ports": [
      22
    ]
  },
  "errors": [],
  "string": "Raspbian",
  "filters": [
    "port"
  ]
}
```

### List the filter names a search query can use

`GET /shodan/host/search/filters`

- Footprint: passive (the target is not contacted)

Returns the names of all search filters.

Response fields:

- `[]` (string): Filter name

```bash
curl 'https://api.shodan.io/shodan/host/search/filters?key=YOUR_API_KEY'
```

Example response (200):

```json
[
  "all",
  "asn",
  "city",
  "hostname",
  "org",
  "port"
]
```

### List the properties a search can summarise as facets

`GET /shodan/host/search/facets`

- Footprint: passive (the target is not contacted)

Returns the names of all facets.

Response fields:

- `[]` (string): Facet name

```bash
curl 'https://api.shodan.io/shodan/host/search/facets?key=YOUR_API_KEY'
```

Example response (200):

```json
[
  "asn",
  "country",
  "org",
  "os",
  "port"
]
```

## DNS

### Subdomains and DNS records Shodan has collected for a domain

`GET /dns/domain/{domain}`

- Takes: Domain
- Footprint: passive (the target is not contacted)
- Cost: 1 query credit per lookup

Returns the domain's subdomains and its records (subdomain, type, value, last seen), 100 per page. `history=true` includes historical records; `type` limits to one record type.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domain` | path | string | yes | Domain name to look up Example: example.com |
| `history` | query | boolean | no | True to include historical DNS data Example: false |
| `type` | query | string | no | DNS record type Example: MX One of: A, AAAA, CNAME, NS, SOA, MX, TXT |
| `page` | query | integer | no | Page of results, 100 per page Example: 1 |

Response fields:

- `domain` (string): The domain looked up
- `tags[]` (string): Tags such as ipv6
- `data[].subdomain` (string): Subdomain (empty for the domain itself)
- `data[].type` (string): Record type
- `data[].value` (string): Record value
- `data[].last_seen` (string): When Shodan last saw the record
- `subdomains[]` (string): Subdomains found
- `more` (boolean): Whether more pages exist

```bash
curl 'https://api.shodan.io/dns/domain/example.com?key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "domain": "example.com",
  "tags": [
    "ipv6"
  ],
  "data": [
    {
      "subdomain": "",
      "type": "MX",
      "value": "mail.example.com",
      "last_seen": "2026-11-15T10:20:30.000000"
    },
    {
      "subdomain": "www",
      "type": "A",
      "value": "192.0.2.10",
      "last_seen": "2026-11-15T10:20:30.000000"
    }
  ],
  "subdomains": [
    "mail",
    "www"
  ],
  "more": false
}
```

### Resolve hostnames to IP addresses

`GET /dns/resolve`

- Takes: Domain
- Footprint: passive (the target is not contacted)

Returns an object mapping each hostname to an IP address.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `hostnames` | query | string | yes | Comma-separated list of hostnames Example: example.com |

Response fields:

- `{hostname}` (string): IP address the hostname resolves to

```bash
curl 'https://api.shodan.io/dns/resolve?hostnames=example.com&key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "example.com": "192.0.2.10"
}
```

### Look up the hostnames defined for IP addresses

`GET /dns/reverse`

- Takes: IP address
- Footprint: passive (the target is not contacted)

Returns an object mapping each IP to a list of hostnames.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ips` | query | string | yes | Comma-separated list of IP addresses Example: 192.0.2.10 |

Response fields:

- `{ip}[]` (string): Hostnames for the IP

```bash
curl 'https://api.shodan.io/dns/reverse?ips=192.0.2.10&key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "192.0.2.10": [
    "host10.example.net"
  ]
}
```

## On-demand scanning

### Ask Shodan to crawl IPs or netblocks now

`POST /shodan/scan`

- Takes: IP address
- Footprint: active (contacts the target)
- Cost: 1 scan credit per IP
- Plan: Paid API plan

Shodan's crawlers connect to the given IPs, so this contacts the target. Returns a scan ID to poll with GET /shodan/scan/{id}. Needs a paid API plan. `ips` can also be a JSON object mapping each IP to a list of [port, protocol] pairs.

Response fields:

- `count` (integer): Number of IPs that will be crawled
- `id` (string): Scan ID
- `credits_left` (integer): Scan credits remaining

```bash
curl -X POST 'https://api.shodan.io/shodan/scan?key=YOUR_API_KEY' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'ips=198.51.100.0/30,203.0.113.7'
```

Example response (200):

```json
{
  "count": 5,
  "id": "Ab12Cd34Ef56Gh78",
  "credits_left": 4995
}
```

### Check the status of an on-demand scan

`GET /shodan/scan/{id}`

- Footprint: passive (the target is not contacted)

Returns the scan's status: SUBMITTING, QUEUE, PROCESSING or DONE.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | Scan ID returned by POST /shodan/scan Example: Ab12Cd34Ef56Gh78 |

Response fields:

- `count` (integer): IPs in the scan
- `status` (string): SUBMITTING, QUEUE, PROCESSING or DONE
- `id` (string): Scan ID
- `created` (string): When the scan was created

```bash
curl 'https://api.shodan.io/shodan/scan/Ab12Cd34Ef56Gh78?key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "count": 5,
  "status": "DONE",
  "id": "Ab12Cd34Ef56Gh78",
  "created": "2026-11-28T14:02:11.000000"
}
```

### List the on-demand scans you have created

`GET /shodan/scans`

- Footprint: passive (the target is not contacted)

Returns your scans with their status, creation time and size.

Response fields:

- `matches[]` (object): Scans: id, status, created, size, credits_left
- `total` (integer): Number of scans

```bash
curl 'https://api.shodan.io/shodan/scans?key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "matches": [
    {
      "id": "Ab12Cd34Ef56Gh78",
      "status": "DONE",
      "created": "2026-11-28T14:02:11.000000",
      "size": 5,
      "credits_left": 4995
    }
  ],
  "total": 1
}
```

## Account

### Your API plan and remaining query and scan credits

`GET /api-info`

- Footprint: passive (the target is not contacted)

Returns the plan behind your key, credits left and usage limits.

Response fields:

- `plan` (string): API plan
- `query_credits` (integer): Query credits left
- `scan_credits` (integer): Scan credits left
- `monitored_ips` (integer): IPs being monitored
- `usage_limits` (object): Plan limits for scan_credits, query_credits and monitored_ips
- `unlocked` (boolean): Whether the account is unlocked
- `unlocked_left` (integer): Unlocks left
- `https` (boolean): HTTPS filter access
- `telnet` (boolean): Telnet filter access

```bash
curl 'https://api.shodan.io/api-info?key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "scan_credits": 100,
  "usage_limits": {
    "scan_credits": 100,
    "query_credits": 100,
    "monitored_ips": 16
  },
  "plan": "dev",
  "https": false,
  "unlocked": true,
  "query_credits": 87,
  "monitored_ips": 0,
  "unlocked_left": 87,
  "telnet": false
}
```

### Your account profile: membership, credits and creation date

`GET /account/profile`

- Footprint: passive (the target is not contacted)

Returns information about the account behind the key.

Response fields:

- `member` (boolean): Whether the account has a membership
- `credits` (integer): Credits
- `display_name` (string): Display name, or null
- `created` (string): When the account was created

```bash
curl 'https://api.shodan.io/account/profile?key=YOUR_API_KEY'
```

Example response (200):

```json
{
  "member": true,
  "credits": 0,
  "display_name": null,
  "created": "2020-06-15T10:44:43.148000"
}
```

---

Listings on OSINTtools.io are reviewed by editors and re-verified on a schedule; check pricing and availability on the vendor's site before relying on them, and use OSINT tools only with a lawful basis.
Site index for agents: https://osinttools.io/llms.txt · Full catalog: https://osinttools.io/llms-full.txt · MCP server (Streamable HTTP, no auth): https://osinttools.io/mcp/
