Latest 0.1
Homepage https://github.com/omaralbeik/HNClient
License MIT
Platforms ios 8.0, requires ARC
Dependencies AlamofireObjectMapper
Authors

Super easy to use client for Hacker News API

Cocoapods
Platform
Swift
Xcode
MIT

Usage

Get Hacker News items, user profiles, and much more with few lines of code

Items

Fetch a story, comment, job, Ask HN, poll or poll part for a given id:

HNManager.shared.fetchItem(id: 9127232) { item, error in
  // returns an optional HNItem object
}

Users

Fetch user profile and public activity for a given id:

HNManager.shared.fetchUser(id: "jl") { user, error in
  // returns an optional HNUser object
}

Live Data

Fetch max item ID:

HNManager.shared.fetchMaxItemId { id, error in
  // returns the current largest item id
  // example: 9127232
}

Fetch New, Top and Best Stories:

HNManager.shared.fetchNewStoriesIds { ids in
  // returns an array of up to 500 new stories ids
  // example: [ 9127232, 9128437, 9130049, 9130144, 9130064 ]
}

HNManager.shared.fetchTopStoriesIds { ids in
  // returns an array of up to 500 top stories ids
  // example: [ 9127232, 9128437, 9130049, 9130144, 9130064 ]
}

HNManager.shared.fetchBestStoriesIds { ids in
  // returns an array of up to 500 best stories ids
  // example: [ 9127232, 9128437, 9130049, 9130144, 9130064 ]
}

Fetch Ask, Show and Job stories:

HNManager.shared.fetchAskIds { ids, error in
  // returns an array of up to 200 latest Ask HN ids
  // example: [ 9127232, 9128437, 9130049, 9130144, 9130064 ]
}

HNManager.shared.fetchShowIds { ids, error in
  // returns an array of up to 200 latest Show HN ids
  // example: [ 9127232, 9128437, 9130049, 9130144, 9130064 ]
}

HNManager.shared.fetchJobsIds { ids, error in
  // returns an array of up to 200 latest Jobs HN ids
  // example: [ 9127232, 9128437, 9130049, 9130144, 9130064 ]
}

Fetch changed items and profiles:

HNManager.shared.fetchUpdates { items, profiles, error in
  // return arrays of changed items ids and profiles ids
  // items = [ 8423305, 8420805, 8423379, 8422504, 8394339, 8421900, 8420902, 8422087 ],
  // profiles = [ "thefox", "mdda", "plinkplonk", "arram", "MrZongle2", "Bogdanp" ]
}

Structure

Model:

Services:

Hacker News API:

Dependencies:

Requirements:

  • iOS 8.0+
  • Xcode 8.1+
  • Swift 3.0+

Installation

CocoaPods

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

$ gem install cocoapods

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

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

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

Then, run the following command:

$ pod install

Manually

Add the Source folder to your Xcode project.

License

HNClient is released under the MIT license. See LICENSE for details.

Special Thanks

Special thanks to Mert Akengin for starting this initiative and supporting with Data Modeling!

Latest podspec

{
    "name": "HNClient",
    "version": "0.1",
    "summary": "Super easy to use client for Hacker News API",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/omaralbeik/HNClient",
    "authors": {
        "Omar Albeik": "[email protected]"
    },
    "social_media_url": "https://twitter.com/omaralbeik",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": "true",
    "source": {
        "git": "https://github.com/omaralbeik/HNClient.git",
        "tag": "0.1"
    },
    "source_files": "Source/**/*.swift",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    },
    "dependencies": {
        "AlamofireObjectMapper": [
            "~> 4.1"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This