API for AlwaysN (Free as per license)

LICENSE

Endpoint: https://n.inrify.com/u-api.php?query=(question)

Description: This API provides information based on user queries. It supports simple interactions, Wikipedia information retrieval, and basic conversational responses.

Usage:

Send a GET request to the endpoint with the parameter query containing the user's text input.

Example Request:

GET https://n.inrify.com/u-api.php?query=hello

Response:

If the query is a greeting, confirmation, or a simple action, the API responds accordingly. If the query is a capability question, it fetches information from Wikipedia or a predefined answer file.

Example Response:

Hello! How can I help you?

Supported Queries:

  • Greetings: "hello", "hi"
  • Confirmations: "ok"
  • Actions: "doing"
  • Capability Question: "what can you do for me?"

Error Handling:

  • If no valid query is provided, the API returns an "Invalid request" message.
  • If no response is available for the given query, it returns an "Error: No response available" message.

Important Notes:

  • Cross-Origin Resource Sharing (CORS) is enabled, allowing requests from any origin.
  • The response is in HTML format with UTF-8 encoding.
  • The API checks a predefined answer file (ans.php) first before querying Wikipedia for information.
  • The Wikipedia API is used to fetch and summarize information related to the user's query.

Disclaimer:

This API is provided by iNRiFy.com, Inc. for informational purposes. It may not cover all queries, and the accuracy of information depends on external sources, such as Wikipedia. Use at your own discretion. iNRiFy.com, Inc. holds no responsibility for the content retrieved by this API. By using this API or AlwaysN, You agree all policies of iNRiFy.

Sample Javascript code:


              function simulateChat() {
              var userInput = document.getElementById("query").value;
              var chatBox = document.getElementById("chatBox");

              if (userInput.trim() !== "") {
              appendMessage("user-message", "You: " + userInput);
              document.getElementById("query").value = ""; // Clear the input field

              var xhr = new XMLHttpRequest();
               xhr.onreadystatechange = function () {
              if (xhr.readyState == 4 && xhr.status == 200) {
              var aiResponse = xhr.responseText;
            appendMessage("ai-message", "◉ " + aiResponse);
                            }
                        };

           // Corrected URL syntax here
                 xhr.open("GET",
                "https://n.inrify.com/u-api.php?query="
                + encodeURIComponent(userInput), true);
                   xhr.send();
                    } else {}
                }

                function appendMessage(className, message) {
                  var chatBox = document.getElementById("chatBox");
                  var newMessage = document.createElement("div");
                  newMessage.className = "message " + className;
                  newMessage.textContent = message;
                  chatBox.appendChild(newMessage);
                  chatBox.scrollTop = chatBox.scrollHeight; // Auto-scroll to the bottom
                }
            

To check the code, click here

Feel free to reach out if you have any questions or need further assistance!


Acknoledgements