BinanceKlineDataClient is a Swift package for fetching candlestick (kline) data from Binance API.
You can use Swift Package Manager to integrate BinanceKlineDataClient into your Xcode project.
- In Xcode, select File > Swift Packages > Add Package Dependency.
- Enter the repository URL: https://github.com/AmeerRizvi/BinanceKlineDataClient
- Follow the prompts to specify the version and options.
You can also manually integrate BinanceKlineDataClient into your project by copying the source files.
import BinanceKlineDataClient
let client = BinanceKlineDataClient()
async {
do {
let candles = try await client.fetchCandles(symbol: "BTCUSDT")
print(candles)
} catch {
print("Error fetching data: \(error)")
}
}
You can fetch data for various trading pairs supported by Binance. For a comprehensive list of symbols, refer to the official Binance documentation.
The fetchCandles function requires specifying the symbol, interval, and limit. Interval refers to the duration between data points, and limit specifies the maximum number of data points to fetch.
"1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M"