JSON API

The Bacon Ipsum JSON API is a REST interface for generating meaty lorem ipsum text and can be used by any application. Pass in the following parameters using an HTTPS GET and we’ll return a JSON string array of paragraphs.

Parameters:

  • type: all-meat for meat only or meat-and-filler for meat mixed with miscellaneous ‘lorem ipsum’ filler.
  • paras: optional number of paragraphs, defaults to 5.
  • sentences: number of sentences (this overrides paragraphs)
  • start-with-lorem: optional pass 1 to start the first paragraph with ‘Bacon ipsum dolor sit amet’.
  • format: ‘json’ (default), ‘text’, or ‘html’

Examples:

Some sample jquery code!

$(document).ready(function() 
{
	$("#baconButton").click(function()
	{
		$.getJSON('https://baconipsum.com/api/?callback=?', 
			{ 'type':'meat-and-filler', 'start-with-lorem':'1', 'paras':'3' }, 
			function(baconGoodness)
		{
			if (baconGoodness && baconGoodness.length > 0)
			{
				$("#baconIpsumOutput").html('');
				for (var i = 0; i < baconGoodness.length; i++)
					$("#baconIpsumOutput").append('<p>' + baconGoodness[i] + '</p>');
				$("#baconIpsumOutput").show();
			}
		});
	});
});

Run the sample!

36 Responses to JSON API

  1. Pingback: 5 Fun Lorem Ipsum Generators | Coffee, Code & Cats

  2. Pingback: Promises vs. Callbacks - troublemaker.xyz

  3. Pingback: Sharing Data Components between React and React Native | Shockoe

  4. Pingback: public example apis: GitHub File Free Download

  5. Pingback: boilerplate.react.spa.full server: GitHub File Free Download

  6. Pingback: 8 Fun, Random, and Useless APIs to Tinker With Today | Nordic APIs |

Leave a Reply

Your email address will not be published. Required fields are marked *