CONTOGEN
ContoGen is a lightweight, serverless API that generates descriptive content for any given term using Wikipedia as the source. It is designed to be completely free, requires no API key. The API returns up to 400 words of descriptive content about the term provided by the user.
API ENDPOINT
GET (location)?query=<term>
(location)
means the location of api inside your directory.
Parameters
Name
Type
Description
query
string
The term or keyword to search.
Examples
Request
GET https://yoursite.com/(location of api)?query=Python
Example Response
{
"description": "Python is an interpreted, high-level programming language for general-purpose programming. ..."
}
How it Works
1) The serverless function (contogen.js) receives the query from the user.
2) It calls the Wikipedia REST API to fetch the summary of the term.
3) If the summary is shorter than 400 words, it fetches the full page content via the Wikipedia action API.
4) The description is truncated to 400 words for consistency.
5) The API returns the description in JSON format.
Frontend Usage
<input id="queryInput" type="text" placeholder="Enter a term">
<button onclick="callAPI()">Get Description</button>
<div id="output"></div>
<script>
async function callAPI() {
const query = document.getElementById("queryInput").value.trim();
const res = await fetch(`location of api?query=${encodeURIComponent(query)}`);
const data = await res.json();
document.getElementById("output").textContent = data.description;
}
</script>
Change the "location of api"
to the actual location of api inside your directory.
View on Github