This library provides convenient way to use Coinpaprika.com API in Swift.

Overview

Coinpaprika API Swift Client

Build Status codecov Version License Platform Carthage compatible Swift 5.0

Documentation | Repository | Installation

Usage

This library provides convenient way to use Coinpaprika.com API in Swift.

Coinpaprika delivers full market data to the world of crypto: coin prices, volumes, market caps, ATHs, return rates and more.

Import

Market Stats

import Coinpaprika

Coinpaprika.API.global().perform { (response) in
  switch response {
    case .success(let stats):
    // Successfully downloaded GlobalStats
    // stats.marketCapUsd - Market capitalization in USD
    // stats.volume24hUsd - Volume from last 24h in USD
    // stats.bitcoinDominancePercentage - Percentage share of Bitcoin MarketCap in Total MarketCap
    // stats.cryptocurrenciesNumber - Number of cryptocurrencies available on Coinpaprika
    case .failure(let error):
    // Failure reason as error
  }
}

Coins list

import Coinpaprika

Coinpaprika.API.coins().perform { (response) in
  switch response {
    case .success(let coins):
    // Successfully downloaded [Coin]
    // coins[0].id - Coin identifier, to use in ticker(id:) method
    // coins[0].name - Coin name, for example Bitcoin
    // coins[0].symbol - Coin symbol, for example BTC
    case .failure(let error):
    // Failure reason as error
  }
}

Ticker data for all coins

import Coinpaprika

Coinpaprika.API.tickers(quotes: [.usd, .btc]).perform { (response) in
  switch response {
    case .success(let tickers):
    // Successfully downloaded [Ticker]
    // tickers[0] - see the next method for Ticker properties
    case .failure(let error):
    // Failure reason as error
  }
}

Ticker data for selected coin

import Coinpaprika

Coinpaprika.API.ticker(id: "bitcoin-btc", quotes: [.usd, .btc]).perform { (response) in
  switch response {
    case .success(let ticker):
    // Successfully downloaded Ticker
    // ticker.id - Coin identifier, to use in ticker(id:) method
    // ticker.name - Coin name, for example Bitcoin
    // ticker.symbol - Coin symbol, for example BTC
    // ticker.rank - Position in Coinpaprika ranking (by MarketCap)
    // ticker.circulatingSupply - Circulating Supply
    // ticker.totalSupply - Total Supply
    // ticker.maxSupply - Maximum Supply
    // ticker.betaValue - Beta
    // ticker.lastUpdated - Last updated date
    //
    // Each Ticker could contain several Ticker.Quote (according to provided quotes parameter). To access to quote for given currency, use subscripting like:
    // - ticker[.usd] - Ticker.Quote in USD
    // - ticker[.btc] - Ticker.Quote in BTC
    // etc...
    //
    // So how to get this cryptocurrency price in USD and BTC?
    // - ticker[.usd].price - Coin price in USD
    // - ticker[.btc].price - Coin price in BTC
    //
    // Ticker.Quote contains following properties:
    // let currency: QuoteCurrency = .usd
    // - ticker[currency].price - Price
    // - ticker[currency].volume24h - Volume from last 24h
    // - ticker[currency].volume24hChange24h - Volume change in last 24h
    // - ticker[currency].marketCap - Market capitalization
    // - ticker[currency].marketCapChange24h - Market capitalization in last 24h
    // - ticker[currency].percentChange1h - Percentage price change in last 1 hour
    // - ticker[currency].percentChange12h - Percentage price change in last 12 hour
    // - ticker[currency].percentChange24h - Percentage price change in last 24 hour
    // - ticker[currency].percentChange7d - Percentage price change in last 7 days
    // - ticker[currency].percentChange30d - Percentage price change in last 30 days
    // - ticker[currency].percentChange1y - Percentage price change in last 1 year
    // - ticker[currency].athPrice - ATH price
    // - ticker[currency].athDate - ATH date
    // - ticker[currency].percentFromPriceAth - Percentage price change from ATH
    // - ticker[currency].volumeMarketCapRate - Volume/MarketCap rate
    case .failure(let error):
    // Failure reason as error
  }
}

Search

import Coinpaprika

Coinpaprika.API.search(query: "bitcoin", categories: [.coins, .exchanges, .icos, .people, .tags], limit: 20).perform { (response) in
  switch response {
    case .success(let searchResults):
    // Successfully downloaded SearchResults
    // searchResults.currencies - list of matching coins as [Search.Coin]
    // searchResults.icos - list of matching ICOs as [Search.Ico]
    // searchResults.exchanges - list of matching exchanges as [Search.Exchange]
    // searchResults.people - list of matching people as [Search.Person]
    // searchResults.tags - list of matching tags as [Search.Tag]
    case .failure(let error):
    // Failure reason as error
  }
}

More

Other endpoints could be found in CoinpaprikaAPI reference.

Installation

Swift Package Manager (SPM)

CoinpaprikaAPI is available through SPM. To install it, simply add the following dependency (for example in Xcode 11 built-in manager):

https://github.com/coinpaprika/coinpaprika-api-swift-client

Cocoapods

CoinpaprikaAPI is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'CoinpaprikaAPI'

Run pod install to integrate CoinpaprikaAPI with your workspace.

Carthage

CoinpaprikaAPI is available through Carthage. To install it, simply add the following line to your Carthage file:

github "coinpaprika/coinpaprika-api-swift-client"  

Run carthage update to build the framework and drag the built CoinpaprikaAPI.framework into your Xcode project.

License

CoinpaprikaAPI is available under the MIT license. See the LICENSE file for more info.

You might also like...
Modern Swift implementations of BIP39, BIP32, and BIP44
Modern Swift implementations of BIP39, BIP32, and BIP44

PLEASE NOTE! This is fork from KevinVitale/WalletKit Due to SPM (Swift package manager) and github restrictions it's impossible to add original KevinV

Swift UI component - Stories instagram, slideshow, crypto wallet intro
Swift UI component - Stories instagram, slideshow, crypto wallet intro

SwiftUI and Combine - Stories intro multi-platform widget Features Long tap - pause stories showcase Tap - next story Leeway - pause before start stor

BitcoinCore for Bitcoin, BitcoinCash(ABC), Litecoin and Dash wallet toolkit for Swift.

BitcoinCore for Bitcoin, BitcoinCash(ABC), Litecoin and Dash wallet toolkit for Swift. This is a full implementation of SPV node including wallet creation/restore, synchronization with network, send/receive transactions, and more.

XCTestExtensions is a Swift extension that provides convenient assertions for writing Unit Test.
XCTestExtensions is a Swift extension that provides convenient assertions for writing Unit Test.

XCTestExtensions Features XCTAssertEventually (that convenient assertions for writing Unit Test). Use "XCTAssertEventually", you can write asynchronou

A Swift package that provides convenient Lorem Ipsum text, images, colors and other placeholders for rapidly prototyping, building and testing your iOS applications.
A Swift package that provides convenient Lorem Ipsum text, images, colors and other placeholders for rapidly prototyping, building and testing your iOS applications.

Lorem Introducing Lorem, a placeholder generator library for iOS to help you rapidly prototype, build and test your iOS applications. By leveraging Sw

SwiftSocket library provides the easy way to use sockets on Apple platforms

SwiftSocket library provides as easy to use interface for socket based connections on server or client side. Supports both TCP and UDP sockets.

A framework to validate inputs of text fields and text views in a convenient way.

FormValidatorSwift The FormValidatorSwift framework allows you to validate inputs of text fields and text views in a convenient way. It has been devel

A framework to validate inputs of text fields and text views in a convenient way.

FormValidatorSwift The FormValidatorSwift framework allows you to validate inputs of text fields and text views in a convenient way. It has been devel

Handle in-app purchases in iOS in a convenient way

InAppPurchases Handle in-app purchases in iOS in a convenient way. Overview InAppPurchases covers all the basic aspects of in-app purchases in swift i

📷A simple and convenient way to manage your webcam's picture settings, right from your menu bar
📷A simple and convenient way to manage your webcam's picture settings, right from your menu bar

Viewfinder A simple and convenient way to manage your webcam's picture settings, right from your menu bar. About • Download • Building from Source • C

Lightbox is a convenient and easy to use image viewer for your iOS app
Lightbox is a convenient and easy to use image viewer for your iOS app

Lightbox is a convenient and easy to use image viewer for your iOS app, packed with all the features you expect: Paginated image slideshow. V

Swift-music - swift-music is a swift package that provides an easy-to-use API for music related developments.

🎼 swift-music Introduction swift-music is a swift package that provides an easy-to-use API for music related developments. Currently available module

IGStoryButtonKit provides an easy-to-use button with rich animation and multiple way inspired by instagram story/stories.
IGStoryButtonKit provides an easy-to-use button with rich animation and multiple way inspired by instagram story/stories.

Introduction Have you ever seen UI like instagram story, haven't you? Actually, features like instagram story have been implemented in many applicatio

MusicTheoryKit: a swift module that provides an easy-to-use API for most commonly used music terms

MusicTheoryKit Introduction MusicTheoryKit is a Swift framework that provides an easy-to-use API for most commonly used music terms. Create notes, ass

OysterKit is a framework that provides a native Swift scanning, lexical analysis, and parsing capabilities. In addition it provides a language that can be used to rapidly define the rules used by OysterKit called STLR

OysterKit A Swift Framework for Tokenizing, Parsing, and Interpreting Languages OysterKit enables native Swift scanning, lexical analysis, and parsing

Provides a custom presentation modifier that provides more options including full screen presentations. (iOS)

Presentation Also available as a part of my SwiftUI+ Collection – just add it to Xcode 13+ Provides a custom presentation modifier that provides more

AwaitKit is a powerful Swift library which provides a powerful way to write asynchronous code in a sequential manner.
AwaitKit is a powerful Swift library which provides a powerful way to write asynchronous code in a sequential manner.

AwaitKit is a powerful Swift library inspired by the Async/Await specification in ES8 (ECMAScript 2017) which provides a powerful way to write asynchronous code in a sequential manner.

ITunesFeedGenerator - This library provides very simple and Swiftly way to fetch feeds from iTunes Store

ITunesFeedGenerator This library provides very simple and Swiftly way to fetch feeds from iTunes Store: Most Played Songs. Top Free or Paid Books. Top

Convenient & secure logging during development & release in Swift 3, 4 & 5
Convenient & secure logging during development & release in Swift 3, 4 & 5

Colorful, flexible, lightweight logging for Swift 3, Swift 4 & Swift 5. Great for development & release with support for Console, File & cloud platfor

Comments
  • Need public properties in TickerHistory

    Need public properties in TickerHistory

    When using your library (install with Carthage), I can not access properties of TickerHistory because they are not public. I think we should add public access here like other models.

    opened by hlongvu 1
  • Update Module Name

    Update Module Name

    To align with Swift naming convention and avoid Module Name <> Main Class conflict we need to update Module Name.

    Module name will be changed from CoinpaprikaAPI to Coinpaprika. Main struct CoinapaprikaAPI.swift will be changed to API.swift.

    For better backward compatibility typealias CoinpaprikaAPI is also supported and will be translated to Coinpaprika.API.


    Fixed issues:

    • Using module name CoinpaprikaAPI to avoid type ambiguity wasn't possible, because it was translated by Xcode to struct name CoinpaprikaAPI.swift. After this change it will be possible to use Coinpaprika.Coin, Coinpaprika.Ticker, etc... for all module public types.
    opened by dstranz 0
  • [WIP] Migrate to Swift 5

    [WIP] Migrate to Swift 5

    • Change result type from Response to built in Result<Model, Error> from Swift 5 (with fallback for <5 versions)
    • Remove unnecessary public keywords in Swift 5
    • Add .swift_versions - supported Swift versions = 4.2 & 5.0
    • Add .cocoapods_version - supported Cocoapods versions = 1.7+
    opened by dstranz 0
  • [2.0] New endpoints, support for different quotes

    [2.0] New endpoints, support for different quotes

    • Quote (currency) - param in ticker & tickers endpoint
    CoinpaprikaAPI.ticker(id: "btc-bitcoin", quotes: [.usd, .eth]).perform { (response) in
       let priceInEth= response.value?[.eth].price
       let priceInUsd = response.value?[.usd].price
    } 
    
    • New tag & tags endpoints
    • New exchange & exchanges endpoints
    • New exchange markets endpoint
    • New coin details, coin exchanges and coin markets endpoints
    • New coin events endpoint
    • New coin twitter stream endpoint
    • New coin latest & historical OHLCV endpoint
    • New person details endpoint
    • New tickers history endpoint - to get historical ticker information for specific coin
    • Exposed JSON Encoder & Decoder used to handle API Models for convenient storing models in apps:
    let ticker: Ticker = ...
    let encoder = Ticker.encoder
    let encodedData = try? encoder.encode(bitcoin)
    
    opened by dstranz 0
Releases(2.4.0)
  • 2.4.0(Aug 19, 2019)

    • Add an option to customize client User Agent
    • Add an option to provide custom Error Parser
    • [SPM] Add Coinpaprika prefix to Networking and NetworkingMocks modules
    Source code(tar.gz)
    Source code(zip)
  • 2.3.0(Jun 25, 2019)

  • 2.2(May 15, 2019)

    • Updated module name from CoinpaprikaAPI to Coinpaprika to allow use module prefix to resolve type ambiguity.

    How to migrate?

    Replace all import CoinpaprikaAPI occurrences with import Coinpaprika

    More info in PR #7.

    Source code(tar.gz)
    Source code(zip)
  • 2.1.1(Apr 10, 2019)

  • 2.1(Apr 10, 2019)

    • Convert to Swift 5
    • Add swift_versions (4.2 & 5.0) to podspec, required by Cocoapods 1.7
    • Add native Result type when compiled with Swift 5
    • Extract Request abstract to podspec CoinpaprikaAPI/Networking
    • Add support for Basic Auth and custom authorization headers in Request
    Source code(tar.gz)
    Source code(zip)
  • 2.0.6(Mar 14, 2019)

    • Add new properties (id, userImageLink , retweeetCount, likeCount) to Tweet model
    • Add description, websiteStatus, apiStatus properties to Exchange model
    • Add imgRev field (logo revision) to Coin model
    • Add createEvent endpoint
    • Add new top movers method with results number option
    • Add lead property to News model
    • Add top300 option to Top Movers
    • Add Person Tweets method
    • Expose TickerHistory and Ohlcv properties publicly (#5)
    Source code(tar.gz)
    Source code(zip)
  • 2.0.5(Jan 23, 2019)

    New methods:

    • latestNews
    • historicalNews
    • topMovers
    • fiats

    Other changes:

    • extended list of available Quotes (added fiat currencies)
    • switch to new links structure (with followers and other stats) in CoinExtended model
    • add imageLink to Tweet model
    • add marketCapChange24h & volume24hChange24h to GlobalStats model
    • add type to Coin model
    • add coinCounter & icoCounter fields to TagType protocol
    • add id property to Event model
    • fixed volumeMarketCapRate value
    Source code(tar.gz)
    Source code(zip)
  • 2.0.4(Dec 13, 2018)

    Change type of following properties from Int64 to Decimal to be consistent with API Specification:

    • Exchange.reportedVolume24h, Exchange.adjustedVolume24h
    • GlobalStats.marketCapUsd, GlobalStats.volume24hUsd
    • Ohlcv.marketCap (+ add missing nullability to other numeric properties)
    • Ticker.circulatingSupply, Ticker.totalSupply, Ticker.maxSupply
    Source code(tar.gz)
    Source code(zip)
  • 2.0.3(Dec 11, 2018)

    • Change volume24h type from Int64 to Decimal (in Ticker.Quote)
    • Add nullability to url property in Event
    • Add Error to NSError bridge with HTTP Codes included
    • Add parent (Coin Platform) property to CoinExtended
    • Rename Person.Position model to Person.Project
    • Add coinName and coinSymbol to Person.Project
    Source code(tar.gz)
    Source code(zip)
  • 2.0.2(Nov 27, 2018)

    • Remove nullability from Exchange.fiats and Person.positions
    • Rename property Market.reportedVolumeShare to Market.reportedVolume24hShare
    • Rename property Person.Links.linkeding to Person.Links.linkedin
    • Add missing Event.description property
    • Add public visibility to property Person.Position.coinId and Person.Position.position
    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(Nov 22, 2018)

    • Added manual CodingKeys mappings to speed up models parsing
    • Added common TagType protocol conformance to all models containing tag.id and tag.name
    • Changed OHLCV & tickers history endpoints url
    • Removed keyDecodingStrategy & keyEncodingStrategy properties (due to migration to CodingKeys)
    Source code(tar.gz)
    Source code(zip)
  • 2.0(Nov 16, 2018)

    • Quote (currency) - param in ticker & tickers endpoint
    CoinpaprikaAPI.ticker(id: "btc-bitcoin", quotes: [.usd, .eth]).perform { (response) in
       let priceInEth= response.value?[.eth].price
       let priceInUsd = response.value?[.usd].price
    } 
    
    • New tag & tags endpoints
    • New exchange & exchanges endpoints
    • New exchange markets endpoint
    • New coin details, coin exchanges and coin markets endpoints
    • New coin events endpoint
    • New coin twitter stream endpoint
    • New coin latest & historical OHLCV endpoint
    • New person details endpoint
    • New tickers history endpoint - to get historical ticker information for specific coin
    • Exposed JSON Encoder & Decoder used to handle API Models for convenient storing models in apps:
    let ticker: Ticker = ...
    let encoder = Ticker.encoder
    let encodedData = try? encoder.encode(bitcoin)
    
    Source code(tar.gz)
    Source code(zip)
  • 1.1(Oct 8, 2018)

  • 1.0.4(Sep 28, 2018)

  • 1.0.3(Sep 26, 2018)

  • 1.0.2(Sep 26, 2018)

  • 1.0.1(Sep 24, 2018)

Owner
Coinpaprika
Coinpaprika
A pure swift Ethereum Web3 library

⚗️ Web3 Web3.swift is a Swift library for signing transactions and interacting with Smart Contracts in the Ethereum Network. It allows you to connect

null 484 Dec 16, 2022
Full Bitcoin library for iOS, implemented on Swift. SPV wallet implementation for Bitcoin, Bitcoin Cash and Dash blockchains.

BitcoinKit-iOS Bitcoin, BitcoinCash(ABC) and Dash wallet toolkit for Swift. This is a full implementation of SPV node including wallet creation/restor

Horizontal Systems 231 Dec 2, 2022
CryptoSwift - Crypto related functions and helpers for Swift implemented in Swift

CryptoSwift Crypto related functions and helpers for Swift implemented in Swift.

Kushal Shingote 2 Feb 6, 2022
Elegant Web3js functionality in Swift. Native ABI parsing and smart contract interactions on Ethereum network.

You can ask for help in our Discord Channel web3swift Swift implementation of web3.js functionality ⚡ Interaction with remote node via JSON RPC ?? Sma

BANKEX - Proof-of-Asset Protocol 487 Mar 25, 2022
EthereumKit is a free, open-source Swift framework for easily interacting with the Ethereum.

EthereumKit is a Swift framework that enables you to create Ethereum wallet and use it in your app. // BIP39: Generate seed and mnemonic sentence. le

Ryo Fukuda 458 Dec 31, 2022
Bitcoin protocol toolkit for Swift

Welcome to BitcoinKit The BitcoinKit library is a Swift implementation of the Bitcoin protocol which support both BCH and BTC. Improving the mobile ec

Yenom - The simplest Bitcoin wallet - 786 Dec 25, 2022
A simple Proof-of-Work Blockchain built in Swift

Blockchain in Swift A simple Proof-of-Work Blockchain built in Swift. Requirements Xcode 13.0 Swift 5.2 Vapor 4.49 Swift NIO 2.33.0 Getting started Cl

Felipe Ricieri 5 Sep 25, 2022
IOTA wallet.rs Swift binding

IOTA wallet.rs Swift Binding Swift binding for the official wallet.rs Rust library for IOTA Ledger. The Swift binding links and communicates with the

Pasquale Ambrosini 5 Jun 13, 2022
Web3keystore - Ethereum keystore logic, in Swift

web3keystore A module for creating and interacting with Ethereum keystores. Hand

Brian Wagner 0 Feb 12, 2022
A swift utility to resolve Ethereum Domain Names.

ENSKit A swift utility to resolve Ethereum Domain Names per EIP-137. Examples Initializing: // Use default options with Cloudflare Ethereum Gateway le

null 16 Nov 25, 2022