QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.

Overview

QuoteKit Logo

QuoteKit

Twitter Follow

The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey. It uses the latest async/await syntax for easy access and contains all the APIs like fetching a random quote, all quotes, authors, tags and searching quotes and authors.

Note: This framework is still in beta.

Requirements

As it uses the async/await feature of Swift 5.5, the platforms currently supported are iOS 15.0+, macOS 12.0+, watchOS 8.0+ and tvOS 15.0+. There's a PR merged in Swift language related to back deployment, and the framework will be updated accordingly to support the older OSes.

Installation

To add QuoteKit in your project, the best way is via the Swift Package Manager.

dependencies: [
    .package(url: "https://github.com/rudrankriyam/QuoteKit.git")
]

Usage

The struct QuoteKit contains static methods you can call for fetching the revelant data. For example, to get the list of quotes -

do {
    var quotes: Quotes?
    quotes = try await QuoteKit.quotes()
} catch {
    print(error)
}

The examples given below are similar to the ones in Quotable's README.

Random Quote

Returns a single random Quote object from the /random API.

var randomQuote: Quote?
randomQuote = try await QuoteKit.randomQuote()

You can customise the request by adding query parameters like minimum and maximum length of the quote or the tag associated with it. You can also get a random quote by a specific author(s).

Few examples:

Random Quote with tags "technology" AND "famous-quotes" -

try await QuoteKit.randomQuote(tags: [.technology, .famousQuotes], type: .all)

Random Quote with tags "History" OR "Civil Rights" -

try await QuoteKit.randomQuote(tags: [.history, .civilRights], type: .either)

Random Quote with a maximum length of 50 characters -

try await QuoteKit.randomQuote(maxLength: 150)

Random Quote with a length between 100 and 140 characters -

try await QuoteKit.randomQuote(minLength: 100, maxLength: 140)

Random Quote by the author "Aesop" and "Stephen Hawking" -

try await QuoteKit.randomQuote(authors: ["aesop", "stephen-hawking"])

List Quotes

Returns the Quotes object based on the given queries from the /quotes API. By default, the list contains 20 Quote in one page.

var quotes: Quotes?
quotes = try await QuoteKit.quotes()

Few examples:

Get all quotes with a maximum length of 50 characters -

try await QuoteKit.quotes(maxLength: 150)

Get all quotes with a length between 100 and 140 characters -

try await QuoteKit.quotes(minLength: 100, maxLength: 140)

Get the first page of quotes, with 20 results per page -

try await QuoteKit.quotes(page: 1)

Get the second page of quotes, with 20 results per page, with a limit of 10 quotes -

try await QuoteKit.quotes(limit: 10, page: 2)

Get all quotes with the tags love OR happiness -

try await QuoteKit.quotes(tags: [.love, .happiness], type: .either)

Get all quotes with the tags technology AND famous-quotes -

try await QuoteKit.quotes(tags: [.technology, .famousQuotes], type: .all)

Get all quotes by author, using the author's slug -

try await QuoteKit.quotes(authors: ["albert-einstein"])

Get all quotes sorted by author -

try await QuoteKit.quotes(sortBy: .author)

Get all quotes sorted by content, in descending order -

try await QuoteKit.quotes(sortBy: .content, order: .descending)

Quote By ID

If there is one, return a single Quote object for the given id from the /quotes/:id API.

var quote: Quote?
quote = try await QuoteKit.quote(id: "2xpHvSOQMD")

List Authors

Returns the Authors object matching the given queries from the /authors API. By default, the list contains 20 Author in one page. You can filter multiple authors by providing their slugs in the query parameter.

var authors: Authors?
authors = try await QuoteKit.authors()

Few examples:

Get the first page of authors, with 20 results per page -

try await QuoteKit.authors(page: 1)

Get the second page of authors, with 20 results per page, with a limit of 10 authors -

try await QuoteKit.authors(limit: 10, page: 2)

Get all authors, sorted alphabetically by name -

try await QuoteKit.authors(sortBy: .name)

Get all authors, sorted by number of quotes in descending order -

try await QuoteKit.authors(sortBy: .quoteCount, order: .descending)

Get a single author by slug -

try await QuoteKit.authors(slugs: ["albert-einstein"])

Get multiple authors by slug -

try await QuoteKit.authors(slugs: ["albert-einstein", "abraham-lincoln"])

Author By ID

If there is one, return a single Author object for the given id from the /authors/:id API.

var author: Author?
author = try await QuoteKit.author(id: "XYxYtSeixS-o")

Author Profile Image URL

Returns the image URL for given author slug. You can specify the image size as well. The default image size is 700x700.

var authorImageURL: URL?
authorImageURL = QuoteKit.authorProfile(size: 1000, slug: "aesop")

List Tags

Returns the Tags object containing the list of all tags from the /tags API. You can sort it and order the sorted results.

var tags: Tags?
tags = try await QuoteKit.tags()

Get all tags, sorted alphabetically by name -

try await QuoteKit.tags(sortBy: .name)

Get all tags, sorted by number of quotes in descending order -

try await QuoteKit.tags(sortBy: .quoteCount, order: .descending)

Search Quotes

Returns the Quotes object based on the search query from the /search/quotes API. By default, the list contains 20 Quote in one page.

var quotes: Quotes?
quotes = try await QuoteKit.searchQuotes(for: "love")

Get the first page of searched quotes, with 20 results per page -

try await QuoteKit.searchQuotes(for: "love", page: 1)

Get the second page of searched quotes, with 20 results per page, with a limit of 10 quotes -

try await QuoteKit.searchQuotes(for: "love", limit: 10, page: 2)

Search Authors

Returns the Authors object based on the search query from the /search/authors API. By default, the list contains 20 Author in one page.

var quotes: Quotes?
quotes = try await QuoteKit.searchAuthors(for: "kalam")

Get the first page of searched authors, with 20 results per page -

try await QuoteKit.searchAuthors(for: "kalam", page: 1)

Get the second page of searched authors, with 20 results per page, with a limit of 10 authors -

try await QuoteKit.searchAuthors(for: "kalam", limit: 10, page: 2)

Data Models

There are many different data models for using this framework.

  • Quote

The object represents a single quote. You can get the content of the quote using the content variable. The tags is an array of the relevant tag associated with the quote. To get the number of characters in the quote, use length.

struct Quote: Decodable, Identifiable {
    var id: String
    var tags: [String]
    var content: String
    var author: String
    var authorSlug: String
    var length: Int
    var dateAdded: String
    var dateModified: String
    
    enum CodingKeys: String, CodingKey {
        case id = "_id"
        case tags, content, author, authorSlug, length, dateAdded, dateModified
    }
}
  • Author

The object represents a single author. You can get the link to their Wikipedia page or their official website using link. bio contains a brief, one paragraph about the author. Use description instead to get a shorter description of the person's occupation or what they're known for. quotes contains an array of the author's quote.

Bool { lhs.id == rhs.id } } ">
struct Author: Decodable, Identifiable {
    var id: String
    var link: String
    var bio: String
    var description: String
    var name: String
    var quoteCount: Int
    var slug: String
    var dateAdded: String
    var dateModified: String
    var quotes: [Quote]?
    
    enum CodingKeys: String, CodingKey {
        case link, bio, description
        case id = "_id"
        case name, quoteCount, slug
        case dateAdded, dateModified
        case quotes
    }
}

extension Author: Equatable {
    static func ==(lhs: Author, rhs: Author) -> Bool {
        lhs.id == rhs.id
    }
}
You might also like...
A Swift client for the OpenAI API.

OpenAI A Swift client for the OpenAI API. Requirements Swift 5.3+ An OpenAI API Key Example Usage Completions import OpenAI

Swift Bot with Vapor for Telegram Bot Api

Telegram Vapor Bot Please support Swift Telegram Vapor Bot Lib development by giving a ⭐️ Telegram Bot based on Swift Vapor. Swift Server Side Communi

Solana + RxSolana This is a open source library on pure swift for Solana protocol

The objective is to create a cross platform, fully functional, highly tested and less depencies as posible. The project is still at initial stage. Lots of changes chan happen to the exposed api.

Fetch Multiple Rest API using Swift 5.5 Async Await with Task, TaskGroup, Continuation API
Fetch Multiple Rest API using Swift 5.5 Async Await with Task, TaskGroup, Continuation API

Source code for Tutorial on experimenting with Swift Async Await to fetch multiple REST API endpoints and eliminate Pyramid of Doom callback hell to improve code readability and maintanability

Swift library for the Twitter API v1 and v2

Swift library for the Twitter API v1 and v2

The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.
The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey.

QuoteKit The QuoteKit is a Swift framework to use the free APIs provided by Quotable created by Luke Peavey. It uses the latest async/await syntax for

Quotes App is quotes browsing app which is built with Quotable Free API completely in SwiftUI.
Quotes App is quotes browsing app which is built with Quotable Free API completely in SwiftUI.

Quotes App is quotes browsing app which is built with Quotable Free API completely in SwiftUI. You can watch the whole journey of building this

 Quotes App - quotes browsing app which is built with Quotable Free API completely in UIKit
Quotes App - quotes browsing app which is built with Quotable Free API completely in UIKit

Quotes App is quotes browsing app which is built with Quotable Free API completely in UIKit

Swift APIs for SQLite: Type-safe down to the schema. Very, very, fast. Dependency free.
Swift APIs for SQLite: Type-safe down to the schema. Very, very, fast. Dependency free.

Lighter Lighter is a set of technologies applying code generation to access SQLite3 databases from Swift, e.g. in iOS applications or on the server. L

CookCLI is provided as a command-line tool to make Cook recipe management easier

CookCLI is provided as a command-line tool to make Cook recipe management easier, and enable automation and scripting workflows for the CookLa

Sample code for Core ML using ResNet50 provided by Apple and a custom model generated by coremltools.
Sample code for Core ML using ResNet50 provided by Apple and a custom model generated by coremltools.

CoreML-samples This is the sample code for Core ML using ResNet50 provided by Apple. ResNet50 can categorize the input image to 1000 pre-trained categ

A simple weather forecast application with data provided from OpenWeatherMap.
A simple weather forecast application with data provided from OpenWeatherMap.

Weather Forecast Example Application Author: Long Kim This repo contains the source code for a simple weather forecast application with data provided

Disease diagnosis service based on api linkage for education chatbot provided by Saltlux
Disease diagnosis service based on api linkage for education chatbot provided by Saltlux

AIDoctor-P-Project 가천대학교 2021-2학기 P프로젝트입니다. 솔트룩스에서 제공된 교육용 챗봇 api 연동을 기반으로 한 질병 진단 서비스 Splash Login UserMain Disease Detail ### Hospital Detail ChatBo

Catalyst example using an AppKit-provided NSVisualEffectView to provide a translucent blurred window
Catalyst example using an AppKit-provided NSVisualEffectView to provide a translucent blurred window

CatalystEffectViewChrome This project demonstrates how to insert an NSVisualEffe

An iOS application enables you explore art works provided by DeviartArt.com with high quality UX.
An iOS application enables you explore art works provided by DeviartArt.com with high quality UX.

Iris.iOS Iris is a model mobile application based on iOS. It provides basic functions allow users to explore on DeviantArt and check Daily Arts, Notif

Challenge-M2Y-TM4 - A challenge provided by Mobile2You, with the purpose of analyzing knowledge about UI, API consumption
Challenge-M2Y-TM4 - A challenge provided by Mobile2You, with the purpose of analyzing knowledge about UI, API consumption

Challenge-M2Y-TM4 Um desafio proporcionado pela Mobile2You, com proposito de ana

Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.
Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

100-Days-of-SwiftUI - a free online course created and delivered by Paul Hudson

100-Days-of-SwiftUI DESCRIPTION 100 Days of SwiftUI is a free online course crea

Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Releases(1.2.0)
  • 1.2.0(Oct 31, 2021)

    Hi there! This update contains backward compatibility of Swift's new concurrency system! In simple terms, you can use async/await syntax targeting iOS 13, macOS Catalina, watchOS 6, and tvOS 13!

    Do note you have to use Xcode 13.2+

    Happy coding!

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Oct 3, 2021)

    While we wait and hope that the new async/await is backported to support the older version of iOS and other platforms, I modified QuoteKit to support completion handlers so that you can use it for iOS 13, macOS 11, tvOS 13 and watchOS 6!

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Sep 25, 2021)

    This release contains more tests and all the APIs for you to create wonderful quote apps! It is currently being used in my app "Quoting" that I plan to release soon for iOS 15!

    Enjoy!

    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Sep 1, 2021)

  • 0.1.1(Aug 30, 2021)

    The RRQuotableKit is a framework to use the free APIs provided by Quotable. It uses the latest async/await syntax for easy access and contains all the APIs like fetching a random quote, all quotes, authors and tags.

    Source code(tar.gz)
    Source code(zip)
Owner
Rudrank Riyam
Learning iOS development and some design
Rudrank Riyam
A (really) native and powerful macOS Telegram client built using SwiftUI, optimized for moderating large communities and personal use.

Moc A (really) native and powerful macOS Telegram client, optimized for moderating large communities and personal use. This client is currently in dev

GGorAA 84 Jan 2, 2023
👤 Framework to Generate Random Users - An Unofficial Swift SDK for randomuser.me

RandomUserSwift is an easy to use Swift framework that provides the ability to generate random users and their accompanying data for your Swift applic

Wilson Ding 95 Sep 9, 2022
Swifter - A Twitter framework for iOS & OS X written in Swift

Getting Started Installation If you're using Xcode 6 and above, Swifter can be installed by simply dragging the Swifter Xcode project into your own pr

Matt Donnelly 2.4k Dec 26, 2022
Swift implementation of Github REST API v3

GitHubAPI Swift implementation of GitHub REST api v3. Library support Swift 4.2. Work is in progress. Currently supported: Issues API. Activity API(Fe

Serhii Londar 77 Jan 7, 2023
Google Directions API helper for iOS, written in Swift

PXGoogleDirections Google Directions API SDK for iOS, entirely written in Swift. ?? Features Supports all features from the Google Directions API as o

Romain L 268 Aug 18, 2022
Swift Reddit API Wrapper

reddift reddift is Swift Reddit API Wrapper framework, and includes a browser is developed using the framework. Supports OAuth2(is not supported on tv

sonson 236 Dec 28, 2022
Instagram API client written in Swift

SwiftInstagram is a wrapper for the Instagram API written in Swift. It allows you to authenticate users and request data from Instagram effortlessly.

Ander Goig 580 Nov 25, 2022
Swift client for Kubernetes

Table of contents Overview Compatibility Matrix Examples Usage Creating a client Configuring a client Client authentication Client DSL Advanced usage

Swiftkube 94 Dec 14, 2022
Instagram Private API Swift

SwiftyInsta Please notice SwiftyInsta may not be actively maintained at the moment of you reading this note. Refer to #244 for more info. Instagram of

Mahdi Makhdumi 218 Jan 5, 2023
SDK for creating Telegram Bots in Swift.

Chat • Changelog • Prerequisites • Getting started • Creating a new bot • Generating Xcode project • API overview • Debugging notes • Examples • Docum

Rapier 349 Dec 20, 2022