Super easy to use client for Hacker News API
Get Hacker News items, user profiles, and much more with few lines of code
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
}
Fetch user profile and public activity for a given id:
HNManager.shared.fetchUser(id: "jl") { user, error in
// returns an optional HNUser object
}
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" ]
}
- This project relies on Hacker News API
- HNClient uses AlamofireObjectMapper for networking and mapping JSON to native objects.
- iOS 8.0+
- Xcode 8.1+
- Swift 3.0+
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
Add the Source folder to your Xcode project.
HNClient is released under the MIT license. See LICENSE for details.
Special thanks to Mert Akengin for starting this initiative and supporting with Data Modeling!