The Google Books API Client Library for Swift
The supported options:
Add this to Podfile
# Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'GoogleBooksApiClient'
end
$ pod install
Add this to Cartfile
github "google-books/swift-api-client"
$ carthage update
The library makes it simple to call Google Books APIs.
import GoogleBooksApiClient
let session = URLSession.shared
let client = GoogleBooksApiClient(session: session)
let req = GoogleBooksApi.VolumeRequest.List(query: "Google")
let task: URLSessionDataTask = client.invoke(
req,
onSuccess: { volumes in NSLog("\(volumes)" },
onError: { error in NSLog("\(error)") }
)
let authInfo = GoogleBooksApiAuthInfo(apiKey: nil, authToken: "YOUR_AUTH_TOKEN")
let req = GoogleBooksApi.MyLibraryBookshelvesRequest.AddVolume(
shelf: BookshelfId.haveRead,
volumeId: Id("VOLUME_ID"),
authInfo: authInfo
)
let task: URLSessionDataTask = client.invoke(
req,
onSuccess: { volumes in NSLog("\(volumes)" },
onError: { error in NSLog("\(error)") }
)
MIT