getEverything method

Future<List<Article>> getEverything({
  1. String? query,
  2. String? queryInTitle,
  3. String? sources,
  4. String? domains,
  5. String? excludeDomains,
  6. DateTime? from,
  7. DateTime? to,
  8. String? language,
  9. String? sortBy,
  10. int? pageSize,
  11. int? page,
})

Fetches a list of articles based on the provided query parameters.

Optional parameters:

  • query: The search query.
  • queryInTitle: Search for articles with the query term in the title.
  • sources: A comma-separated list of source IDs or domains.
  • domains: A comma-separated list of domains (e.g., bbc.co.uk, techcrunch.com).
  • excludeDomains: A comma-separated list of domains to exclude.
  • from: The earliest date (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss) to retrieve articles from.
  • to: The latest date (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss) to retrieve articles to.
  • language: The language of the articles.
  • sortBy: The order to sort articles in.
  • pageSize: The number of articles per page.
  • page: The page number to retrieve.

Implementation

Future<List<Article>> getEverything({
  String? query,
  String? queryInTitle,
  String? sources,
  String? domains,
  String? excludeDomains,
  DateTime? from,
  DateTime? to,
  String? language,
  String? sortBy,
  int? pageSize,
  int? page,
}) async {
  final String url = Util.buildEverythingUrl(
    query,
    queryInTitle,
    sources,
    domains,
    excludeDomains,
    from,
    to,
    language,
    sortBy,
    pageSize,
    page,
  );
  final dynamic response = await Util.call(
    apiKey: apiKey,
    url: url,
    dataKey: "articles",
  );
  return Article.parseList(response);
}