Yandex Metrika
All Guides
Beginner

Filtering Quotes

Filter quotes by author and language using the API.

APIFiltering

Filtering Quotes

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.

Filtering by Language

To get quotes in a specific language, you can use the `lang` parameter:

JavaScript
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:

JavaScript
fetch('https://echoes.soferity.com/api/quotes/random?lang=en,fr')
  .then(response => response.json())
  .then(data => console.log(data));

Filtering by Author

To get quotes from a specific author, you can use the `author` parameter:

JavaScript
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:

JavaScript
fetch('https://echoes.soferity.com/api/quotes/random?author=Einstein,Gandhi')
  .then(response => response.json())
  .then(data => console.log(data));

Combining Language and Author

To filter by both language and author, use both parameters:

JavaScript
fetch('https://echoes.soferity.com/api/quotes/random?lang=en&author=Einstein')
  .then(response => response.json())
  .then(data => console.log(data));

Pagination

When listing all quotes, you can use pagination parameters:

JavaScript
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)