All Projects → NicholasTD07 → Swiftdailyapi

NicholasTD07 / Swiftdailyapi

Licence: mit
A Swift API framework for ZhiHu's Daily News.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftdailyapi

Swiftinstagram
Instagram API client written in Swift
Stars: ✭ 570 (+179.41%)
Mutual labels:  api, cocoapods, carthage
Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (-11.27%)
Mutual labels:  api, rest-api
Co Cart
🛒 CoCart is a flexible, open-source solution to enabling the shopping cart via the REST API for WooCommerce.
Stars: ✭ 198 (-2.94%)
Mutual labels:  api, rest-api
Autoserver
Create a full-featured REST/GraphQL API from a configuration file
Stars: ✭ 188 (-7.84%)
Mutual labels:  api, rest-api
Jikan Rest
The REST API for Jikan
Stars: ✭ 200 (-1.96%)
Mutual labels:  api, rest-api
Bmw Yolov4 Inference Api Cpu
This is a repository for an nocode object detection inference API using the Yolov4 and Yolov3 Opencv.
Stars: ✭ 180 (-11.76%)
Mutual labels:  api, rest-api
Apicheck
The DevSecOps toolset for REST APIs
Stars: ✭ 184 (-9.8%)
Mutual labels:  api, rest-api
Icimulator
Simulate camera functions on iOS Simulator with images, videos, or your MacBook Camera.
Stars: ✭ 177 (-13.24%)
Mutual labels:  cocoapods, carthage
Whatsnewkit
Showcase your awesome new app features 📱
Stars: ✭ 2,329 (+1041.67%)
Mutual labels:  cocoapods, carthage
Swiftyanimate
Composable animations in Swift
Stars: ✭ 194 (-4.9%)
Mutual labels:  cocoapods, carthage
Imagetransition
Library for smooth animation of images during transitions.
Stars: ✭ 195 (-4.41%)
Mutual labels:  cocoapods, carthage
Zhihu zhuanlan apis
知乎专栏API分析
Stars: ✭ 179 (-12.25%)
Mutual labels:  api, zhihu
Proteus
Lean, mean, and incredibly fast JVM framework for web and microservice development.
Stars: ✭ 178 (-12.75%)
Mutual labels:  api, rest-api
Storefront Api
Storefront GraphQL API Gateway. Modular architecture. ElasticSearch included. Works great with Magento1, Magento2, Spree, OpenCart, Pimcore and custom backends
Stars: ✭ 180 (-11.76%)
Mutual labels:  api, rest-api
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-13.24%)
Mutual labels:  cocoapods, carthage
Lumen Microservice
Lumen on Docker - Skeleton project with Nginx, MySQL & PHP 7 | Aws ECS, Google Kubernates, Azure Container Engine
Stars: ✭ 183 (-10.29%)
Mutual labels:  api, rest-api
Tkradarchart
A customizable radar chart in Swift
Stars: ✭ 199 (-2.45%)
Mutual labels:  cocoapods, carthage
Wkcookiewebview
WKWebView with cookie sharing support
Stars: ✭ 171 (-16.18%)
Mutual labels:  cocoapods, carthage
Irldocumentscanner
A drop-in Objective-C ViewController that will Automatically scan a document for you you.
Stars: ✭ 172 (-15.69%)
Mutual labels:  cocoapods, carthage
Api
API that uncovers the technologies used on websites and generates thumbnail from screenshot of website
Stars: ✭ 189 (-7.35%)
Mutual labels:  api, rest-api

SwiftDailyAPI

Build Status codecov.io 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.

Requirement

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

Installation

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

CocoaPods

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 Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'SwiftDailyAPI', '~> 2.0'

Then, run the following command:

$ pod install

Carthage

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.

Usage

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)
}

api.news(newsId) { 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 Then part in the spec which expects all the vars in the Setup to not be nil.

Frameworks

Appendix

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].