Fortune Cookie API
Introducing the Fortune Cookie API, a fun and engaging way to deliver random messages of wisdom, humor, and inspiration to your users. Easily integrate this API into your website, application, or service to enhance user engagement with spontaneous, thought-provoking fortunes.
Step by Step Fortune Cookie API Postman Testing Integration
Step by Step Fortune Cookie API Postman Testing Integration
API Endpoint For English
POST https://astroapi-5.divineapi.com/api/v2/fortune-cookieGuide: If you only need English, use this endpoint.
API Endpoint for other languages
POST https://astroapi-5-translator.divineapi.com/api/v2/fortune-cookieGuide: If you want the response in any other language use this translator endpoint.
Supported Language Codes
Use the lan field in the request body to specify the desired response language.
Supported Reference Article:
https://support.divineapi.com/general-api-support/translating-apis-into-a-different-language
| Code | Language |
|---|---|
| en | English |
| hi | Hindi |
| zh | Chinese |
| ja | Japanese |
| ar | Arabic |
| ru | Russian |
| pt | Portuguese |
| es | Spanish |
| fr | French |
| de | German |
| it | Italian |
| nl | Dutch |
| pl | Polish |
| tr | Turkish |
| uk | Ukrainian |
| hu | Hungarian |
| gr | Greek |
| bn | Bengali |
| ma | Marathi |
| tm | Tamil |
| tl | Telugu |
| ml | Malayalam |
| kn | Kannada |
| ta | Filipino/Tagalog |
| bah | Indonesian |
Guide: Update translation settings using the DivineAPI Translator.
Headers
| Name | Type | Description |
|---|---|---|
| Authorization* | String | Your API Access Token. Example: Bearer {token} |
Request Body
| Name | Type | Description |
|---|---|---|
| api_key* | String | Your DivineAPI key available on your developer dashboard. |
| lan | String | Language code as per the table above. Default is en. |
200: OK Successful
{
"success": 1,
"data": {
"prediction": {
"result": "Your next journey will take you to a place of peace and joy."
}
}
}Example Code Implementations
Below are example implementations in various programming environments.
cURL
curl --location 'https://astroapi-5.divineapi.com/api/v2/fortune-cookie' \
--header 'Authorization: Bearer {Your Auth Token}' \
--form 'api_key="{Your API Key}"' \
--form 'lan="en"'NodeJS
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://astroapi-5.divineapi.com/api/v2/fortune-cookie',
'headers': {
'Authorization': 'Bearer {Your Auth Token}'
},
formData: {
'api_key': '{Your API Key}',
'lan': 'en'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});JavaScript jQuery AJAX
var form = new FormData();
form.append("api_key", "{Your API Key}");
form.append("lan", "en");
var settings = {
"url": "https://astroapi-5.divineapi.com/api/v2/fortune-cookie",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Bearer {Your Auth Token}"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});Python
import requests
url = "https://astroapi-5.divineapi.com/api/v2/fortune-cookie"
payload = {'api_key': '{Your API Key}',
'lan': 'en'}
headers = {
'Authorization': 'Bearer {Your Auth Token}'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)