# Using API for the Random Quote Machine Challenge

**URL:** <https://forum.freecodecamp.org/t/using-api-for-the-random-quote-machine-challenge/133142>\
**Category:** General\
**Created:** [June 30, 2017, 9:41am UTC](https://forum.freecodecamp.org/t/using-api-for-the-random-quote-machine-challenge/133142 "2017-06-30T09:41:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattr12](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mattr12](https://forum.freecodecamp.org/u/mattr12)\
**Post date:** [June 30, 2017, 9:41am UTC](https://forum.freecodecamp.org/t/using-api-for-the-random-quote-machine-challenge/133142/1 "2017-06-30T09:41:21Z")

</div>

I am not sure how to use API with JSON. I’ve looked back at the previous exercises and I am still kind of lost.

I understand how to use the “on click” event function, I am pretty sure I know how to declare a string var and just += to it. I also found a free quote API, but I have no idea how to access it.

The API I Googled is here: [https://forismatic.com/en/api/](https://forismatic.com/en/api/)

My Codepen is here: [https://codepen.io/mattr8/full/qjxKQR/](https://codepen.io/mattr8/full/qjxKQR/)

Any help will be appreciated.

---

<div class="post-metadata">

**Author:** ![alightedlamp](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/alightedlamp/32/63336_2.png) [@alightedlamp](https://forum.freecodecamp.org/u/alightedlamp)\
**Post date:** [June 30, 2017, 1:28pm UTC](https://forum.freecodecamp.org/t/using-api-for-the-random-quote-machine-challenge/133142/2 "2017-06-30T13:28:06Z")

</div>

Hello – you can also generate your own quote object directly in your app, and randomly access quotes from there, if you want to build something you’re more personally invested in and avoid the hassle of dealing with an API (until the weather app 🙂).

Otherwise you could use the [jQuery ajax](https://www.sitepoint.com/use-jquerys-ajax-function/) method. So onclick, you’d run the ajax method that takes your API url as an arg, and display something based on success or failure of that request.

---

<div class="post-metadata">

**Author:** ![slowlearner](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/slowlearner/32/161526_2.png) [@slowlearner](https://forum.freecodecamp.org/u/slowlearner)\
**Post date:** [June 30, 2017, 2:51pm UTC](https://forum.freecodecamp.org/t/using-api-for-the-random-quote-machine-challenge/133142/4 "2017-06-30T14:51:54Z")

</div>

Hi, You need to add the jQuery javascript file (Settings/Javascript).  
Also, your the JS pane in your pen is empty.

Here’s another random quote generator. [https://random-quote-generator.herokuapp.com/api/quotes/](https://random-quote-generator.herokuapp.com/api/quotes/)

btw I am also struggling to get getJSON to work for me 😖

Cheers, Rainer

---

<div class="post-metadata">

**Author:** ![slowlearner](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/slowlearner/32/161526_2.png) [@slowlearner](https://forum.freecodecamp.org/u/slowlearner)\
**Post date:** [June 30, 2017, 4:34pm UTC](https://forum.freecodecamp.org/t/using-api-for-the-random-quote-machine-challenge/133142/6 "2017-06-30T16:34:06Z")

</div>

Apologies, my bad. I meant to paste in this https generator:  
[https://random-quote-generator.herokuapp.com/api/quotes/](https://random-quote-generator.herokuapp.com/api/quotes/)  
Thank you for the advice.

---

<div class="post-metadata">

**Author:** ![imvpn22](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/imvpn22/32/115143_2.png) [@imvpn22](https://forum.freecodecamp.org/u/imvpn22)\
**Post date:** [January 9, 2018, 11:55am UTC](https://forum.freecodecamp.org/t/using-api-for-the-random-quote-machine-challenge/133142/7 "2018-01-09T11:55:33Z")

</div>

Is there any API which also returns image url?

---

<div class="post-metadata">

**Author:** ![Kay](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kay/32/116211_2.png) [@Kay](https://forum.freecodecamp.org/u/Kay)\
**Post date:** [February 3, 2018, 7:23am UTC](https://forum.freecodecamp.org/t/using-api-for-the-random-quote-machine-challenge/133142/8 "2018-02-03T07:23:38Z")

</div>

Yea, actually there is.  
[https://source.unsplash.com/](https://source.unsplash.com/)

---

<div class="post-metadata">

**Author:** ![maeri](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/maeri/32/36358_2.png) [@maeri](https://forum.freecodecamp.org/u/maeri)\
**Post date:** [February 22, 2018, 8:33am UTC](https://forum.freecodecamp.org/t/using-api-for-the-random-quote-machine-challenge/133142/9 "2018-02-22T08:33:15Z")

</div>

thanks - that link works out of box 🙂
