Accessing Jibber AI (Rapid API) using JavaScript
To access RapidAPI from JavaScript, you can use the Fetch API or a HTTP client library such as Axios or Request.
Here are the basic steps to get started:
NOTE: For production, you should not expose the key by making the call from your front end website as the key could be discovered. These calls would typically be made by a back-end process (E.g. Node)
Here's an example using the Fetch API:
async function analyzeText(text) {
const body = {
"features": {
"sentiment": true,
"keyword": true,
"pii": true,
"entities": true,
"summary": true
},
"text": text
}
const response = await fetch('https://jibber-analyzer.p.rapidapi.com/en/analyze', {
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-RapidAPI-Host": "jibber-analyzer.p.rapidapi.com",
"X-RapidAPI-Key": "your-rapid-api-key"
},
body: JSON.stringify(body)
});
if (response.ok) {
let responseJson = await response.json();
return responseJson
}
throw new Error(`HTTP error! status: ${response.status}`);
}
analyzeText("My name is Julia Peach and I live in Paris.").then(responseJson => {
console.log(JSON.stringify(responseJson, null, 2));
});
In the above example, replace your-rapid-api-key with your RapidAPI key.
For other languages, change the /en/ in the Uri to the language of choice: