An API framework for newsapi.org with Swift.
- Swift5.5+
.package(url: "https://github.com/mtfum/NewsAPI.git", from: "0.1.0")
import NewsAPI
let client = NewsAPI(apiKey: "YOUR_API_KEY")
let articles = try await client.getSources(
sources: [String] = [], // abc-news, bbc-news, etc...
query: String? = nil,
category: NewsSourceCategory? = nil,
language: Language = Language.en
)
let articles = try await client.search(
query: "",
sources: [String] = [],
sortBy: SortBy? = nil, // relevancy, popularity, publishedAt
language: Language? = nil
)
let articles = try await client.getTopHeadlines(
category: NewsSourceCategory? = nil,
language: Language? = nil,
country: Country? = nil
)