A collection of quotes, fortunes, anecdotes, and quips. Get new quotes everyday on facebook, twitter, and tumblr.

API

Introduction

iheartquotes provides an interface for easily pulling a random quote from a database of Unix fortune files. If all you want is the data then you should go find the fortune files (try freshmeat). If what you want is to easily put a dynamic quote on your webpage or in your login script then read on.

Examples

#1. Show Random Fortune When You Login

Put this in your .bash_profile or other login startup script. This will retrieve a random fortune from the iheartquotes server or quickly timeout if you're not online. OSX users will probably want to substitute 'curl --max-time 3' for the wget command.

alias getfortune='wget --timeout=3 -O - -q'
alias fortune='getfortune http://www.iheartquotes.com/api/v1/random'
alias myfortune='getfortune http://www.iheartquotes.com/api/v1/random?source=joel_on_software+paul_graham+prog_style
myfortune

Show Random Fortune On Your Website

Cut and paste this HTML into your website. There's an example of what it looks like on my blog.

 <iframe width="230" 
  height="165"
  frameborder="0"
  scrolling="no"       
  src="http://iheartquotes.com/api/v1/random?format=html&max_lines=4&max_characters=320&width=225&height=165">
<a href="http://iheartquotes.com/fortune/random">Random Quote</a>
</iframe>  

I put this code in the sidebar of my blog.

Documentation

The API has a single REST method. Call the URI below to access the API and pass in any of the options as query string parameters.

http://www.iheartquotes.com/api/v1/random

Standard Options

format: return the result 'text', 'html', or 'json' format. The default is text.

max_lines: maximum number of lines in the quote.

min_lines: minimum number of lines in the quote.

max_characters: maximum number of characters in the quote.

min_characters: minimum number of characters in the quote.

source: pulls quotes from one of the sources listed. Multiple sources should be space or "+" separated, ex: calvin+xfiles

Valid Sources

From geek: esr humorix_misc humorix_stories joel_on_software macintosh math mav_flame osp_rules paul_graham prog_style subversion

From general: 1811_dictionary_of_the_vulgar_tongue codehappy fortune liberty literature misc murphy oneliners riddles rkba shlomif shlomif_fav stephen_wright

From pop: calvin forrestgump friends futurama holygrail powerpuff simon_garfunkel simpsons_cbg simpsons_chalkboard simpsons_homer simpsons_ralph south_park starwars xfiles

From religious: bible contentions osho

From scifi: cryptonomicon discworld dune hitchhiker

Formatting Options

show_permalink: show the quote's permalink at the bottom of the text by default. Turn this off with "false" or "0".

show_source: show the quote's source at the bottom of the text by default. Turn this off with "false" or "0".

font_family:Render the text in the specified font-family.

font_color: Render the text in the specified font color.

width: The width of the box to render the quote in.

height: The height of the box to render the quote in.