{"id":19403174,"url":"https://github.com/4rays/swift-fsrs","last_synced_at":"2026-03-05T14:31:09.477Z","repository":{"id":254501129,"uuid":"846722992","full_name":"4rays/swift-fsrs","owner":"4rays","description":"A Swift implementation of the FSRS spaced repetition algorithm","archived":false,"fork":false,"pushed_at":"2024-10-25T12:32:09.000Z","size":21,"stargazers_count":30,"open_issues_count":2,"forks_count":5,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-03T00:32:26.939Z","etag":null,"topics":["dsr","flashcards","fsrs","spaced-repetition","spaced-repetition-algorithm"],"latest_commit_sha":null,"homepage":"","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/4rays.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":"2024-08-23T20:19:45.000Z","updated_at":"2026-02-17T14:28:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"be38b4ac-2615-423b-a95d-ba68294d28ad","html_url":"https://github.com/4rays/swift-fsrs","commit_stats":null,"previous_names":["4rays/swift-fsrs"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/4rays/swift-fsrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rays%2Fswift-fsrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rays%2Fswift-fsrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rays%2Fswift-fsrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rays%2Fswift-fsrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4rays","download_url":"https://codeload.github.com/4rays/swift-fsrs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rays%2Fswift-fsrs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30130308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T12:40:50.676Z","status":"ssl_error","status_checked_at":"2026-03-05T12:39:32.209Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["dsr","flashcards","fsrs","spaced-repetition","spaced-repetition-algorithm"],"created_at":"2024-11-10T11:27:32.055Z","updated_at":"2026-03-05T14:31:09.040Z","avatar_url":"https://github.com/4rays.png","language":"Swift","readme":"# SwiftFSRS\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F4rays%2Fswift-fsrs%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/4rays/swift-fsrs) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F4rays%2Fswift-fsrs%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/4rays/swift-fsrs)\n\nAn idiomatic and configurable Swift implementation of the [FSRS spaced repetition algorithm](https://github.com/open-spaced-repetition/fsrs4anki/wiki/The-Algorithm).\n\n## Installation\n\nAdd the following to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/4rays/swift-fsrs\")\n]\n```\n\n## Usage\n\n### The Scheduler\n\nThe workhorse of the algorithm is the `Scheduler` protocol. It takes a card and a review and returns a new card and review log object.\n\nOut of the box, the library ships with a short-term and a long-term scheduler.\nUse the short-term scheduler when you want to support multiple reviews of the same card in a single day. Use the long-term scheduler otherwise.\n\nHere is how you can create your own scheduler:\n\n```swift\nimport SwiftFSRS\n\nstruct CustomScheduler: Scheduler {\n  func schedule(\n    card: Card,\n    algorithm: FSRSAlgorithm,\n    reviewRating: ReviewRating,\n    reviewTime: Date\n  ) -\u003e CardReview {\n    // Implement your custom algorithm here\n  }\n}\n```\n\n### The Algorithm\n\nThe library implements `v5` of the FSRS algorithm out of the box. It can also support custom implementations.\n\n```swift\nimport SwiftFSRS\n\nlet customAlgorithm = FSRSAlgorithm(\n  decay: -0.5,\n  factor: 19 / 81,\n  requestRetention: 0.9,\n  maximumInterval: 36500,\n  parameters: [/* ... */]\n)\n\nscheduler.schedule(\n  card: card,\n  algorithm: customAlgorithm,\n  reviewRating: .good,\n  reviewTime: Date()\n)\n```\n\n### Scheduling a Review\n\nTo schedule a review for a given card:\n\n```swift\nimport SwiftFSRS\n\nlet scheduler = LongTermScheduler()\nlet card = Card()\n\nlet review = scheduler.schedule(\n  card: card,\n  algorithm: .v5,\n  reviewRating: .good, // or .easy, .hard, .again\n  reviewTime: Date()\n)\n\nprint(review.card)\nprint(review.log)\n```\n\nCards don't have any content properties and are meant to be properties of your own type.\n\n```swift\nimport SwiftFSRS\n\nstruct MyFlashCard {\n  let question: String\n  let answer: String\n  let fsrsCard: Card\n}\n```\n\n## License\n\nSwiftFSRS is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4rays%2Fswift-fsrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4rays%2Fswift-fsrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4rays%2Fswift-fsrs/lists"}