protected function buildUrl($type, $value)
    {
        $type = trim(strtolower($type));

        if (!in_array($type, ["ip", "email", "username"])) {
            throw new \InvalidArgumentException("Type of " . $type . " is not supported by the API");
        }

        $url = $this->baseApiUrl . "?";
        $url .= $type . "=";
        $url .= urlencode($value);

        // If Tor nodes are not allowed, add it as a flag.
        if (!$this->allowTorNodes) $url .= "&notorexit";


        return $url . "&f=json";
    }