Filter quotes by author and language using the API.
With Echoes API, you can filter quotes based on various criteria. This guide will show you how to filter quotes by author, language, and other parameters using the API.
To get quotes in a specific language, you can use the `lang` parameter:
fetch('https://echoes.soferity.com/api/quotes/random?lang=en')
.then(response => response.json())
.then(data => console.log(data));
For multiple languages, specify them as comma-separated:
fetch('https://echoes.soferity.com/api/quotes/random?lang=en,fr')
.then(response => response.json())
.then(data => console.log(data));
To get quotes from a specific author, you can use the `author` parameter:
fetch('https://echoes.soferity.com/api/quotes/random?author=Einstein')
.then(response => response.json())
.then(data => console.log(data));
Author name doesn't need an exact match; partial matching works too.
For multiple authors:
fetch('https://echoes.soferity.com/api/quotes/random?author=Einstein,Gandhi')
.then(response => response.json())
.then(data => console.log(data));
To filter by both language and author, use both parameters:
fetch('https://echoes.soferity.com/api/quotes/random?lang=en&author=Einstein')
.then(response => response.json())
.then(data => console.log(data));
When listing all quotes, you can use pagination parameters:
fetch('https://echoes.soferity.com/api/quotes?page=2&perPage=20')
.then(response => response.json())
.then(data => console.log(data));
- page: Page number (default: 1)
- perPage: Number of quotes per page (default: 10, maximum: 100)