This is a library that leverages Yahoo Finance REST API and provides very simple and Swiftly way to interact with it.
- Fetch Chart data for 1d, 1w, 1mo, 3mo, 6mo, 1y, 2y, 5y, YTD, max.
- Search Ticker using query.
- Fetch quotes using ticker symbols.
- Swift Async Await Interface.
- Fetch Raw JSON data.
First of all, you need to import and initalize the StocksAPI
.
import StocksAPI
let api = StocksAPI()
let tesla1wkChart = try await api.fetchChartData(tickerSymbol: "TSLA", range: .oneWeek)
let tickers = try await api.searchTickers(query: "TESLA")
let quotes = try await api.fetchQuotes(symbols: "TSLA,GOOG,AAPL,MSFT")
Here is how you proceed to add it to your project:
- File > Swift Packages > Add Package Dependency
- Add https://github.com/Learnin-IOS/StocksAPI.git
- Select "Main" branch
This is entirely Powered by Yahoo Finance API https://www.yahoo.com/?ilc=401
Yahoo Finance REST API Postman Collection Download Link: https://drive.google.com/file/d/1GzLBLGSE4nRjjj-bI0nSV0Un5VGiKO5j/view