simpLipsum...

...exposes a free restfull API to the web. You can use it to generate lorem ipsum text on demand. To use the api, simply make a GET request to the simpLipsum /api endpoint.

//Using fetch() to make the request:

fetch('https://simplipsum.now.sh/api')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(err => console.log(err))

//This request will return an error 400,
//because no query parameters were supplied.

To receive an usable response, you need to add a query parameter to the fetch like this:

//Adding a query parameter

fetch('https://simplipsum.now.sh/api?paragraphs=2')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(err => console.log(err))

//This fetch request will return an JSON object
//with 2 Paragraphs inside the "text" key.

Every response Object will have the same structure:

//The response object

{
  status: {
    code: 200,
    text: ["Ok"],
    timeStamp: 1585663775104
    },
  req: {
    paragraphs: "2"
    },
  text: "This contains the HTML encoded lorem ipsum text",
  textRaw: "This contains the raw lorem ipsum text",
}

//Code 200 is returend when the request was succesfull.
//Code 400 is returned when not enough parameters are supplied.
//Code 429 is returned when too many request come in at the same time.

There are 5 available query Parameters for you to use.

//Returns the requested amount in full paragraphs.

fetch('https://simplipsum.now.sh/api?paragraphs=[number]')

//Returns the requested amount in full sentences.

fetch('https://simplipsum.now.sh/api?sentences=[number]')

//Returns the requested amount of words.

fetch('https://simplipsum.now.sh/api?words=[number]')

//Returns the requested amount of characters.

fetch('https://simplipsum.now.sh/api?characters=[number]')

//If true, only the HTML formatted text is returned
//without the rest of the response object.

fetch('https://simplipsum.now.sh/api?textOnly=[true / false]')

While you can add multiple query paramters to the query string, only the first of the four different types will have an effect. The rest will be filtered out.

api