The OpenAPI 3.1 spec on one page

Every endpoint, parameter, response and schema of the host.sh IP lookup API, rendered from its OpenAPI 3.1 spec into one static page.

This page is generated from the OpenAPI spec (OpenAPI 3.1.0, API version 2). Use the YAML file itself for code generators and API clients; the guides are in the docs.

host.sh IP lookup API

Geolocation, network and connection details for IPv4 and IPv6 addresses.

Without a token you can look up your own address (10 requests a minute per IP). Looking up any other address, and batch lookups, need a token. Send it as ?token=, as a token field in a JSON body, or as an Authorization: Bearer header.

Which sections a response has depends on the token's plan.

Servers

  • https://api.host.sh
  • https://ipv4.host.sh: IPv4 only, to learn a dual-stack client's IPv4 address

Authentication

Each endpoint takes one of these, or none where the endpoint allows it:

  • bearer: HTTP Authorization: Bearer <token> header
  • query: API key in the query parameter token

Endpoints

GET /v2/lookup/

Look up an address (your own without a token).

Auth: none, bearer, query. Operation id: lookup.

ParameterInTypeDescription
ipquerystringIPv4 or IPv6 address to look up (needs a token). Without it you get your own address. Example: 8.8.8.8.
uaquerystringUser-Agent string to parse (needs the user agent permission)
alquerystringAccept-Language header value to parse
fieldsquerystringComma-separated dotted paths to keep, e.g. geo.country.code,connection.ip. Unknown paths are left out.
langquerystring, one of en, de, es, fr, ja, pt-BR, ru, zh-CN, default enLanguage of continent, country, region and city names. Falls back to English where a name is missing.
hostnamequeryboolean, default falseAdd connection.hostname, the reverse DNS (PTR) name. Adds up to a second.
formatquerystring, one of json, text, default jsontext returns one field as plain text; it needs fields with exactly one single-value path.
prettyqueryboolean, default falseIndent the JSON and sort its keys
callbackquerystringJSONP callback name (letters, digits, _, $ and .)
StatusMeaningContent
200Lookup resultapplication/json (Lookup), text/plain
400Errorapplication/json (Errors)
401Errorapplication/json (Errors)
403Errorapplication/json (Errors)
429More than 10 tokenless requests a minute from one addressapplication/json (Errors), header Retry-After

POST /v2/lookup/

Same as GET, with the parameters in a JSON or form body.

Auth: none, bearer, query. Operation id: lookupPost.

Request body:

  • application/json: object with token, ip, ua, al, fields, lang
StatusMeaningContent
200Lookup resultapplication/json (Lookup), text/plain
400Errorapplication/json (Errors)
401Errorapplication/json (Errors)
403Errorapplication/json (Errors)

GET /v2/lookup/{address}

Look up one address given in the path (token required). The trailing slash is optional, /v2/lookup/8.8.8.8/ works too.

Auth: bearer, query (a token is required; the spec also lists none). Operation id: lookupAddress.

ParameterInTypeDescription
addresspath, requiredstringExample: 8.8.8.8.
fieldsquerystringComma-separated dotted paths to keep, e.g. geo.country.code,connection.ip. Unknown paths are left out.
langquerystring, one of en, de, es, fr, ja, pt-BR, ru, zh-CN, default enLanguage of continent, country, region and city names. Falls back to English where a name is missing.
hostnamequeryboolean, default falseAdd connection.hostname, the reverse DNS (PTR) name. Adds up to a second.
formatquerystring, one of json, text, default jsontext returns one field as plain text; it needs fields with exactly one single-value path.
prettyqueryboolean, default falseIndent the JSON and sort its keys
callbackquerystringJSONP callback name (letters, digits, _, $ and .)
StatusMeaningContent
200Lookup resultapplication/json (Lookup), text/plain
400Errorapplication/json (Errors)
403Errorapplication/json (Errors)

POST /v2/lookup/batch/

Look up up to 100 addresses at once (token required). The body is a JSON array of addresses, {"ips": [...]}, or plain text with addresses separated by commas, spaces or new lines. Results come back in the same order. An invalid address gets an errors item instead of failing the whole request. Every address counts as one lookup.

Auth: bearer, query (a token is required; the spec also lists none). Operation id: lookupBatch.

ParameterInTypeDescription
fieldsquerystringComma-separated dotted paths to keep, e.g. geo.country.code,connection.ip. Unknown paths are left out.
langquerystring, one of en, de, es, fr, ja, pt-BR, ru, zh-CN, default enLanguage of continent, country, region and city names. Falls back to English where a name is missing.
prettyqueryboolean, default falseIndent the JSON and sort its keys

Request body (required):

  • application/json: an array of string (at most 100), or an object with ips (array of string (at most 100)). Example: ["8.8.8.8","1.1.1.1"]
  • text/plain: string. Example: "8.8.8.8\n1.1.1.1"
StatusMeaningContent
200One result per address, in request orderapplication/json
400Errorapplication/json (Errors)
401Errorapplication/json (Errors)
403Errorapplication/json (Errors)

GET /v2/ip/

Your IP address and nothing else. Plain text by default. Use ipv4.host.sh to get your IPv4 address on a dual-stack connection.

Auth: none. Operation id: myIp.

ParameterInTypeDescription
formatquerystring, one of text, json
StatusMeaningContent
200The caller's addresstext/plain, application/json

Schemas

Name

FieldTypeDescription
idinteger or null
codestring or null
namestring or null

Lookup

FieldTypeDescription
geoobject
geo.continentobject
geo.continent.idinteger or null
geo.continent.codestring or null
geo.continent.namestring or null
geo.countryobject
geo.country.is_euboolean
geo.country.flagstring or null
geo.country.calling_codestring or null
geo.country.capitalstring or null
geo.country.tldstring or null
geo.country.currencyobject or null
geo.country.currency.codestring
geo.country.currency.namestring
geo.country.currency.symbolstring or null
geo.country.idinteger or null
geo.country.codestring or null
geo.country.namestring or null
geo.subdivisionobject
geo.subdivision.idinteger or null
geo.subdivision.codestring or null
geo.subdivision.namestring or null
geo.cityobject
geo.city.idinteger or null
geo.city.namestring or null
geo.postal_codestring or null
geo.latitudenumber or null
geo.longitudenumber or null
geo.radiusinteger or nullAccuracy radius in km
geo.timezoneobject
geo.timezone.namestring or null
geo.timezone.offsetinteger or nullMinutes behind UTC, like JavaScript getTimezoneOffset() (UTC-5 is 300)
geo.timezone.utc_offsetstring or null
geo.timezone.is_dstboolean or null
geo.timezone.current_timestring or null
connectionobject
connection.ipstring
connection.versioninteger, one of 4, 6
connection.bogonbooleanPrivate, reserved or otherwise not routable
connection.hostnamestring or nullOnly with hostname=1
connection.typestring or null
connection.ispobject
connection.isp.asninteger or null
connection.isp.asostring or nullAS organization
connection.isp.namestring or null
connection.isp.organizationstring or null
connection.isp.mccstring or nullMobile country code (mobile carriers)
connection.isp.mncstring or nullMobile network code (mobile carriers)
connection.anonymityobjectWhether the address is in a known network of each kind. Every score is from 0 to 1 in steps of 1/16: 0 means the address is not listed, and any score above 0 is a hit. A higher score means more, or more certain, evidence for that kind; it is not a probability. On api.host.sh the tor, vpn, proxy, dch, cdn and bot lists are updated every 6 hours.
connection.anonymity.torobjectTor exit nodes (1 for a listed exit).
connection.anonymity.tor.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.anonymity.vpnobjectServers of commercial VPN services, as their operators publish them, and ranges known to be VPN exits. Cloudflare WARP (and Zero Trust) egress scores 0.5, because it also carries ordinary users of a privacy app and companies' traffic. Apple iCloud Private Relay is not VPN and scores 0.
connection.anonymity.vpn.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.anonymity.proxyobjectPublic open proxies, from lists that test them every hour or so (a listed proxy scores 0.75 or more). About half of them are compromised home or mobile devices, so treat a hit as a signal, not proof, and don't block home users on it alone.
connection.anonymity.proxy.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.anonymity.dchobjectHosting and data center ranges: cloud, VPS and dedicated server providers. name and url name the provider where it is known. Coverage of IPv6 hosting space is lower than of IPv4.
connection.anonymity.dch.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.anonymity.dch.namestring or nullName of the network, organization, provider or crawler where known
connection.anonymity.dch.urlstring or nullIts website, where known
connection.anonymity.cdnobjectCDN edge ranges. name and url name the CDN.
connection.anonymity.cdn.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.anonymity.cdn.namestring or nullName of the network, organization, provider or crawler where known
connection.anonymity.cdn.urlstring or nullIts website, where known
connection.anonymity.botobjectRanges that search engines, AI crawlers and monitoring services publish for their crawlers. name and url name the crawler, useragent the token in its User-Agent. A hit means the address belongs to that crawler; check the User-Agent too, a browser from the same range is not the crawler.
connection.anonymity.bot.useragentstring or null
connection.anonymity.bot.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.anonymity.bot.namestring or nullName of the network, organization, provider or crawler where known
connection.anonymity.bot.urlstring or nullIts website, where known
connection.anonymity.scraperobjectLegacy data that is not maintained; currently empty, so 0 for every address.
connection.anonymity.scraper.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.anonymity.ddosobjectLegacy data that is not maintained; currently empty, so 0 for every address.
connection.anonymity.ddos.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.usageobjectScores (0 to 1, as for anonymity) for com, org, edu, lib, gov, mil, isp and mob networks, with name and url where known. Legacy data that has not been updated since 2023: gov, lib, mil and org may be outdated, and com, edu, isp and mob are currently empty (0 for every address).
connection.usage.comobjectCommercial networks
connection.usage.com.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.usage.com.namestring or nullName of the network, organization, provider or crawler where known
connection.usage.com.urlstring or nullIts website, where known
connection.usage.orgobjectNon-profit organizations
connection.usage.org.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.usage.org.namestring or nullName of the network, organization, provider or crawler where known
connection.usage.org.urlstring or nullIts website, where known
connection.usage.eduobjectEducational institutions
connection.usage.edu.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.usage.edu.namestring or nullName of the network, organization, provider or crawler where known
connection.usage.edu.urlstring or nullIts website, where known
connection.usage.libobjectLibraries
connection.usage.lib.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.usage.lib.namestring or nullName of the network, organization, provider or crawler where known
connection.usage.lib.urlstring or nullIts website, where known
connection.usage.govobjectGovernment
connection.usage.gov.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.usage.gov.namestring or nullName of the network, organization, provider or crawler where known
connection.usage.gov.urlstring or nullIts website, where known
connection.usage.milobjectMilitary
connection.usage.mil.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.usage.mil.namestring or nullName of the network, organization, provider or crawler where known
connection.usage.mil.urlstring or nullIts website, where known
connection.usage.ispobjectInternet service providers
connection.usage.isp.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.usage.isp.namestring or nullName of the network, organization, provider or crawler where known
connection.usage.isp.urlstring or nullIts website, where known
connection.usage.mobobjectMobile networks
connection.usage.mob.scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
connection.usage.mob.namestring or nullName of the network, organization, provider or crawler where known
connection.usage.mob.urlstring or nullIts website, where known
user_agentstring
clientobject
osobject
deviceobject

Score

FieldTypeDescription
scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit

NamedScore

FieldTypeDescription
scorenumber, 0 to 1 in steps of 0.06250 is not listed; any score above 0 is a hit
namestring or nullName of the network, organization, provider or crawler where known
urlstring or nullIts website, where known

Errors

FieldTypeDescription
errorsarray of object
errors[].codeinteger
errors[].messagestring
errors[].reasonstring
errors[].detailstring

This page as Markdown: /docs/openapi/index.md