{"id":26904990,"url":"https://github.com/meesakveld/strapi-swift","last_synced_at":"2025-04-01T10:55:32.917Z","repository":{"id":284995313,"uuid":"926820790","full_name":"meesakveld/strapi-swift","owner":"meesakveld","description":"Swift Package that provides a simple and easy way to interact with Strapi APIs in Swift | Mees Akveld","archived":false,"fork":false,"pushed_at":"2025-03-28T19:35:29.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T20:31:18.004Z","etag":null,"topics":["api","framework","strapi","strapi-cms","swift","swift-package"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meesakveld.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2025-02-03T23:03:12.000Z","updated_at":"2025-03-28T20:07:07.000Z","dependencies_parsed_at":"2025-03-28T20:41:22.400Z","dependency_job_id":null,"html_url":"https://github.com/meesakveld/strapi-swift","commit_stats":null,"previous_names":["meesakveld/strapi-swift"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meesakveld%2Fstrapi-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meesakveld%2Fstrapi-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meesakveld%2Fstrapi-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meesakveld%2Fstrapi-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meesakveld","download_url":"https://codeload.github.com/meesakveld/strapi-swift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246628300,"owners_count":20808106,"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":["api","framework","strapi","strapi-cms","swift","swift-package"],"created_at":"2025-04-01T10:55:32.427Z","updated_at":"2025-04-01T10:55:32.910Z","avatar_url":"https://github.com/meesakveld.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StrapiSwift\n\nStrapiSwift is a Swift package that provides a simple and easy way to interact with Strapi APIs. It is built on top of the `URLRequest` and `Codable` protocols to provide a seamless experience for developers. StrapiSwift is designed to work with Strapi APIs that are built with the default REST API plugin.\n\n## Table of Contents\n- [StrapiSwift](#strapiswift)\n  - [Table of Contents](#table-of-contents)\n  - [Installation](#installation)\n  - [Configuration](#configuration)\n    - [Setup](#setup)\n    - [Use a replacing token once](#use-a-replacing-token-once)\n  - [Content Manager](#content-manager)\n  - [Authentication Local Provider](#authentication-local-provider)\n  - [Media Library](#media-library)\n  - [How to Contribute](#how-to-contribute)\n  - [License](#license)\n\n\u003cbr\u003e\n\n## Installation\n\nYou can add StrapiSwift to your Swift project using Swift Package Manager.\n\n1. In Xcode, go to File -\u003e Swift Packages -\u003e Add Package Dependency.\n\n2. Enter the repository URL: `https://github.com/meesakveld/strapi-swift.git`\n\n3. Choose the version or branch you want to use.\n\n\u003cbr\u003e\n\n## Configuration\nTo configure StrapiSwift, you need to provide the base URL of your Strapi API and the authentication token (if needed).\n\n### Setup\n\n```swift\nimport SwiftUI\nimport StrapiSwift\n\n@main\nstruct SomeNameApp: App {\n    @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate\n    \n    var body: some Scene {\n        WindowGroup {\n            ContentView()\n        }\n    }\n}\n\nclass AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {\n\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -\u003e Bool {\n        // —— Configure StrapiSwift ——\n        Strapi.configure(\n            baseURL: \"https://your-strapi-url.com\",\n            token: \"some-token\"\n        )\n        \n        return true\n    }\n\n}\n```\n\nThe configuration can always be overwritten, to for example use a jwt token after logging in.\n\n### Use a replacing token once\n\nAfter making an request with the token, the one time use token will be replaced with the original configured token.\n\n```swift\nStrapi.useTokenOnce(token: \"some-token\")\n```\n\n\u003cbr\u003e\n\n## Content Manager\n*Filter, sort, populate, fields, pagination, locale and status parameters are supported.*\n- ### GET requests\n\n    ```swift\n    // Get all documents\n    try await Strapi.contentManager.collection(\"gifts\").getDocuments(as: [Gift].self)\n\n    // Get a single document\n    try await Strapi.contentManager.collection(\"gifts\").withDocumentId(\"a4fsdnjsdf42dsfd\").getDocument(as: Gift.self)\n    ```\n\n- ### POST requests\n\n    ```swift\n    let data = StrapiRequestBody([\n        \"invitedUserEmail\": .string(email),\n        \"event\": .string(eventDocumentId)\n    ])\n\n    try await Strapi.contentManager.collection(\"event-invites\").postData(data, as: EventInvite.self)\n    ```\n\n- ### PUT requests\n\n    ```swift\n    let data = StrapiRequestBody([\n        \"status\": .string(\"accepted\")\n    ])\n\n    try await Strapi.contentManager.collection(\"event-invites\").withDocumentId(\"a4fsdnjsdf42dsfd\").putData(data, as: EventInvite.self)\n    ```\n\n\n- ### DELETE requests\n\n    ```swift\n    try await Strapi.contentManager.collection(\"event-invites\").withDocumentId(\"a4fsdnjsdf42dsfd\").delete()\n    ```\n\n\u003cbr\u003e\n\n## Authentication Local Provider\n- ### Register: a new user\n\n    ```swift\n    try await Strapi.authentication.local.register(username: \"michaelscott\", email: \"michaelscott@dundermifflin.com\", password: \"password\", as: User.self)\n    ```\n\n- ### Login: an existing user\n\n    ```swift\n    try await Strapi.authentication.local.login(identifier: \"michaelscott\", password: \"password\", as: User.self)\n    ```\n\n- ### Update Profile: for a user\n\n    ```swift\n    let data: StrapiRequestBody = StrapiRequestBody([\n        \"firstname\": .string(\"Michael\"),\n        \"lastname\": .string(\"Scott\"),\n    ])\n    \n    try await Strapi.authentication.local.updateProfile(data, userId: 1, as: User.self)\n    ```\n\n- ### Me: to get the current user (with option add an extended url)\n\n    ```swift\n    // Get the current user\n    try await Strapi.authentication.local.me(as: User.self)\n\n    // Me with an extended url for custom endpoints\n    let data: StrapiRequestBody = StrapiRequestBody([\n        \"deviceToken\": .string(\"dfsdg53gdfg532GFD6fgds\")\n    ])\n\n    try await Strapi.authentication.local.me(extendUrl: \"/device-token\", requestType: .PUT, data: data, as: User.self)\n    ```\n\n- ### Change Password: for a user\n\n    ```swift\n    try await Strapi.authentication.local.changePassword(currentPassword: \"currentPassword\", newPassword: \"newPassword\", as: User.self)\n    ```\n\n\u003cbr\u003e\n\n## Media Library\n- ### Get All Files: in the media library\n\n    ```swift\n    try await Strapi.mediaLibrary.files.getFiles(as: [StrapiImage].self)\n    ```\n\n- ### Get File: by ID\n\n    ```swift\n    try await Strapi.mediaLibrary.files.withId(1).getFile(as: StrapiImage.self)\n    ```\n\n- ### Upload Image: to the media library (via `UIImage` or `URL`)\n\n    ```swift\n    // Upload image from UIImage\n    try await Strapi.mediaLibrary.files.uploadImage(image: image)\n\n    // Upload image from URL\n    try await Strapi.mediaLibrary.files.uploadImage(from: \"https://picsum.photos/200/300\")\n    ```\n\n- ### Delete File: by ID\n\n    ```swift\n    try await Strapi.mediaLibrary.files.withId(1).delete(as: StrapiImage.self)\n    ```\n\n## How to Contribute\n\nIf you'd like to contribute, feel free to fork the repository, make your changes, and open a pull request.\n\n## License\n\nStrapiSwift is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for more details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeesakveld%2Fstrapi-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeesakveld%2Fstrapi-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeesakveld%2Fstrapi-swift/lists"}