{"id":29068613,"url":"https://github.com/mixinnetwork/bot-api-swift-client","last_synced_at":"2025-06-27T11:08:52.108Z","repository":{"id":44096603,"uuid":"488847464","full_name":"MixinNetwork/bot-api-swift-client","owner":"MixinNetwork","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-10T15:39:50.000Z","size":224,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-22T06:54:12.956Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/MixinNetwork.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":"2022-05-05T05:49:29.000Z","updated_at":"2022-07-11T14:08:31.000Z","dependencies_parsed_at":"2022-08-25T10:50:22.455Z","dependency_job_id":null,"html_url":"https://github.com/MixinNetwork/bot-api-swift-client","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/MixinNetwork/bot-api-swift-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MixinNetwork%2Fbot-api-swift-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MixinNetwork%2Fbot-api-swift-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MixinNetwork%2Fbot-api-swift-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MixinNetwork%2Fbot-api-swift-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MixinNetwork","download_url":"https://codeload.github.com/MixinNetwork/bot-api-swift-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MixinNetwork%2Fbot-api-swift-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262244918,"owners_count":23281028,"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":[],"created_at":"2025-06-27T11:08:42.470Z","updated_at":"2025-06-27T11:08:52.100Z","avatar_url":"https://github.com/MixinNetwork.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bot-api-swift-client\n\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/MixinAPI.svg)](https://cocoapods.org/pods/MixinAPI)\n\nThe [Mixin Network](https://mixin.one/) based wallet allows for the rapid construction of decentralized wallets, decentralized on-chain exchanges, and other products.\n\n# Requirements\n- iOS 13.0 or later\n\n# Installation\n\n## Cocoapods\nAdd it in Podfile\n```\npod 'MixinAPI'\n```\n\n# Usage\n```swift \nlet client = Client(userAgent: \"YourApp 0.1.0\")\nlet iterator = CurrentTimePINIterator()\nlet session = try API.AuthenticatedSession(userID: userID,\n                                           sessionID: sessionID,\n                                           pinToken: pinToken,\n                                           privateKey: privateKey,\n                                           client: client,\n                                           hostStorage: WalletHost(),\n                                           pinIterator: iterator,\n                                           analytic: consoleOutput)\nlet api = API(session: session)\n\napi.account.me { result in\n    print(result)\n}\n```\n\n# Demo\nSome basic usages are demonstrated with the demo. Follow the steps below to try it:\n1. Clone the repo\n2. Run `pod install` in the repo's root folder\n3. Open `MixinAPI.xcworkspace` generated by previous step\n4. Fill your credentials in [AccountViewModel.swift](https://github.com/MixinNetwork/bot-api-swift-client/blob/main/WalletDemo/WalletDemo/View%20Model/AccountViewModel.swift)\n5. Run\n\n# About PIN \nA 6-digit PIN is required when a user is trying to transfer assets, the code functions pretty much like a private key, not retrievable if lost.\n\n- There is a time lock for PIN errors. If you have failed 5 times a day, do not try again, even the PIN is correct after 5 times, an error will be returned. Repeating more times will cause a longer lock time. It is recommended that users write down the tried PIN and try again the next day.\n- Once a PIN is lost, it can never be retrieved. It is recommended that the developer let each user enter it regularly to help memorize it. During the initial setting, make sure to let the user enter it more than 3 times and remind the user that it cannot be retrieved if lost\n- For asset security, it is recommended to remind users not to set PINs that are too simple or common combinations, such as 123456, 111222.\n\n# Support\n- Report bugs in a [Github issue](https://github.com/MixinNetwork/bot-api-swift-client/issues/new).\n- Access our developers group of Mixin ID 7000104112.\n\n# API Essentials\n\n## Overview\nAPIs are grouped and provided through an `API` object. Initialize it with a valid session to access them.\n\n## Authenticated Session\nYou need to provide several credentials to intialize an `API.AuthenticatedSession`.\n- `userID` \n\u003e `client_id` provided by developer's dashboard for bots, or `user_id` of messenger users.\n- `sessionID`\n- `pinToken`\n- `privateKey`\n\u003e An ed25519 private key, which provided by developer's dashboard for bots, or generated by calling `Ed25519PrivateKey()` for messenger users.\n- `hostStorage` \n\u003e Stores current host index. When a bad network is detected, API may try again by switching to another host. \n\u003e See [WalletHost.swift](https://github.com/MixinNetwork/bot-api-swift-client/blob/main/WalletDemo/WalletDemo/Foundation/WalletHost.swift) for example.\n- `pinIterator` \n\u003e PIN is encrypted with an iterator, which must be incremental and greater than 0. You can pick `CurrentTimePINIterator` to use the current system time as iterator's value, or implement one by yourself with custom value provided. Custom PIN iterator should conforms to protocol `PINIterator`, and provide an incremented value each time when `value()` is called.\n\n## Notifications\n- `API.unauthorizedNotification` \n\u003e This notification will be posted when the session is considered unauthorized. This may happens when a bot's credential is reset. You can tear down UI components when this notification is received.\n- `API.clockSkewDetectedNotification`\n\u003e Mixin API must be called with system time being accurated, otherwise all requests will be failed. If a significant clock skew is detected, this notification will be posted, you may observe this notification to tell end users to check their time settings.\n\n# Account APIs\n\n- `AccountWorker.me(completion:)`\n\u003e Get the current user's personal information.\n- `AccountWorker.update(fullName:biography:avatarBase64:completion:)`\n\u003e Update user's profile.\n- `AccountWorker.verify(pin:completion:)`\n\u003e Verify PIN.\n- `AccountWorker.updatePIN(old:new:completion:)`\n\u003e Update PIN. \n\n\u003e ℹ️ `old` should be nil if `User.hasPIN` is false.\n- `AccountWorker.logs(offset:category:limit:completion:)`\n\u003e Get user's log.\n\n# Asset APIs\n\n- `AssetWorker.assets(queue:completion:)`\n\u003e Request user's asset list.\n\n\u003e ℹ️ Assets responded with this API may have an empty `depositEntries`. If you want a deposit address, call `AssetWorker.asset(assetID:completion:)` with a specific asset ID to get one.\n- `AssetWorker.snapshots(limit:offset:assetID:opponentID:destination:tag:queue:completion:)`\n\u003e Get the snapshots by several filters. `opponent` and `destination`, `tag` can't use together, both of them don't support order.\n- `AssetWorker.fee(assetID:completion:)`\n\u003e Get the specified asset's fee.\n- `AssetWorker.pendingDeposits(assetID:destination:tag:completion:)`\n\u003e Get public network-wide deposit records.\n- `AssetWorker.search(keyword:completion:)`\n\u003e Search asset with specific keyword.\n- `AssetWorker.topAssets(completion:)`\n\u003e Get current trendings.\n- `AssetWorker.fiats(completion:)`\n\u003e Returns a list of all fiat exchange rates based on US Dollar.\n- `AssetWorker.ticker(asset:offset:completion:)`\n\u003e Get the historical price of a given asset.\n\n# Collectible APIs\n\n- `CollectibleWorker.sign(requestID:pin:completion:)`\n\u003e Sign collectible request.\n- `CollectibleWorker.unlock(requestID:pin:completion:)`\n\u003e Unlock collectible request.\n- `CollectibleWorker.cancel(requestID:completion:)`\n\u003e Cancel collectible request.\n- `CollectibleWorker.token(tokenID:)`\n\u003e Get the information of the collectible.\n\n# Multisig APIs\n\n- `MultisigWorker.sign(requestID:pin:completion:)`\n\u003e Sign multisig request.\n- `MultisigWorker.unlock(requestID:pin:completion:)`\n\u003e Send multisig unlocking request.\n- `MultisigWorker.cancel(requestID:completion:)`\n\u003e Send multisig cancelling request.\n\n# Payment APIs\n\n- `PaymentWorker.payments(assetID:opponentID:amount:traceID:)`\n\u003e Transfer to an opponent with specific ID.\n- `PaymentWorker.payments(assetID:addressID:amount:traceID:)`\n\u003e Transfer to an address with specific ID.\n- `PaymentWorker.transactions(transactionRequest:pin:completion:)`\n\u003e Transfer to a specified multisig address.\n- `PaymentWorker.transfer(assetID:opponentID:amount:memo:pin:traceID:completion:)`\n\u003e Transfer to an opponent with specific ID.\n\n# Snapshot APIs\n\n- `SnapshotWorker.snapshot(snapshotID:completion:)`\n\u003e Get the snapshot of a user by id.\n\n\u003e ℹ️ If the snapshot is not of the current user, `MixinError.forbidden` will be returned.\n- `SnapshotWorker.trace(traceID:)`\n\u003e Get the snapshot corresponding to specific trace ID.\n\n# Withdrawal APIs\n\n- `WithdrawalWorker.address(addressID:completion:)`\n\u003e Get the address with specifice id.\n- `WithdrawalWorker.addresses(assetID:completion:)`\n\u003e Get a list of withdrawal addresses for the given asset.\n- `WithdrawalWorker.save(address:completion:)`\n\u003e Create a new withdrawal address.\n- `WithdrawalWorker.withdrawal(withdrawal:completion:)`\n\u003e Submit a withdrawal request.\n\n\u003e ℹ️ It costs fee to withdrawal. To get the fee, use `AssetWorker.fee(assetID:completion:)`.\n- `WithdrawalWorker.delete(addressID:pin:completion:)`\n\u003e Delete a specified address by it's id.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixinnetwork%2Fbot-api-swift-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixinnetwork%2Fbot-api-swift-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixinnetwork%2Fbot-api-swift-client/lists"}