{
  "openapi": "3.1.0",
  "info": {
    "title": "FernTool Network API",
    "version": "0.3.0",
    "description": "Free network API: your IP, IP geolocation with timezone and VPN/Tor/datacenter flags, batch lookup, RDAP WHOIS, DNS, reverse DNS and subnet calculator. No key. CORS *. Please keep under ~40 network lookups/minute."
  },
  "servers": [
    {
      "url": "https://www.ferntool.com"
    }
  ],
  "paths": {
    "/ip": {
      "get": {
        "operationId": "getMyIpText",
        "summary": "Your IP as plain text",
        "responses": {
          "200": {
            "description": "IP",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/json": {
      "get": {
        "operationId": "getMyIp",
        "summary": "Your IP with ISP/ASN/location",
        "responses": {
          "200": {
            "description": "Info",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ip": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "isp": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "city": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "region": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "country": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "timezone": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "colo": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "asn": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "version": {
                      "type": "integer"
                    },
                    "latitude": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "longitude": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/batch": {
      "post": {
        "operationId": "batchLookupIp",
        "summary": "Look up 1-100 IPs",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ips": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 100
                  }
                },
                "required": [
                  "ips"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Bad request"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/api/whois/{query}": {
      "get": {
        "operationId": "whoisLookup",
        "summary": "RDAP WHOIS for a domain, IP or ASN",
        "parameters": [
          {
            "name": "query",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query"
          },
          "502": {
            "description": "Upstream RDAP error"
          }
        }
      }
    },
    "/api/dns/{domain}": {
      "get": {
        "operationId": "dnsLookup",
        "summary": "DNS records via Cloudflare DoH",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "Comma-separated: A,AAAA,MX,TXT,NS,CNAME,SOA",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Records",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid domain/type"
          }
        }
      }
    },
    "/api/reverse-dns/{ip}": {
      "get": {
        "operationId": "reverseDns",
        "summary": "PTR lookup",
        "parameters": [
          {
            "name": "ip",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hostnames",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid IP"
          }
        }
      }
    },
    "/api/subnet": {
      "get": {
        "operationId": "subnetCalc",
        "summary": "IPv4/IPv6 subnet calculator",
        "parameters": [
          {
            "name": "cidr",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Subnet",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid CIDR"
          }
        }
      }
    },
    "/api/ip/{ip}": {
      "get": {
        "operationId": "lookupIp",
        "summary": "Validate and look up an IP",
        "parameters": [
          {
            "name": "ip",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Valid IP",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid IP"
          }
        }
      }
    }
  }
}
