Swiftpack.co - Package - meilisearch/meilisearch-swift
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.



MeiliSearch | Website | LinkedIn | Documentation | Slack | FAQ

GtiHub Workflow Status License Bors enabled

⚡ Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine MeiliSearch client written in Swift 🍎

MeiliSearch-Swift is a client for MeiliSearch written in Swift.

MeiliSearch is an open-source search engine. Discover what MeiliSearch is! For more information about features go to our Swift documentation.


  • Complete full API wrapper
  • Easy to install, deploy, and maintain
  • Highly customizable
  • No external dependencies
  • Thread safe
  • Uses Codable

Get started

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding MeiliSearch-Swift as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/meilisearch/meilisearch-swift.git")

Basic setup

Make sure to firstly setup your MeiliSearch server. Please follow this getting started here.

To do a simply search using the client, you can create a Swift script like this:

import MeiliSearch

func searchForMovies() {

    // Create a new client instance of MeiliSearch with the default host.
    let client = try! MeiliSearch()

    // Create a new search request with "botman" as query.
    let searchParameters = SearchParameters.query("botman")

    // Typealias that represents the result from Meili.
    typealias MeiliResult = Result<SearchResult<Movie>, Swift.Error>

    // Call the function search and wait for the closure result.
    self.client.search(UID: "movies", searchParameters) { (result: MeiliResult) in
        switch result {
        case .success(let searchResult):
        case .failure(let error):


private struct Movie: Codable, Equatable {

    let id: Int
    let title: String
    let poster: String
    let overview: String
    let releaseDate: Date

    enum CodingKeys: String, CodingKey {
        case id
        case title
        case poster
        case overview
        case releaseDate = "release_date"


Compatibility with MeiliSearch

This package only guarantees the compatibility with the version v0.18.1 of MeiliSearch.


To try out a demo you will need to go to its directory in Demos/. In that directory you can either:

  • Open the SwiftPM project in Xcode and press run, or
  • Run swift build or swift run in the terminal.


Please check the Vapor Demo source code here.


Please check the Perfect Demo source code here.

Development Workflow and Contributing

Any new contribution is more than welcome in this project!

If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!


Feel free to contact us about any questions you may have:

Any suggestion or feedback is highly appreciated. Thank you for your support!

Swift programming language from Apple

MeiliSearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.


Stars: 47


v0.6.1 🕊 - 2021-01-13T12:33:29


  • Make SearchParameters initializer public (#98) @felix-gohla

Thanks again to @curquiza, and @felix-gohla ! 🎉

v0.6.0 🕊 - 2020-11-04T16:14:04

Breaking changes ⚠️

  • Update dump status (#89) @curquiza
  • Remove the udpateHealth method (#90) @curquiza

Also thanks to @bidoubiwa and @ppamorim! 🎉

v0.5.0 🕊 - 2020-10-27T13:21:03


  • Overload function 'getDocument' to accept identifier as Int too (#52) @ednofedulo
  • Add support to Encodable types for addDocuments function (#53) @ppamorim
  • Add dump support (#72) @ppamorim
  • Addd waitForPending update method (#73) @ppamorim

Breaking changes ⚠️

  • Make all the search parameters optional (#66) @curquiza
  • Change the update status as enum and rename Type into UpdateType in Update model (#71) @ppamorim

Thanks again to @Ethenyl, @curquiza, @ednofedulo, @bidoubiwa and @ppamorim! 🎉

v0.4.0 🕊 - 2020-10-08T16:05:37

Breaking changes ⚠️

  • Remove acceptNewFields routes (#51) @Ethenyl
  • Change search method from get to post (#30) @bidoubiwa

Thanks again to @Ethenyl, @bidoubiwa, and @curquiza. Special thanks to @ppamorim who improved all the tests! 🎉

v0.3.0 🕊 - 2020-10-01T14:32:32


Breaking changes ⚠️

  • Remove sys-info routes (#50) @Ethenyl
  • Add primaryKey during index creation (#32) @bidoubiwa and @ppamorim
  • name is optional in Index struct (#32) @bidoubiwa and @ppamorim


  • Fix updateDocuments method (#32) @bidoubiwa and @ppamorim
  • Use the apiKey when requesting (#32) @bidoubiwa and @ppamorim
  • Fix deleteBatch method (#32) @bidoubiwa and @ppamorim
  • Fix updateIndex method (#32) @bidoubiwa and @ppamorim

Thanks again to @Ethenyl, @bidoubiwa, @curquiza and @ppamorim! 🎉

v0.2.0 🕊 - 2020-07-30T09:07:43


  • MeiliSearch bump to v0.13.0 (#28) @curquiza
  • Add release drafter (#17) @curquiza
  • Add CONTRIBUTING.md (#19) @curquiza
  • Update github actions to not run the documentation action when opening a PR (#23) @ppamorim
  • Update swift-test.yml to run it on every PR, not only pointing to master (#27) @curquiza
  • Feature/facets (#16) @ppamorim

Breaking changes

  • Rename addOrReplaceDocument and addOrUpdateDocument into addDocuments and updateDocuments. (#21) @curquiza

Thanks again to @curquiza, @eskombro and @ppamorim! 🎉

0.1.0 - 2020-06-22T04:07:31

First version of meilisearch-swift.

This release contains:

  • Support to version v0.10.X of Meilisearch;
  • Support to Index, Document, Search, Updates, Keys, Settings, Stats, Health, Version and System Information.