Skip to content
/ NewsAPI Public

An unofficial supported Swift client library for accessing News API.

License

Notifications You must be signed in to change notification settings

mtfum/NewsAPI

Repository files navigation

NewsAPI

An API framework for newsapi.org with Swift.

Requirement

  • Swift5.5+

Installation

Swift Package Manager

.package(url: "https://github.com/mtfum/NewsAPI.git", from: "0.1.0")

Usage

Setup

import NewsAPI

let client = NewsAPI(apiKey: "YOUR_API_KEY")

Get Sources

let articles = try await client.getSources(
    sources: [String] = [], // abc-news, bbc-news, etc...
    query: String? = nil,
    category: NewsSourceCategory? = nil,
    language: Language = Language.en
)

Search

let articles = try await client.search(
  query: "",
  sources: [String] = [],
  sortBy: SortBy? = nil, // relevancy, popularity, publishedAt
  language: Language? = nil
)

Top-Headlines

let articles = try await client.getTopHeadlines(
  category: NewsSourceCategory? = nil,
  language: Language? = nil,
  country: Country? = nil
)

About

An unofficial supported Swift client library for accessing News API.

Topics

Resources

License

Stars

Watchers

Forks

Languages