{"id":13694090,"url":"https://github.com/lucaslimapoa/NewsAPISwift","last_synced_at":"2025-05-03T01:31:14.189Z","repository":{"id":62449006,"uuid":"92892070","full_name":"lucaslimapoa/NewsAPISwift","owner":"lucaslimapoa","description":"NewsAPISwift is a Swift client for News API V2, a service that provides breaking news headlines, and search for articles from over 30,000 news sources and blogs.","archived":false,"fork":false,"pushed_at":"2018-06-28T16:19:10.000Z","size":410,"stargazers_count":26,"open_issues_count":2,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T05:22:31.335Z","etag":null,"topics":["cocoapods","ios","newsapi","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucaslimapoa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-31T01:36:14.000Z","updated_at":"2025-03-28T17:53:05.000Z","dependencies_parsed_at":"2022-11-01T23:18:00.884Z","dependency_job_id":null,"html_url":"https://github.com/lucaslimapoa/NewsAPISwift","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaslimapoa%2FNewsAPISwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaslimapoa%2FNewsAPISwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaslimapoa%2FNewsAPISwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaslimapoa%2FNewsAPISwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucaslimapoa","download_url":"https://codeload.github.com/lucaslimapoa/NewsAPISwift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252130387,"owners_count":21699079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","ios","newsapi","swift"],"created_at":"2024-08-02T17:01:24.052Z","updated_at":"2025-05-03T01:31:13.145Z","avatar_url":"https://github.com/lucaslimapoa.png","language":"Swift","funding_links":[],"categories":["News"],"sub_categories":["News API"],"readme":"# NewsAPISwift\n\n[![CI Status](http://img.shields.io/travis/lucaslimapoa/NewsAPISwift.svg?style=flat)](https://travis-ci.org/lucaslimapoa/NewsAPISwift)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Version](https://img.shields.io/cocoapods/v/NewsAPISwift.svg?style=flat)](http://cocoapods.org/pods/NewsAPISwift)\n[![License](https://img.shields.io/cocoapods/l/NewsAPISwift.svg?style=flat)](http://cocoapods.org/pods/NewsAPISwift)\n[![Platform](https://img.shields.io/cocoapods/p/NewsAPISwift.svg?style=flat)](http://cocoapods.org/pods/NewsAPISwift)\n[![codecov](https://codecov.io/gh/lucaslimapoa/NewsAPISwift/branch/master/graph/badge.svg)](https://codecov.io/gh/lucaslimapoa/NewsAPISwift)\n[![codebeat badge](https://codebeat.co/badges/bf6f15c8-5844-4d0b-85ff-0e50d1c51176)](https://codebeat.co/projects/github-com-lucaslimapoa-newsapiswift-master)\n\nNewsAPISwift is a Swift client for [News API V2](http://newsapi.org), a service that provides breaking news headlines, and search for articles from over 30,000 news sources and blogs.\n\n## Usage\n\nNewsAPISwift offers two functions to which sources and top headlines can be requested.\n\n### Sources\nThe first functions is used for listing all available sources indexed by the service.\nThree parameters can be passed in order to filter results.\n\n| Parameter | Description |\n| --------- | ----------- |\n| **Category**  | The category you would like to get sources for. The possible values are: `business`, `entertainment`, `general`, `health`, `science`, `sports`, `technology`. *Default: all categories.*|\n| **Language**  | The language you would like to get sources for. The possible values are: `ar`, `de`, `en`, `es`, `fr`, `he`, `it`, `nl`, `no`, `pt`, `ru`, `se`, `ud`, `zh`. *Default: all languages.*|\n| **Country**   | The country you would like to get sources for. To get the full list of supported countries, please head to the official [documentation](https://newsapi.org/docs/endpoints/sources). *Default: all countries.*\n\n#### Example\n\n```swift\nimport NewsAPISwift\n\nlet newsAPI = NewsAPI(apiKey: \"YourKeyHere\")\n\nnewsAPI.getSources(category: .technology, language: .en, country: .us) { result in\n    switch result {\n    case .success(let sources):\n        // Do something with returned sources\n    case .failure(let error):\n        // Handle error\n    }\n}\n```\n\n### Top Headlines\nThe second function is used for listing top headlines. It is possible to request headlines for a specific country, a single or multiple sources, as well as keywords.\n\nTo get a full list of supported parameters, check the official [documentation](https://newsapi.org/docs/endpoints/sources) for the service.\n\n#### Example\n\nTop Headlines about the weather:\n```swift\nimport NewsAPISwift\n\nlet newsAPI = NewsAPI(apiKey: \"YourKeyHere\")\n\nnewsAPI.getTopHeadlines(q: \"weather\") { result in\n    switch result {\n    case .success(let headlines):\n        // Do something with returned headlines\n    case .failure(let error):\n        // Handle error\n    }\n}\n```\n\nTop Headlines from BBC News:\n```swift\nnewsAPI.getTopHeadlines(sources: [\"bbc-news\"]) { result in\n    switch result {\n    case .success(let headlines):\n        // Do something with returned headlines\n    case .failure(let error):\n        // Handle error\n    }\n}\n\n```\n\nTop Headlines from the US about technology:\n```swift        \nnewsAPI.getTopHeadlines(category: .technology, country: .us) { result in\n    switch result {\n    case .success(let headlines):\n        // Do something with returned headlines\n    case .failure(let error):\n        // Handle error\n    }\n}\n\n```\n\nIt is also possible to limit the number of articles returned by passing the *pageSize* parameter. Since there could be more results, pagination is also possible.\n\n```swift\nnewsAPI.getTopHeadlines(pageSize: 20, page: 1) { result in\n    switch result {\n    case .success(let headlines):\n        // Do something with returned headlines\n    case .failure(let error):\n        // Handle error\n    }\n}\n\n```\n\n## Example Application\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first. Then, open **Example.xcworkspace** and run the project.\n\n## Installation\n\n#### CocoaPods\nCocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```\n$ gem install cocoapods\n```\n\nTo integrate NewsAPISwift into your Xcode project using CocoaPods, specify it in your Podfile:\n\n```ruby\nplatform :ios, '8.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'NewsAPISwift', '~\u003e 2.0'\nend\n```\n\nThen, run the following command:\n\n```\n$ pod install\n````\n\n#### Carthage\nCarthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with Homebrew using the following command:\n\n```\n$ brew update\n$ brew install carthage\n```\n\nTo integrate NewsAPISwift into your Xcode project using Carthage, specify it in your Cartfile:\n\n```\ngithub \"lucaslimapoa/NewsAPISwift\"\n```\n\nRun the following command to build the framework:\n\n```\ncarthage update\n```\n\nThen, drag the built NewsAPISwift.framework into your Xcode project.\n\n## License\n\nNewsAPISwift is available under the MIT license. See the LICENSE file for more info.\n\n*NOTE: This library and its author are not endorsed by or affiliated with newsapi.org.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaslimapoa%2FNewsAPISwift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucaslimapoa%2FNewsAPISwift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaslimapoa%2FNewsAPISwift/lists"}