{"id":17066767,"url":"https://github.com/moltin/ios-sdk","last_synced_at":"2025-10-30T20:43:58.159Z","repository":{"id":32544212,"uuid":"36126328","full_name":"moltin/ios-sdk","owner":"moltin","description":"Swift SDK for the Moltin eCommerce API","archived":false,"fork":false,"pushed_at":"2021-01-05T16:45:57.000Z","size":9037,"stargazers_count":37,"open_issues_count":6,"forks_count":18,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-10T00:12:42.216Z","etag":null,"topics":["api","commerce","ecommerce","headless","ios","moltin","sdk","swift"],"latest_commit_sha":null,"homepage":"https://moltin.github.io/ios-sdk","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/moltin.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}},"created_at":"2015-05-23T14:16:31.000Z","updated_at":"2024-04-11T02:47:47.000Z","dependencies_parsed_at":"2022-09-11T22:00:18.045Z","dependency_job_id":null,"html_url":"https://github.com/moltin/ios-sdk","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moltin%2Fios-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moltin%2Fios-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moltin%2Fios-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moltin%2Fios-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moltin","download_url":"https://codeload.github.com/moltin/ios-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248610810,"owners_count":21132998,"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","commerce","ecommerce","headless","ios","moltin","sdk","swift"],"created_at":"2024-10-14T11:08:13.854Z","updated_at":"2025-10-30T20:43:58.073Z","avatar_url":"https://github.com/moltin.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://www.elasticpath.com/themes/custom/bootstrap_sass/logo.svg\" alt=\"\" width=\"400\" /\u003e\n\n# Elastic Path Commerce Cloud iOS Swift SDK\n\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Moltin.svg)](https://img.shields.io/cocoapods/v/Moltin.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![follow on Twitter](https://img.shields.io/twitter/follow/elasticpath?style=social\u0026logo=twitter)](https://twitter.com/intent/follow?screen_name=elasticpath)\n\n\u003e A simple to use iOS/tvOS/watchOS SDK to help get you off the ground quickly and efficiently with your Elastic Path Commerce Cloud written in Swift.\n\n📚 [API reference](https://documentation.elasticpath.com/commerce-cloud/docs/developer/get-started/sdk.html#officially-supported-sdk) \u0026mdash; 📚 [Elastic Path Commerce Cloud](https://www.elasticpath.com)\n\n# Requirements\n\n- iOS 10.0+ / tvOS 10.0+ / watchOS 3.0+\n- Swift 4.0+\n\n# Installation\n\n## Cocoapods\n\nAdd the following to your `Podfile`:\n```\npod 'Moltin', '~\u003e 3.1.2'\n```\n\nOr, quickly try out our examples:\n```bash\npod try Moltin\n```\n## Carthage\n\nAdd the following to your `Cartfile`:\n```\ngithub \"Moltin/ios-sdk\" ~\u003e 3.1.2\n```\n## Swift Package Manager\n\nAdd the following to your `dependencies` value in `Package.swift`:\n```swift\ndependencies: [\n    .package(url: \"https://github.com/moltin/ios-sdk.git\", from: \"3.1.2\")\n]\n```\n\n# Usage\n\n## Making a request\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\n\nmoltin.product.all { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n\nmoltin.product.get(\"\u003cproduct ID\u003e\") { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n\nmoltin.product.tree { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n## Checking out \u0026 Payment\n\nPaying for a cart is a two step process in Moltin.\n\nFirst, check out your cart, which will return you an order:\n\n```swift\nself.moltin.cart.checkout(\n    cart: ...,\n    withCustomer: ...,\n    withBillingAddress: ...,\n    withShippingAddress: ...) { (result) in\n    switch result {\n        case .success(let order):\n            ...\n        default: break\n    }\n}\n```\n\nNow that you have an order, you can pay for your order. Moltin providers several gateways for you to use:\n\n- Stripe\n- BrainTree\n- Adyen\n- Manual\n\nOnce you've chosen your payment gateway, you can fulfil one of Moltin's `PaymentMethod`'s:\n\n```swift\nlet paymentMethod = StripeToken(withStripeToken: ...)\n```\n\nYou can then use this payment method to pay for an order:\n\n```swift\nself.moltin.cart.pay(\n    forOrderID: order.id,\n    withPaymentMethod: paymentMethod) { (result) in\n    ...\n}\n```\n\n## Config\n\nThe basic way to set up the Moltin SDK is to create an instance of the `Moltin` class with your client ID and optionally the locale of the application. However, if you'd like to change additional details of the SDK, such as the URL of your `Moltin` instance, you can do so by passing in `MoltinConfig`.\n\n```swift\nlet moltin = Moltin(withClientID: ...) // Takes Locale.current\n```\n\n```swift\nlet moltin = Moltin(withClientID: ..., withLocale: ...)\n```\n\n```swift\nlet config = MoltinConfig(\n    clientID: ...,\n    scheme: ...,\n    host: ...,\n    version: ...,\n    locale: ...)\n\nlet moltin = Moltin(withConfiguration: config)\n```\nOr:\n```swift\nlet config = MoltinConfig.default(\n    withClientID: ...,\n    withLocale: ...)\n\nlet moltin = Moltin(withConfiguration: config)\n```\n\n## Available Resources\n- Brands\n- Carts\n- Categories\n- Collections\n- Currencies\n- Files\n- Flows\n- Fields\n- Entries\n- Products\n\n# Authentication\n\nAuthentication is handled silently for you as part of the SDK. The SDK will cache credentials to ensure that it is not making unnecessary requests.\n\nThe iOS SDK only supports `Implicit` authentication currently.\n\n# Filtering\n\n## Operations\n- Filter\n- Sort\n- Offset / Limit\n- Include\n\n## Filter\n```swift\nmoltin.product.filter(operator: .eq, key: \"name\", value: \"ProductName\").all {\n   ...\n}\n```\n\n## Sort\n```swift\nmoltin.product.sort(\"order\").all {\n   ...\n}\n```\n```swift\nmoltin.product.sort(\"-order\").all {\n   ...\n}\n```\n\n## Offset / Limit\n\n```swift\nmoltin.product.limit(10).offset(20).all {\n    ...\n}\n```\n\n## Include\n\n```swift\nmoltin.product.include([.mainImage, .files]).all {\n    ...\n}\n```\n\n## Combining Operations\n\n```swift\nmoltin.product.sort(\"-name\").include([.mainImage]).limit(20).all {\n   ...\n}\n```\n\n# Flows\n\nIf you've implemented a custom field on a resource by using flows, you can cast this to a type of your choice by type-hinting your result, so long as this type conforms to `Codable`:\n\n```swift\nmoltin.product.all { (result: Result\u003cPaginatedResponse\u003c[MyCustomProduct]\u003e\u003e) in\n    switch result {\n        case .success(let response):\n            print(response.data) // [MyCustomProduct]\n        case .failure(_):\n            break\n    }\n}\n```\n\n```swift\nmoltin.product.get(forID: \"\u003cyour ID\u003e\") { (result: Result\u003cMyCustomProduct\u003e) in\n    switch result {\n    case .success(let response):\n        print(response) // MyCustomProduct\n    case .failure(_):\n        break\n    }\n```\n\nWe recommend ensuring that your types extend from our base types for safety, then you implement the `required init(from decoder: Decoder)`:\n\n```swift\nclass MyCustomProduct: moltin.Product {\n    let author: Author\n\n    enum ProductCodingKeys : String, CodingKey {\n        case author\n    }\n\n    required init(from decoder: Decoder) throws {\n        let container = try decoder.container(keyedBy: ProductCodingKeys.self)\n        self.author = try container.decode(Author.self, forKey: .author)\n        try super.init(from: decoder)\n    }\n}\n```\n\nThis will allow you to add additional types as you need, but ensures the base type, such as product, is still parsed correctly.\n\n# Examples\n\nThe Swift SDK is a community-supported software development kit for Elastic Path Commerce Cloud (formerly Moltin). The following examples show you how to use the SDK to make requests to the Commerce Cloud APIs.\n\nFor details about the endpoints, objects, and responses, see the [Elastic Path Commerce API Reference](https://documentation.elasticpath.com/commerce-cloud/docs/api/index.html).\n\n- [Basics](#basics)\n    - [Includes](#includes)\n    - [Pagination](#pagination)\n    - [Filtering](#filtering)\n    - [Sorting](#sorting)\n    - [Tokens](#tokens)\n- [Currency](#currency)\n- [Products](#products)\n- [Brands](#brands)\n- [Categories](#categories)\n- [Collections](#collections)\n- [Carts](#carts)\n- [Customers](#customers)\n- [Payments](#payments)\n\n## Basics\n\n### Includes\n\nExamples of using `include` with resources. For more information, see [Includes](https://documentation.elasticpath.com/commerce-cloud/docs/api/basics/includes.html).\n\n#### Include category products\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nmoltin.category.include([.products]).get(forID: id) { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n#### Include product main_image\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nmoltin.product.include([.main_image]).all { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n#### Multiple includes\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nmoltin.product.include([.main_image, .category]).all { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n### Pagination\n\nExamples of using pagination with resources. For more information, see [Pagination](https://documentation.elasticpath.com/commerce-cloud/docs/api/basics/pagination.html).\n\n#### Get all categories, two per page\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product.limit(2).all {\n  // Do something\n}\n```\n\n#### Get products 21-30\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product.limit(10).offset(20).all {\n  // Do something\n}\n```\n\n### Filtering\n\nExamples of using different `filter` operators. For more information, see [Filtering](https://documentation.elasticpath.com/commerce-cloud/docs/api/basics/filtering.html).\n\n#### The `eq` operator\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product.filter(operator: .eq, key: \"commodity_type\", value: \"digital\").all {\n  // Do something\n}\n```\n\n#### The `like` operator - A string *begins with* a specified value\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product.filter(operator: .like, key: \"sku\", value: \"SHOE_DECK_*\").all {\n  // Do something\n}\n```\n\n#### The `like` operator - A string *contains* a specified value\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product.filter(operator: .like, key: \"sku\", value: \"*_DECK_*\").all {\n  // Do something\n}\n```\n\n#### The `like` operator - A string *ends with* a specified value\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product.filter(operator: .like, key: \"sku\", value: \"*_RED\").all {\n  // Do something\n}\n```\n\n#### Chaining multiple operators\n\nCaution: This feature is currently in **Beta** and you should expect it to change.\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product\n  .filter(operator: .eq, key: \"commodity_type\", value: \"physical\")\n  .sort(\"created_at\")\n  .all {\n  // Do something\n}\n```\n\n### Sorting\n\nExamples of using `sort` with resources. For more information, see [Sorting](https://documentation.elasticpath.com/commerce-cloud/docs/api/basics/sorting.html).\n\n#### Sort products by `created_at` in ascending order\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product.sort(\"created_at\").all {\n  // Do something\n}\n```\n\n#### Sort products by `created_at` in descending order\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product.sort(\"-created_at\").all {\n  // Do something\n}\n```\n\n### Tokens\n\n#### Get an implicit access token\n\nAn `implicit` token can be thought of as a **Read only** token.\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\n```\n\n## Currency\n\n### Get a currency\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nmoltin.currency.get(forID: id) { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n### Get all currencies\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.currency.all { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n\n## Products\n\n### Get all products\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nself.moltin.product.include([.mainImage]).all { (result: Result\u003cPaginatedResponse\u003c[moltin.Product]\u003e\u003e) in\n   switch result {\n       case .success(let response):\n            DispatchQueue.main.async {\n                self.products = response.data ?? []\n            }\n        case .failure(let error):\n            print(\"Products error\", error)\n        }\n    }\n}\n```\n\n### Get all products that belong to a category\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.product.filter(operator: .eq, key: \"category.id\", value: \"xxxx\").all {\nresponse in\n// Do something\n}\n```\n\n### Get a product\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nmoltin.product.get(forID: id) { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n## Brands\n\n### Get all brands\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.brand.all { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n### Get a brand\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nmoltin.brand.get(forID: id) { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n## Categories\n\n### Get all categories\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.category.all { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n### Get a category\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nmoltin.category.get(forID: id) { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n### Get the categories tree\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.category.tree { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n## Collections\n\n### Get all collections\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.collection.all { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n### Get a collection\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nmoltin.collection.get(forID: id) { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n## Carts\n\n### Get a cart\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nself.moltin.cart.get(forID: AppDelegate.cartID, completionHandler: { (result) in\n    switch result {\n        case .success(let result):\n            DispatchQueue.main.async {\n                print(\"Cart:\", result)\n                }\n            case .failure(let error):\n                print(\"Cart error:\", error)\n            }\n    })\n```\n\n### Get cart items\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet referenceId = 'XXXX'\nself.moltin.cart.items(forCartID: referenceId) { (result) in\n    switch result {\n        case .success(let result):\n            DispatchQueue.main.async {\n                 print(\"Cart items:\", result.data)\n            }\n            case .failure(let error):\n                print(\"Cart error:\", error)\n            }\n        }\n    }\n```\n\n### Add a product to a cart\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet referenceId = 'XXXX'\nlet productId = 'XXXX'\nlet productQty = 'XXXX'\nself.moltin.cart.addProduct(withID: productId , ofQuantity: productQty, toCart: referenceId, completionHandler: { (_) in\n})\n```\n\n### Add a promotion to a cart\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet referenceId = 'XXXX'\nself.moltin.cart.addPromotion(code, toCart: referenceId) { (result) in\n    switch result {\n        case .success(let status):\n            DispatchQueue.main.async {\n                print(\"Promotion: (status)\")\n            }\n            default: break\n            }\n        }\n}\n```\n\n### Check out a cart\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nmoltin.cart.checkout(\n    cart: ...,\n    withCustomer: ...,\n    withBillingAddress: ...,\n    withShippingAddress: ...) { (result) in\n    switch result {\n        case .success(let order):\n            ...\n        default: break\n    }\n}\n```\n\n### Delete a cart\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet referenceId = 'XXXX'\nself.moltin.cart.deleteCart(referenceId, completionHandler: { (result)    in\n    switch result {\n        case .success(let result):\n            print(\"Cart error:\", result)\n        case .failure(let error):\n            print(\"Cart error:\", error)\n        }\n})\n```\n\n## Customers\n\n### Get a customer\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nmoltin.customer.get(forID: id) { result in\n    switch result {\n        case .success(let response):\n            print(response)\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n## Payments\n\n### Create a Stripe payment\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet paymentMethod = StripeToken(withStripeToken: ...)\nmoltin.cart.pay(\n    forOrderID: order.id,\n    withPaymentMethod: paymentMethod) { (result) in\n    ...\n}\n```\n\n### Create a manually authorize payment\n\n```swift\nlet moltin = Moltin(withClientID: \"\u003cyour client ID\u003e\")\nlet id = \"XXXX\"\nlet paymentMethod = ManuallyAuthorizePayment()\nmoltin.cart.pay(forOrderID: order.id, withPaymentMethod: paymentMethod) { (result) in\n    switch result {\n        case .success:\n            print(\"Success\")\n        case .failure(let error):\n            print(error)\n    }\n}\n```\n\n# Further Documentation\n\nFind more general documentation on the [API docs](https://documentation.elasticpath.com/commerce-cloud/docs/api/index.html).\n\n# Communication\n\n- If you need help with the SDK or the platform, get in touch on the [forum](https://forum.moltin.com)\n- If you found a bug with the SDK, open an issue on GitHub\n- If you have a feature request for the SDK, open an issue.\n- If you want to contribute to the SDK, submit a pull request.\n\n\n# License\n\nMoltin is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoltin%2Fios-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoltin%2Fios-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoltin%2Fios-sdk/lists"}