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.
Authenticating with a paid plan
Paid plans (Starter / Pro / Business / Ultimate / Enterprise) live on a separate hostname,https://api-pro.coinpaprika.com/v1/, and require an API key in the Authorization header. Send the bare key — a Bearer prefix is rejected by the WAF.
The high-level Coinpaprika.API static methods don’t currently accept a key. To call paid endpoints, drop down to the CoinpaprikaNetworking Request<Model> constructor with .bearer(token:) and point it at the Pro base URL. The package exposes CoinpaprikaNetworking as a separate library product, so add it to your target’s dependencies alongside Coinpaprika.
Coinpaprika.API), keep using the high-level static API against the default base URL.
Common Use Cases
Ticker Data for a Specific Coin
Coin Details
Historical Ticker Data
Historical endpoints require a paid plan. The high-levelCoinpaprika.API.historicalTicks(...) shape is shown below for the request structure; to actually authenticate, build a Request<Tick> against the Pro base URL using the .bearer(token:) pattern from “Authenticating with a paid plan”.
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.
FAQs
How do I use the Pro API in Swift?
How do I use the Pro API in Swift?
The high-level
Coinpaprika.API static methods don’t currently accept a key. Use CoinpaprikaNetworking’s Request<Model> constructor with .bearer(token:) and the https://api-pro.coinpaprika.com/v1/ base URL. See the “Authenticating with a paid plan” section above.Where can I find coin IDs for methods like ticker(id:)?
Where can I find coin IDs for methods like ticker(id:)?
Use the Coverage Checker to obtain canonical IDs (e.g.,
btc-bitcoin).How do I fetch historical ticks/ohlcv?
How do I fetch historical ticks/ohlcv?
Historical endpoints require a paid plan. Build a
Request<Model> against the Pro base URL with .bearer(token:) auth (see the “Authenticating with a paid plan” section), pointing at tickers//historical or coins//ohlcv/historical with start/end/quote parameters.What is the recommended error handling?
What is the recommended error handling?
Inspect the failure case of
Result and map to app errors; for 429 responses, back off and retry.Requirements
- iOS 10.0+ / macOS 10.12+ / watchOS 3.0+ / tvOS 10.0+
- Swift 4.2+