Free API - Inspirational quotes JSON with code examples

The following API endpoint returns an array of inspirational quotes in JSON format

Quotes Free API

You’re welcome to use it for your side projects to the HTTP GET request and display the results.

Usage examples:

JavaScript: Fetch API

fetch("https://type.fit/api/quotes")
  .then(function(response) {
    return response.json();
  })
  .then(function(data) {
    console.log(data);
  });

JQuery:

const settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://type.fit/api/quotes",
  "method": "GET"
}

$.ajax(settings).done(function (response) {
  const data = JSON.parse(response);
  console.log(data);
});

Demo React application: https://quotes-react.netlify.app
Github repo: https://github.com/ssokurenko/quotes-react-app

37 Likes

This is exactly what I was looking for! Thank you.

5 Likes

Thank you for this!!!

4 Likes

Is there a way to get only a certain number of quotes in the request?

3 Likes

Thank you for this!! API is gone tho, was working fine yest, it is now a keyboard typing practice web application :confused:

1 Like

Hi @AngieBR, thanks for your interest and reporting the issue.
API restored, please check https://type.fit/api/quotes
The service was moved to another CDN provider (Cloudflare).

1 Like

Hi @ab91, sure, you’re welcome )

1 Like

Hi @dangerpwnd, sure, you’re welcome!
Please post here where do you use those quotes. Cheers

1 Like

Please post here where do you use those quotes. Cheers

Hi @Vlad246, thanks for your interest.
Currently parametrised requests are not supported. The endpoint works as is.

1 Like

Thank you so much for fixing the issue :slight_smile: You’re a great contribution to my learning :smiley:

Sure, @AngieBR, you’re welcome.
Please share a link here, where do you use this API.

Sounds good, I am finishing up a Medium post discussing the project this weekend, I will reply back with the link

1 Like

Is this API site down ? I was using it earlier for a fun project.

1 Like

Hey @SergeyWebPro I’m currently using this API with a python script that builds an image using one of the quotes, selected at random, and posts the image in an AppData folder for Outlook. This allows me to have new inspirational quotes in the signature of my emails everyday. Thanks again!

1 Like

Hi @caz, good to know you use it for a fun project.
Just checked, the API is up and running https://type.fit/api/quotes

Out of curiosity…

I am seeing the following console error when making the call from my app:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://type.fit/api/quotes. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)

My research suggests that this is due to a security feature on the server side, one that is not able to bypassed outside of a hackier use of jsonp. However, I can still retrieve the resource by just pasting the URL in my browser…which makes me think I am doing something wrong here…

Thank you for having this available at all, but was curious as to if this was intentional?

2 Likes

Hi @ab91 thanks for reporting that.
I’ve recently added Cloudflare support, the original header settings were overwritten.
You’re right the issue is caused by CORS: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers

I’ve just updated the header to allow requests from other domains. Please check.

1 Like

I’ve also been experiencing the same behaviour this morning…

I tried using the API today too, however I also have the same problem.