/WKDStocksAPI

Swift Async API interface for finance.yahoo.com

Primary LanguageSwiftMIT LicenseMIT

WKDStocksAPI

api screenshot

A Swift Package / Library for asynchronous API access to finance.yahoo.com REST API endpoints. H/T to Alfian.

Features

  • Fetching chart data for an array of timeframes
  • Search for stock ticker symbols by company name
  • Fetch quotes via ticker symbol
  • Uses Swift concurrency (async/await)
  • Fetches raw JSON data
  • Available on iOS, macOS, macCatalyst, tvOS, watchOS
  • Use SwiftUI or UIKit

Available via Swift Package Manager (SPM)

Example

Initialize repository

Import and init the WKDStocksAPI.

import WKDStocksAPI

let api = WKDStocksAPI()

Fetch AAPL stocks for the most recent trading day

let appleChart1d = try await api.fetchChartData(tickerSymbol: "AAPL", range: .oneDay)

Search for ticker symbols using company name

let tickers = try await api.searchTicker(query: "Tesla")

Fetch quote details for multiple stock symbols

let quotes = api.fetchQuotes(symbols: "AAPL, TSLA, GOOG, MSFT")