Company
Date Published
Author
Eric Vargas
Word count
1393
Language
English
Hacker News points
1

Summary

The goal of this post is to build a library that retrieves the latest price of a list of cryptocurrencies, uses the CoinMarketCap API, and provides a simple code structure for creating a Swift package using the Swift Package Manager. The sample server API endpoint used in this example is /v2/cryptocurrency/quotes/latest. A struct called CoinRetriever exposes only one function that retrieves the latest price of a list of coins by calling the CoinMarketCap API endpoint and decoding the response into models such as Quote, Coin, and Coins. The library can be published to GitHub and used in other projects via Xcode's Package Manager. Additionally, liblab offers an automated process for generating client libraries in multiple languages and platforms.