Table of Content

Making request
Endpoints
Objects
Errors and Notices
Code Samples

API Docs

You will get 15 credits daily for free which you can use to fetch data from the API.
Making requests
GET
https://advice-api-smoky.vercel.app/api/advice?apiKey=your_api_key

Endpoints

Random Advice
Note: Advice is cached for 2 seconds. Any repeat-request within 2 seconds will return the same piece of advice.
HTTPS MethodGet
URLhttps://advice-api-smoky.vercel.app/api/advice?apiKey=your_api_key
DescriptionReturns a random advice slip as a slip object
ParametersapiKey    Required.
Advice by ID
HTTPS MethodGet
URLhttps://advice-api-smoky.vercel.app/api/advice/{slip_id}?apiKey=your_api_key
DescriptionIf an advice slip is found with the corresponding {slip_id}, a slip object is returned.
ParametersapiKey    Required.
Searching advice
HTTPS MethodGet
URLhttps://advice-api-smoky.vercel.app/api/advice/search/{query}?apiKey=your_api_key
DescriptionIf an advice slip is found, containing the corresponding search term in {query}, an array of slip objects is returned inside a search object.
ParametersapiKey    Required.

Objects

Slip object
A slip object is a simple piece of advice.
NameType
slip_idintegerThe unique ID of this advice slip.
advicestringThe advice being given.
Search object
A search object contains the results of a slip search query.
NameType
total_resultsintegerTotal number of matching advice slips found.
queryintegerThe search query provided.
slipsstringAn array of slip objects matching the search query.

Error messages

A messages object contains information about the status of the requested API URL.
NameType
typestringThe type of messages. Can be either noticed, warning or error.
textstringThe messages being received.

Code samples for the major languages

<script type="text/javascript">
async function fetchAdviceAPI() {
const api_key = 'your_api_key';
const response = await fetch('https://advice-api-smoky.vercel.app/api/advice?apiKey=' + api_key);
const result = response.json();
return result;
}
const data = fetchAdviceAPI();
console.log(data);
</script>