{"id":13534150,"url":"https://github.com/appwrite/sdk-for-swift","last_synced_at":"2026-03-03T13:05:39.625Z","repository":{"id":46672641,"uuid":"409580586","full_name":"appwrite/sdk-for-swift","owner":"appwrite","description":"[READ-ONLY] Official Appwrite Swift SDK 🦅🍎","archived":false,"fork":false,"pushed_at":"2025-07-26T17:25:43.000Z","size":846,"stargazers_count":52,"open_issues_count":3,"forks_count":4,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-08-17T20:53:55.093Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appwrite.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-09-23T12:21:34.000Z","updated_at":"2025-07-27T21:50:16.000Z","dependencies_parsed_at":"2024-08-27T12:01:49.516Z","dependency_job_id":"8f95bd20-44b2-4e23-91ef-de817c3d9faa","html_url":"https://github.com/appwrite/sdk-for-swift","commit_stats":{"total_commits":72,"total_committers":8,"mean_commits":9.0,"dds":0.6944444444444444,"last_synced_commit":"f75ad97c0e5506f2a04918ac90c964cd550ad76d"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/appwrite/sdk-for-swift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fsdk-for-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fsdk-for-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fsdk-for-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fsdk-for-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appwrite","download_url":"https://codeload.github.com/appwrite/sdk-for-swift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fsdk-for-swift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271091032,"owners_count":24697715,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["hacktoberfest"],"created_at":"2024-08-01T07:01:27.024Z","updated_at":"2026-03-03T13:05:39.619Z","avatar_url":"https://github.com/appwrite.png","language":"Swift","funding_links":[],"categories":["SDK"],"sub_categories":["Official Appwrite SDKs"],"readme":"# Appwrite Swift SDK\n\n![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green\u0026style=flat-square)\n![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)\n![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square)\n[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)\n[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee\u0026label=twitter\u0026style=flat-square)](https://twitter.com/appwrite)\n[![Discord](https://img.shields.io/discord/564160730845151244?label=discord\u0026style=flat-square)](https://appwrite.io/discord)\n\n**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**\n\n \u003e This is the Swift SDK for integrating with Appwrite from your Swift server-side code. If you're looking for the Apple SDK you should check [appwrite/sdk-for-apple](https://github.com/appwrite/sdk-for-apple)\n\nAppwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Swift SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)\n\n![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png)\n\n## Installation\n\n### Xcode with Swift Package Manager\n\nThe Appwrite Swift SDK is available via Swift Package Manager. In order to use the Appwrite Swift SDK from Xcode, select File \u003e **Add Packages**\n\nIn the dialog that appears, enter the Appwrite Swift SDK [package URL](git@github.com:appwrite/sdk-for-swift.git) in the search field. Once found, select `sdk-for-swift`.\n\nOn the right, select your version rules and ensure your desired target is selected in the **Add to Project** field.\n\nNow click add package and you're done!\n\n### Swift Package Manager\n\nAdd the package to your `Package.swift` dependencies:\n\n```swift\n    dependencies: [\n        .package(url: \"git@github.com:appwrite/sdk-for-swift.git\", from: \"15.2.0\"),\n    ],\n```\n\nThen add it to your target:\n\n```swift\n    targets: [\n        .target(\n            name: \"YourAppTarget\",\n            dependencies: [\n                .product(name: \"\", package: \"sdk-for-swift\")\n            ]\n        ),\n```\n\n\n## Getting Started\n\n### Init your SDK\n\nInitialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key project API keys section.\n\n```swift\nimport Appwrite\n\nfunc main() {\n    let client = Client()\n        .setEndpoint(\"https://[HOSTNAME_OR_IP]/v1\") // Your API Endpoint\n        .setProject(\"5df5acd0d48c2\") // Your project ID\n        .setKey(\"919c2d184...a2ae413dad2\") // Your secret API key\n        .setSelfSigned() // Use only on dev mode with a self-signed SSL cert\n}\n```\n\n### Make Your First Request\n\nOnce your SDK object is initialized, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.\n\n```swift\nlet users = Users(client)\n\ndo {\n    let user = try await users.create(\n        userId: ID.unique(),\n        email: \"email@example.com\",\n        phone: \"+123456789\",\n        password: \"password\",\n        name: \"Walter O'Brien\"\n    )\n    print(String(describing: user.toMap()))\n} catch {\n    print(error.localizedDescription)\n}\n```\n\n### Full Example\n\n```swift\nimport Appwrite\n\nfunc main() {\n    let client = Client()\n        .setEndpoint(\"https://[HOSTNAME_OR_IP]/v1\") // Your API Endpoint\n        .setProject(\"5df5acd0d48c2\") // Your project ID\n        .setKey(\"919c2d18fb5d4...a2ae413da83346ad2\") // Your secret API key\n        .setSelfSigned() // Use only on dev mode with a self-signed SSL cert\n\n    let users = Users(client)\n    \n    do {\n        let user = try await users.create(\n            userId: ID.unique(),\n            email: \"email@example.com\",\n            phone: \"+123456789\",\n            password: \"password\",\n            name: \"Walter O'Brien\"\n        )\n        print(String(describing: user.toMap()))\n    } catch {\n        print(error.localizedDescription)\n    }\n}\n```\n\n### Type Safety with Models\n\nThe Appwrite Swift SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a `nestedType` parameter that allows you to specify your custom model type for full type safety.\n\n```swift\nstruct Book: Codable {\n    let name: String\n    let author: String\n    let releaseYear: String?\n    let category: String?\n    let genre: [String]?\n    let isCheckedOut: Bool\n}\n\nlet databases = Databases(client)\n\ndo {\n    let documents = try await databases.listDocuments(\n        databaseId: \"your-database-id\",\n        collectionId: \"your-collection-id\",\n        nestedType: Book.self // Pass in your custom model type\n    )\n    \n    for book in documents.documents {\n        print(\"Book: \\(book.name) by \\(book.author)\") // Now you have full type safety\n    }\n} catch {\n    print(error.localizedDescription)\n}\n```\n\n**Tip**: You can use the `appwrite types` command to automatically generate model definitions based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation).\n\n### Working with Model Methods\n\nAll Appwrite models come with built-in methods for data conversion and manipulation:\n\n**`toMap()`** - Converts a model instance to a dictionary format, useful for debugging or manual data manipulation:\n```swift\nlet user = try await account.get()\nlet userMap = user.toMap()\nprint(userMap) // Prints all user properties as a dictionary\n```\n\n**`from(map:)`** - Creates a model instance from a dictionary, useful when working with raw data:\n```swift\nlet userData: [String: Any] = [\"$id\": \"123\", \"name\": \"John\", \"email\": \"john@example.com\"]\nlet user = User.from(map: userData)\n```\n\n**`encode(to:)`** - Encodes the model to JSON format (part of Swift's Codable protocol), useful for serialization:\n```swift\nlet user = try await account.get()\nlet jsonData = try JSONEncoder().encode(user)\nlet jsonString = String(data: jsonData, encoding: .utf8)\n```\n\n### Error Handling\n\nWhen an error occurs, the Appwrite Swift SDK throws an `AppwriteError` object with `message` and `code` properties. You can handle any errors in a catch block and present the `message` or `localizedDescription` to the user or handle it yourself based on the provided error information. Below is an example.\n\n```swift\nimport Appwrite\n\nfunc main() {\n    let users = Users(client)\n    \n    do {\n        let users = try await users.list()\n        print(String(describing: users.toMap()))\n    } catch {\n        print(error.localizedDescription)\n    }\n}\n```\n\n### Learn more\n\nYou can use the following resources to learn more and get help\n\n- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)\n- 📜 [Appwrite Docs](https://appwrite.io/docs)\n- 💬 [Discord Community](https://appwrite.io/discord)\n- 🚂 [Appwrite Swift Playground](https://github.com/appwrite/playground-for-swift-server)\n\n\n## Contribution\n\nThis library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.\n\n## License\n\nPlease see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappwrite%2Fsdk-for-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappwrite%2Fsdk-for-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappwrite%2Fsdk-for-swift/lists"}