Latest 0.0.7
Homepage https://github.com/AppShuttleInc/NewsAPI
License MIT
Platforms ios 8.0
Authors

NewsAPI (Currently in development mode)

CI Status
Version
License
Platform

Features

  • [x] Handle NewsAPI shared session
  • [x] Authenticate API Requests with HTTP headers
  • [x] Get all named sources available
  • [ ] Get all named sources available with query parameters
  • [x] Get top headlines from a single source
  • [x] Get top headlines from multiple sources
  • [ ] Get top headlines with query parameters
  • [ ] Get all articles from a single source
  • [ ] Get all articles from multiple sources
  • [ ] Get all articles with query parameters
  • [ ] Complete Documentation

Requirements

  • iOS 8.0+
  • Xcode 9.0+
  • Swift 4.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate NewsAPI into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!

target '<Your Target Name>' do
pod 'NewsAPI'
end

Then, run the following command:

$ pod install

Usage

First, open your AppDelegate.swift and import NewsAPI.

import NewsAPI

Initialize NewsAPI with your API Key (We recommend doing this in the applicationDidFinishLaunchingWithOptions method).

NewsAPI.provideAPIKey("YourApiKey")

Sources

• All Sources:

NewsAPI.getAllSources { (sources, error) in
    if error == nil && sources != nil {
        print("Sources: (sources)")
    } else {
        print(error?.localizedDescription ?? "Unkown Error")
    }
}

Top Headlines

• From Sources IDs:

NewsAPI.getTopHeadlinesForSourcesIDs(["techcrunch", "techradar"]) { (articles, error) in
    if error == nil && articles != nil {
        print("Articles: (articles)")
    } else {
        print(error?.localizedDescription ?? "Unkown Error")
    }
}

• From NewsAPISource objects:


let newsSourcesArray = [NewsAPISource]()

// Get sources from Sources Endpoint or create a new instance of a NewsAPISource

NewsAPI.getTopHeadlinesForSources(newsSourcesArray) { (articles, error) in
    if error == nil && articles != nil {
        print("Articles: (articles)")
    } else {
        print(error?.localizedDescription ?? "Unkown Error")
    }
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

Juan David Cruz Serrano, [email protected]
Thanks to Jordan & NewsAPI for the support!

License

NewsAPI is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "NewsAPI",
    "version": "0.0.7",
    "summary": "Access worldwide news with NewsAPI iOS Library",
    "description": "Get breaking news headlines, and search for articles from over 5,000 news sources and blogs with our NewsAPI iOS Library",
    "homepage": "https://github.com/AppShuttleInc/NewsAPI",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "AppShuttle.io": "[email protected]"
    },
    "source": {
        "git": "https://github.com/AppShuttleInc/NewsAPI.git",
        "tag": "0.0.7"
    },
    "social_media_url": "https://twitter.com/AppShuttleio",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "NewsAPI/Classes/**/*",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This