{"id":20639218,"url":"https://github.com/alexdremov/swiftyfinance","last_synced_at":"2025-07-05T08:33:22.635Z","repository":{"id":59653444,"uuid":"286818711","full_name":"alexdremov/SwiftYFinance","owner":"alexdremov","description":"The best Yahoo Finance library with the power of Swift","archived":false,"fork":false,"pushed_at":"2025-03-09T21:24:42.000Z","size":6884,"stargazers_count":66,"open_issues_count":1,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-20T12:01:11.196Z","etag":null,"topics":["api","finance-api","ios","mobile","mobile-app","stock","stock-api","stock-market","swift","yahoo","yahoo-finance","yahoo-finance-api"],"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/alexdremov.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,"zenodo":null}},"created_at":"2020-08-11T18:25:44.000Z","updated_at":"2025-06-20T10:29:45.000Z","dependencies_parsed_at":"2024-11-16T15:23:18.717Z","dependency_job_id":"094198d3-78b0-4b5e-853d-030cefb811b1","html_url":"https://github.com/alexdremov/SwiftYFinance","commit_stats":null,"previous_names":["alexroar/swiftyfinance"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/alexdremov/SwiftYFinance","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdremov%2FSwiftYFinance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdremov%2FSwiftYFinance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdremov%2FSwiftYFinance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdremov%2FSwiftYFinance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexdremov","download_url":"https://codeload.github.com/alexdremov/SwiftYFinance/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdremov%2FSwiftYFinance/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263710479,"owners_count":23499701,"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","finance-api","ios","mobile","mobile-app","stock","stock-api","stock-market","swift","yahoo","yahoo-finance","yahoo-finance-api"],"created_at":"2024-11-16T15:23:01.245Z","updated_at":"2025-07-05T08:33:22.613Z","avatar_url":"https://github.com/alexdremov.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftYFinance\n\n[![codecov](https://img.shields.io/codecov/c/github/AlexRoar/SwiftYFinance)](https://codecov.io/gh/AlexRoar/SwiftYFinance)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/AlexRoar/SwiftYFinance/swift.yml)\n\n## Requirements\n\nI used Swift 5.0 and backward compatibility is not guranteed. IOS 13+\n\n## Installation\n\nSwiftYFinance is available through [Swift Package Manager](https://swift.org/package-manager/).\n\nAdd dependency to your Package file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/AlexRoar/SwiftYFinance\", .upToNextMajor(from: \"1.4.0\")),\n]\n```\n\nOr add dependency to your XCode project: `File` \u003e `Swift Packages` \u003e `Add Package Dependency`\n\n```\nhttps://github.com/AlexRoar/SwiftYFinance\n```\n## Basic Usage\n\n### Search\n```swift\n/*\n* Main class of SwiftYFinance. Asynchronous method's callback always will\n* have format: (Some Data?, Error?). If error is non-nil, then data is going to be nil.\n* Review Error description to find out what's wrong.\n* Synchronous API is also provided. The only difference is that it blocks the thread and\n* returns data rather than passing it to the callback.\n*/\nimport SwiftYFinance\n\n// Searches quote in Yahoo finances and returns found results\nSwiftYFinance.fetchSearchDataBy(searchTerm: \"AAPL\", quotesCount: 20) {\n    data, error in\n    /*\n    callback: ([YFQuoteSearchResult]?, Error?) -\u003e Void\n    struct YFQuoteSearchResult{\n        var symbol: String?\n        var shortname: String?\n        var longname: String?\n        var exchange: String?\n        var assetType: String?\n    }\n    */\n    if error != nil{\n        print(error!.localizedDescription)\n        return \n    }\n    print(data!.longname ?? \"No long name\")\n}\n```\n\nThe same thing but synchronously:\n\n```swift\nlet (data, error) = SwiftYFinance.syncFetchSearchDataBy(searchTerm: \"AAPL\", quotesCount: 20)\nif error != nil{\n    print(error!.localizedDescription)\n    return \n}\nprint(data!.longname ?? \"No long name\")\n```\n\n**Even though executing commands in the main thread synchronously is not the best practice, I added this feature to the project. It's on your account to write fast, non-freezing apps, so use synchronous methods wisely.**\n\nSearch for news is also awailable through `fetchSearchDataBy(searchNews:String, ...)`\n\n### Basic recent data\n\nFetches the most recent data about identifier collecting basic information.\n```swift\nSwiftYFinance.recentDataBy(identifier: \"AAPL\") {\n    data, error in\n    /*\n    data ~\u003e\n    struct RecentStockData{\n        var currency: String?\n        var symbol: String?\n        var exchangeName: String?\n        var instrumentType: String?\n        var firstTradeDate: Int?\n        var regularMarketTime: Int?\n        var gmtoffset: Int?\n        var timezone: String?\n        var exchangeTimezoneName: String?\n        var regularMarketPrice: Float?\n        var chartPreviousClose: Float?\n        var previousClose: Float?\n        var scale: Int?\n        var priceHint: Int?\n    }\n    */\n    if error != nil{\n        print(error!.localizedDescription)\n        return \n    }\n    print(data!.regularMarketPrice ?? \"No regularMarketPrice\")\n}\n```\n\n### Chart data\n\nFetches chart data points\n```swift\nSwiftYFinance.chartDataBy(\n        identifier: \"AAPL\",\n        start: Date(...),\n        end: Date(...),\n        interval: .oneday) {\n    data, error in\n    /*\n    data ~\u003e[\n        struct StockChartData{\n            var date: Date?\n            var volume: Int?\n            var open: Float?\n            var close: Float?\n            var adjclose: Float?\n            var low: Float?\n            var high: Float?\n        }\n    ]\n    */\n    if error != nil{\n        print(error!.localizedDescription)\n        return \n    }\n    print(data![0]?.open ?? \"Open price is unavailable\")\n}\n```\n\n### Chart data at moment\n\nSometimes, you need to fetch data at some moment in the past. Use `chartDataBy(..., moment: Date, ...)` for that.\n\n```swift\nSwiftYFinance.chartDataBy(\n        identifier: \"AAPL\",\n        moment: Date(...),\n        futureMargin: TimeInterval(...)\n        ) {\n    data, error in\n    /*\n    data ~\u003e[\n        struct StockChartData{\n            var date: Date?\n            var volume: Int?\n            var open: Float?\n            var close: Float?\n            var adjclose: Float?\n            var low: Float?\n            var high: Float?\n        }\n    ]\n    */\n    if error != nil{\n        print(error!.localizedDescription)\n        return \n    }\n    print(data![0]?.open ?? \"Open price is unavailable\")\n}\n```\n\n### Identifier Summary\n\nThis part of API is MASSIVE. Yahoo Finance has a lot of summary modules and I implemented several of them. Still, you can fetch data from raw JSON parameter.\n\nI will add new modules with every version. Currently, only essential modules are implemented.\n\n| Module                            | Support | Module                            | Support |\n|-----------------------------------|---------|-----------------------------------|---------|\n| calendarEvents                    | :white_check_mark: | recommendationTrend               | :white_check_mark: |\n| summaryProfile                    | :white_check_mark: | quoteType                         | :white_check_mark: |\n| industryTrend                     | :white_check_mark: | price                             | :white_check_mark: |\n| summaryDetail                     | :white_check_mark: | incomeStatementHistoryQuarterly   | :x: |\n| assetProfile                      | :x: | balanceSheetHistoryQuarterly      | :x: |\n| incomeStatementHistory            | :x: | cashFlowStatementHistory          | :x: |\n| balanceSheetHistory               | :x: | cashFlowStatementHistoryQuarterly | :x: |\n| financialData                     | :x: | secFilings                        | :x: |\n| upgradeDowngradeHistory           | :x: | institutionOwnership              | :x: |\n| fundOwnership                     | :x: | majorDirectHolders                | :x: |\n| majorHoldersBreakdown             | :x: | insiderTransactions               | :x: |\n| insiderHolders                    | :x: | netSharePurchaseActivity          | :x: |\n| sectorTrend                       | :x: | earnings                          | :x: |\n| companyOfficers                   | :x: | earningsHistory                   | :x: |\n| earningsTrend                     | :x: | indexTrend                        | :x: |\n| symbol                            | :x: | fundProfile                       | :x: |\n| topHoldings                       | :x: | fundPerformance                   | :x: |\n| defaultKeyStatistics              | :x: |                                   |     |\n\nYou can fetch modules by calling `summaryDataBy(...)`\n\n```swift\nSwiftYFinance.summaryDataBy(identifier: \"AAPL\", selection: .all){\ndata, error in\n    if error != nil{\n        print(error!.localizedDescription)\n        return\n    }\n    print(data)\n    /*\n    data ~\u003e\n    struct IdentifierSummary {\n        var recommendationTrend:RecommendationTrend?\n        var summaryProfile:SummaryProfile?\n        var quoteType:QuoteType?\n        var price:Price?\n        var indexTrend:IndexTrend?\n        var calendarEvents:CalendarEvents?\n        var summaryDetail:SummaryDetail?\n        var dataStorage:JSON?\n    }\n    */\n\n    // Raw JSON:\n    print(data.dataStorage)\n}\n```\n\nSeveral types of selection are available. `.all` will fetch every method, even not supported yet so that you can get data from raw JSON. You can select `.supported`, then only supported data will be fetched. Also, you can specify specific module (ex: `.price`) or list of modules (ex: `[.price, .summaryDetail]`)\n\n## Author\n\nAleksandr Dremov, dremov.me@gmail.com\n\n## License\n\nSwiftYFinance 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%2Falexdremov%2Fswiftyfinance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexdremov%2Fswiftyfinance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexdremov%2Fswiftyfinance/lists"}