Generate Filler Text with Loripsum API

Loripsum is a public API to generate filler text for your web or mobile app. With this API, you can generate random paragraphs, sentences, or words of Lorem Ipsum text. This can be useful for testing web designs, creating mockups, or filling in placeholder text for your app.

To get started with Loripsum API, you need to know the available endpoints and parameters. This API has two main endpoints:

  • http://loripsum.net/api: To generate plain text without HTML tags
  • http://loripsum.net/api/html: To generate formatted HTML text

Both endpoints accept the same parameters:

  • type: Type of text to generate: short, medium, long, or verylong (default is medium)
  • p: Number of paragraphs to generate
  • decorate: Add HTML decoration: yes or no (default is no)
  • link: Add anchor links to the text: yes or no (default is no)
  • ul: Add unordered list to the text: yes or no (default is no)
  • ol: Add ordered list to the text: yes or no (default is no)
  • dl: Add description list to the text: yes or no (default is no)
  • bq: Add blockquotes to the text: yes or no (default is no)
  • code: Add code to the text: yes or no (default is no)
  • headers: Add headers to the text: yes or no (default is no)
  • allcaps: Use ALL CAPS for the text: yes or no (default is no)
  • prude: Use safe-for-work text: yes or no (default is no)

To call Loripsum API from JavaScript, you can use the fetch() method to send an HTTP GET request to the API endpoint. Here’s an example code to generate plain text with Loripsum API:

    .then((response) => response.text())
    .then((data) => console.log(data));

This code will generate a short paragraph with HTML decorations and log the result to the console. You can change the endpoint URL and parameters as needed to generate different types of text.

Here’s another example code to generate formatted HTML text with Loripsum API:

    .then((response) => response.text())
    .then((data) => (document.getElementById('output').innerHTML = data));

This code will generate an ordered list of 3 items with headers and insert the result into an HTML element with ID output. You can modify the code to generate different types of HTML text and insert them into different elements in your web page.

That’s it for this short introduction to Loripsum API. Happy generating!