Need help with SwiftDailyAPI?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

204 Stars 28 Forks MIT License 186 Commits 1 Opened issues


A Swift API framework for ZhiHu's Daily News.

Services available


Need anything else?

Contributors list

No Data


Build Status CocoaPods Compatible Carthage Compatible

An API framework for ZhiHu's Daily News, built in Swift. It is powering my open source App Swift-ZHI which is a newsreader App built for ZhiHu's Daily News.


  • iOS 8.0+ / Mac OS X 10.9+
  • Xcode 7.2 +


Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks (10.9).


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

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build SwiftDailyAPI 2.0.0+.

To integrate SwiftDailyAPI into your Xcode project using CocoaPods, specify it in your

platform :ios, '8.0'

pod 'SwiftDailyAPI', '~> 2.0'

Then, run the following command:

$ pod install


Add the following to your Cartfile:

github "NicholasTD07/SwiftDailyAPI" ~> 2.0.0 # Swift 2.1
github "NicholasTD07/SwiftDailyAPI" ~> 1.0.0 # Swift 1.2

Then run

carthage update

Follow the current instructions in Carthage's README for up to date installation instructions.


import SwiftDailyAPI

// Setup var latestDaily: LatestDaily? var daily: Daily? var news: News? var newsExtra: NewsExtra? var shortComments, longComments: Comments?

// Given let newsId = 4772308 let date = NSDate.dateFromString("20150525", format: DailyConstants.dateFormat)! let api = DailyAPI(userAgent: "SwiftDailyAPI_ReadMe")

// When api.latestDaily { latestDailyFromAPI in latestDaily = latestDailyFromAPI print(latestDaily?.news) print(latestDaily?.topNews) }

api.daily(forDate: date) { dailyFromAPI in daily = dailyFromAPI print(daily?.news) } { newsFromAPI in news = newsFromAPI print(news?.newsId) print(news?.title) }

api.newsExtra(newsId) { newsExtraFromAPI in newsExtra = newsExtraFromAPI print(newsExtra?.popularity) print(newsExtra?.comments) }

api.comments(newsId, shortCommentsHandler: { comments in shortComments = comments print(shortComments?.comments) }, longCommentsHandler: { comments in longComments = comments print(longComments?.comments) })

// Then // expect all vars in Setup section to not be nil // code in ReadmeCodeSpecs.swift

This code is tested in ReadmeCodeSpecs.swift. There's also a

part in the spec which expects all the vars in the
to not be nil.



How does SwiftDailyAPI support both Carthage and CocoaPods while having 3rd parity dependencies?

Well, it works like this. Before 2.0.1, I was using Carthage to manage dependencies so Carthage works for version 2.0.0. However, I switched to CocoaPods since 2.0.1 because it's easier to setup, more stable from my experience, also takes less time to install dependencies (Carthage has one extra build step) and Travis has caching for CocoaPods.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.