Latest 0.6.0
License MIT
Platforms ios 10.0
Dependencies InstantSearchClient

CI Status

Algent is a type safe algolia wrapper library.

You can use algolia with Swift decodable type as a search result.


To run the example project, clone the repo, and run pod install from the Example directory first.
Open AppDelegate.swift and set your AlgoliaSearch AppID and APIKey.

Algent.initialize(appID: "YOUR_APP_ID", apiKey: "YOUR_API_KEY")

custom search

Add search result model with implementing decodable

class Diary: Decodable {
    let title: String
    let text: String
    // Algolia hash tag info
    _tags: [String]

Add search request class with implementing AlgoliaRequestProtocol

struct SearchDiaryRequest: AlgoliaRequestProtocol {
    // set search result type
    typealias HitType = Diary

    let page: Int
    let per: Int
    let text: String?
    let hashtags: [String]?

    var indexName: String {
        return "diaries"

    var query: AlgentQuery {
        let query = AlgentQuery(query: text) = UInt(page)
        query.hitsPerPage = UInt(per)
        if let hashtags = hashtags {
            query.tagFilters = hashtags
        return query

    init(page: Int, per: Int, text: String? = nil, hashtags: [String]? = nil) { = page
        self.per = per
        self.text = text
        self.hashtags = hashtags

Call Algent search method using your request.

let request = SarchDiaryRequest(page: 0, per: 20, text: "hello world", hashtags: ["trip"]) request) { result in
    switch result {
    case .success(let response):
        // response is AlgoliaResponse<Request.HitType>
        print(response.hits) // see hit object
    case .failure( let error):
        print(error) // get error



Algent is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'Algent'


miup, [email protected]


Algent is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "Algent",
    "version": "0.6.0",
    "summary": "Algent is a wrapper of Algolia search client for iOS.",
    "description": "Algent is a wrapper of Algolia search client for iOS.nIf you need more infomation, look",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "miup": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.6.0"
    "platforms": {
        "ios": "10.0"
    "source_files": "Algent/Classes/**/*",
    "dependencies": {
        "InstantSearchClient": [
            "~> 7.0"

Pin It on Pinterest

Share This