{"id":13721506,"url":"https://github.com/meilisearch/meilisearch-swift","last_synced_at":"2025-05-07T13:33:08.444Z","repository":{"id":37950188,"uuid":"252325176","full_name":"meilisearch/meilisearch-swift","owner":"meilisearch","description":"Swift client for the Meilisearch API","archived":false,"fork":false,"pushed_at":"2023-12-19T18:34:03.000Z","size":1895,"stargazers_count":83,"open_issues_count":21,"forks_count":21,"subscribers_count":6,"default_branch":"main","last_synced_at":"2023-12-20T13:51:54.853Z","etag":null,"topics":["client","sdk","swift","vapor"],"latest_commit_sha":null,"homepage":"https://www.meilisearch.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meilisearch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-04-02T01:23:46.000Z","updated_at":"2024-01-03T14:35:46.740Z","dependencies_parsed_at":"2024-01-03T14:50:33.434Z","dependency_job_id":null,"html_url":"https://github.com/meilisearch/meilisearch-swift","commit_stats":{"total_commits":653,"total_committers":26,"mean_commits":"25.115384615384617","dds":0.6523736600306278,"last_synced_commit":"9eef683bf52afd7f464ff5ec9a048b73b49b7403"},"previous_names":[],"tags_count":24,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meilisearch%2Fmeilisearch-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meilisearch%2Fmeilisearch-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meilisearch%2Fmeilisearch-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meilisearch%2Fmeilisearch-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meilisearch","download_url":"https://codeload.github.com/meilisearch/meilisearch-swift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224604994,"owners_count":17339245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","sdk","swift","vapor"],"created_at":"2024-08-03T01:01:17.991Z","updated_at":"2025-05-07T13:33:08.437Z","avatar_url":"https://github.com/meilisearch.png","language":"Swift","funding_links":[],"categories":["Integrations"],"sub_categories":["Official Integrations"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/meilisearch/integration-guides/main/assets/logos/meilisearch_swift.svg\" alt=\"meilisearch-swift\" width=\"200\" height=\"200\" /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eMeilisearch Swift\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003e\n  \u003ca href=\"https://github.com/meilisearch/meilisearch\"\u003eMeilisearch\u003c/a\u003e |\n  \u003ca href=\"https://www.meilisearch.com/cloud?utm_campaign=oss\u0026utm_source=github\u0026utm_medium=meilisearch-swift\"\u003eMeilisearch Cloud\u003c/a\u003e |\n  \u003ca href=\"https://meilisearch.github.io/meilisearch-swift/\"\u003eDocumentation\u003c/a\u003e |\n  \u003ca href=\"https://discord.meilisearch.com\"\u003eDiscord\u003c/a\u003e |\n  \u003ca href=\"https://roadmap.meilisearch.com/tabs/1-under-consideration\"\u003eRoadmap\u003c/a\u003e |\n  \u003ca href=\"https://www.meilisearch.com\"\u003eWebsite\u003c/a\u003e |\n  \u003ca href=\"https://docs.meilisearch.com/faq\"\u003eFAQ\u003c/a\u003e\n\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/meilisearch/meilisearch-swift/actions\"\u003e\u003cimg src=\"https://github.com/meilisearch/meilisearch-swift/workflows/Tests/badge.svg\" alt=\"GitHub Workflow Status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/meilisearch/meilisearch-swift/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-informational\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://ms-bors.herokuapp.com/repositories/45\"\u003e\u003cimg src=\"https://bors.tech/images/badge_small.svg\" alt=\"Bors enabled\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e⚡ The Meilisearch API client written for Swift 🍎\u003c/p\u003e\n\n**Meilisearch Swift** is the Meilisearch API client for Swift developers.\n\n**Meilisearch** is an open-source search engine. [Learn more about Meilisearch.](https://github.com/meilisearch/meilisearch)\n\n## Table of Contents \u003c!-- omit in TOC --\u003e\n\n- [📖 Documentation](#-documentation)\n- [🔧 Installation](#-installation)\n- [🚀 Getting started](#-getting-started)\n- [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch)\n- [💡 Learn more](#-learn-more)\n- [⚙️ Contributing](#️-contributing)\n- [📜 Demos](#-demos)\n\n## 📖 Documentation\n\nFor more information about this API see our [Swift documentation](https://meilisearch.github.io/meilisearch-swift/).\n\nFor more information about Meilisearch see our [Documentation](https://docs.meilisearch.com/learn/tutorials/getting_started.html) or our [API References](https://docs.meilisearch.com/reference/api/).\n\n## 🔧 Installation\n\n### With Cocoapods \u003c!-- omit in toc --\u003e\n\n[CocoaPods](https://cocoapods.org/) is a dependency manager for Cocoa projects.\n\n**Meilisearch-Swift** is available through CocoaPods. To install it, add the following line to your Podfile:\n\n```ruby\npod 'MeiliSearch'\n```\n\nThen, run the following command:\n\n```bash\npod install\n```\n\nThis will download the latest version of Meilisearch pod and prepare the `xcworkspace`.\n\n### With the Swift Package Manager \u003c!-- omit in toc --\u003e\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.\n\nOnce 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`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/meilisearch/meilisearch-swift.git\", from: \"0.17.0\")\n]\n```\n\n### Run Meilisearch \u003c!-- omit in toc --\u003e\n\n⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss\u0026utm_source=github\u0026utm_medium=meilisearch-swift).\n\n🪨  Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss\u0026utm_source=github\u0026utm_medium=meilisearch-swift) our fast, open-source search engine on your own infrastructure.\n\n## 🚀 Getting started\n\nTo do a simple search using the client, you can create a Swift script like this:\n\n#### Add documents \u003c!-- omit in toc --\u003e\n\n```swift\n    import MeiliSearch\n\n    // Create a new client instance of Meilisearch.\n    // Note: You must provide a fully qualified URL including scheme.\n    let client = try! MeiliSearch(host: \"http://localhost:7700\")\n\n    struct Movie: Codable, Equatable {\n        let id: Int\n        let title: String\n        let genres: [String]\n    }\n\n    let movies: [Movie] = [\n        Movie(id: 1, title: \"Carol\", genres: [\"Romance\", \"Drama\"]),\n        Movie(id: 2, title: \"Wonder Woman\", genres: [\"Action\", \"Adventure\"]),\n        Movie(id: 3, title: \"Life of Pi\", genres: [\"Adventure\", \"Drama\"]),\n        Movie(id: 4, title: \"Mad Max: Fury Road\", genres: [\"Adventure\", \"Science Fiction\"]),\n        Movie(id: 5, title: \"Moana\", genres: [\"Fantasy\", \"Action\"]),\n        Movie(id: 6, title: \"Philadelphia\", genres: [\"Drama\"])\n    ]\n\n    let semaphore = DispatchSemaphore(value: 0)\n\n    // An index is where the documents are stored.\n    // The uid is the unique identifier to that index.\n    let index = client.index(\"movies\")\n\n    // If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.\n    index.addDocuments(\n        documents: movies,\n        primaryKey: nil\n    ) { result in\n        switch result {\n        case .success(let task):\n            print(task) // =\u003e Task(uid: 0, status: Task.Status.enqueued, ...)\n        case .failure(let error):\n            print(error.localizedDescription)\n        }\n        semaphore.signal()\n      }\n    semaphore.wait()\n```\n\nWith the `uid` of the task, you can check the status (`enqueued`, `canceled`, `processing`, `succeeded` or `failed`) of your documents addition using the [update endpoint](https://docs.meilisearch.com/learn/advanced/asynchronous_operations.html#task-status).\n\n#### Basic Search \u003c!-- omit in toc --\u003e\n\n```swift\ndo {\n  // Call the search function and wait for the result.\n  let result: SearchResult\u003cMovie\u003e = try await client.index(\"movies\").search(SearchParameters(query: \"philoudelphia\"))\n  dump(result)\n} catch {\n  print(error.localizedDescription)\n}\n```\n\nOutput:\n\n```bash\n MeiliSearch.SearchResult\u003cSwiftWork.(unknown context at $10d9e7f3c).Movie\u003e\n  ▿ hits: 1 element\n    ▿ SwiftWork.(unknown context at $10d9e7f3c).Movie\n      - id: 6\n      - title: \"Philadelphia\"\n      ▿ genres: 1 element\n        - \"Drama\"\n  - offset: 0\n  - limit: 20\n  - estimatedTotalHits: 1\n  - facetDistribution: nil\n  ▿ processingTimeMs: Optional(1)\n    - some: 1\n  ▿ query: Optional(\"philoudelphia\")\n    - some: \"philoudelphia\"\n```\n\nSince Meilisearch is typo-tolerant, the movie `philadelphia` is a valid search response to `philoudelphia`.\n\n\u003e Note: All package APIs support closure-based results for backwards compatibility. Newer async/await variants are being added under [issue 332](https://github.com/meilisearch/meilisearch-swift/issues/332).\n\n#### Custom Search With Filters \u003c!-- omit in toc --\u003e\n\nIf you want to enable filtering, you must add your attributes to the `filterableAttributes` index setting.\n\n```swift\nindex.updateFilterableAttributes([\"id\", \"genres\"]) { result in\n    // Handle Result in Closure\n}\n```\n\nYou only need to perform this operation once.\n\nNote that MeiliSearch will rebuild your index whenever you update `filterableAttributes`. Depending on the size of your dataset, this might take time. You can track the process using the [update status](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).\n\nThen, you can perform the search:\n\n```swift\nlet searchParameters = SearchParameters(\n    query: \"wonder\",\n    filter: \"id \u003e 1 AND genres = Action\"\n)\n\nlet response: Searchable\u003cMeteorite\u003e = try await index.search(searchParameters)\n```\n\n```json\n{\n  \"hits\": [\n    {\n      \"id\": 2,\n      \"title\": \"Wonder Woman\",\n      \"genres\": [\"Action\",\"Adventure\"]\n    }\n  ],\n  \"offset\": 0,\n  \"limit\": 20,\n  \"nbHits\": 1,\n  \"processingTimeMs\": 0,\n  \"query\": \"wonder\"\n}\n```\n\n## 🤖 Compatibility with Meilisearch\n\nThis package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-swift/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info.\n\n## 💡 Learn more\n\nThe following sections in our main documentation website may interest you:\n\n- **Manipulate documents**: see the [API references](https://docs.meilisearch.com/reference/api/documents.html) or read more about [documents](https://docs.meilisearch.com/learn/core_concepts/documents.html).\n- **Search**: see the [API references](https://docs.meilisearch.com/reference/api/search.html) or follow our guide on [search parameters](https://docs.meilisearch.com/reference/features/search_parameters.html).\n- **Manage the indexes**: see the [API references](https://docs.meilisearch.com/reference/api/indexes.html) or read more about [indexes](https://docs.meilisearch.com/learn/core_concepts/indexes.html).\n- **Configure the index settings**: see the [API references](https://docs.meilisearch.com/reference/api/settings.html) or follow our guide on [settings parameters](https://docs.meilisearch.com/reference/features/settings.html).\n\n## ⚙️ Contributing\n\nAny new contribution is more than welcome in this project!\n\nIf you want to know more about the development workflow or want to contribute, please visit our [contributing guidelines](/CONTRIBUTING.md) for detailed instructions!\n\n## 📜 Demos\n\nTo try out a demo you will need to go to its directory in `Demos/`. In that directory you can either:\n\n- Open the SwiftPM project in Xcode and press run, or\n- Run `swift build` or `swift run` in the terminal.\n\n### Vapor \u003c!-- omit in toc --\u003e\n\nPlease check the Vapor Demo source code [here](https://github.com/meilisearch/meilisearch-swift/tree/main/Demos/VaporDemo).\n\n### Perfect \u003c!-- omit in toc --\u003e\n\nPlease check the Perfect Demo source code [here](https://github.com/meilisearch/meilisearch-swift/tree/main/Demos/PerfectDemo).\n\n\u003chr\u003e\n\n**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](https://github.com/meilisearch/integration-guides) repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeilisearch%2Fmeilisearch-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeilisearch%2Fmeilisearch-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeilisearch%2Fmeilisearch-swift/lists"}