Loripsum
DevelopmentGenerate 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 tagshttp://loripsum.net/api/html
: To generate formatted HTML text
Both endpoints accept the same parameters:
type
: Type of text to generate:short
,medium
,long
, orverylong
(default ismedium
)p
: Number of paragraphs to generatedecorate
: Add HTML decoration:yes
orno
(default isno
)link
: Add anchor links to the text:yes
orno
(default isno
)ul
: Add unordered list to the text:yes
orno
(default isno
)ol
: Add ordered list to the text:yes
orno
(default isno
)dl
: Add description list to the text:yes
orno
(default isno
)bq
: Add blockquotes to the text:yes
orno
(default isno
)code
: Add code to the text:yes
orno
(default isno
)headers
: Add headers to the text:yes
orno
(default isno
)allcaps
: Use ALL CAPS for the text:yes
orno
(default isno
)prude
: Use safe-for-work text:yes
orno
(default isno
)
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:
fetch('http://loripsum.net/api?type=short&decorate=yes')
.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:
fetch('http://loripsum.net/api/html?ol=3&headers=yes')
.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!