CoinPaprika Swift SDK
The official Swift client library for the CoinPaprika API provides convenient, static access to cryptocurrency market data.Installation
Swift Package Manager (SPM)
Add the following package dependency to yourPackage.swift
file or via Xcode:
CocoaPods
Add the following line to your Podfile and runpod install
:
Quick Start
First, import the library:Coinpaprika.API
object. All requests are asynchronous and return a Result
type in a closure.
Using the Pro API
To use the Pro API, you must manually change the base URL in theConfiguration
object before making any requests. This should be done once when your app launches.
Common Use Cases
Ticker Data for a Specific Coin
Coin Details
Historical Ticker Data
Note: Accessing historical data requires using the Pro API.Search
Error Handling
TheResult
object in the completion handler provides a detailed RequestError
case for failures.
Async/Await Support (iOS 13+ / macOS 10.15+)
The SDK supports modern concurrency withasync/await
.
Available Methods
Global Data
global()
- Get global market overview.
Coins
coins(additionalFields:)
- List all coins.coin(id:)
- Get coin by ID.coinTwitter(id:)
- Get a coin’s Twitter timeline.coinEvents(id:)
- Get coin events.coinExchanges(id:)
- Get exchanges for a coin.coinMarkets(id:quotes:)
- Get markets for a coin.
Tickers
tickers(quotes:page)
- Get all tickers, with optional pagination.ticker(id:quotes:)
- Get a specific ticker.historicalTicks(...)
- Get historical tickers.
Exchanges
exchanges(quotes:)
- List all exchanges.exchange(id:quotes:)
- Get an exchange by ID.exchangeMarkets(id:quotes:)
- Get markets for an exchange.
People & Tags
person(id:)
- Get a person by ID.tags(additionalFields:)
- List all tags.tag(id:additionalFields:)
- Get a tag by ID.
Search & Tools
search(...)
- Search across categories.priceConverter(...)
- Convert between currencies.
Requirements
- iOS 10.0+ / macOS 10.12+ / watchOS 3.0+ / tvOS 10.0+
- Swift 4.2+