Newsie v0.1.0 Newsie.Providers.CurrentsApi View Source

Client for Currents API

Configuration

Requires :api_key to use.

See Newsie.ProviderConfig for documentation on how to configure providers.

Link to this section Summary

Functions

Get a list of supported categories

Get a list of supported languages.

Get a list of supported regions.

Get latest news for the given language

Search for news articles

Link to this section Functions

Specs

config() :: keyword()
Link to this function

get_supported_categories()

View Source

Specs

get_supported_categories() :: {:error, any()} | {:ok, [String.t()]}

Get a list of supported categories

Link to this function

get_supported_languages()

View Source

Specs

get_supported_languages() :: {:error, any()} | {:ok, [String.t()]}

Get a list of supported languages.

Specs

get_supported_regions() ::
  {:error, any()} | {:ok, %{required(String.t()) => String.t()}}

Get a list of supported regions.

These are mostly ISO country codes, but some are regions like 'ASIA' and 'INT'

Link to this function

latest_news(language \\ "en")

View Source

Specs

latest_news(String.t()) :: {:error, any()} | {:ok, [Newsie.Article.t()]}

Get latest news for the given language

Specs

search(keyword()) :: {:error, any()} | {:ok, [Newsie.Article.t()]}

Search for news articles

Search parameters

  • type (see below)
  • category (see below)
  • language (ISO-639-2 code)
  • keywords
  • country (ISO-3166 code)
  • start_date (ISO-8601 timestamp)
  • end_date (ISO-8601 timestamp)

Type

The Currents API provides differnt kinds of content; not just new. The type filter controls the kind of content you want.

  • 1 = news (default)
  • 2 = article
  • 3 = discussion content

Category

  • "regional"
  • "technology"
  • "lifestyle"
  • "business"
  • "general"
  • "programming"
  • "science"
  • "entertainment"
  • "world"
  • "sports"
  • "finance"
  • "academia"
  • "politics"
  • "health"
  • "opinion"
  • "food"
  • "game"

Usage

Newsie.Providers.CurrentsApi.search(language: :en, country: :us, category: "business")