MiningPoolHub-Swift is a complete API wrapper for the miningpoolhub.com API written in the Swift language. All working calls, both authenticated and unauthenticated are available natively in swift code. The goal was to empower others to help build applications for this great community.
This library also supports miningpoolhubstats.com for balance tracking
Built in Swift 4.0
bitcoin: 17ZEBFw5peuoUwYaEJeGkpoJwP1htViLUY
litecoin: LSzwWG35KqfuR5SEiKeJrGq4L3Z36vzjdR
ethereum: 0x339c744e0c08862c0943431079e5a406413bf4ed
CocoaPods
pod 'MiningPoolHub-Swift'
Manual Installation
Copy into your project all the files found in MiningPoolHub/Sources
First, visit miningpoolhub.com and click on "Edit Profile". Retrieve your API key for use below.
*Note: Some calls have an id field. This is normally used to specify the user associated with a given call. It is my observation that if this is left nil, the user will be identified from the API key
If using cocoapods, import the library: import MiningPoolHub_Swift
To make a request to the MiningPoolHub API, simply do the following
let api_key = "YOUR_API_KEY"
let config = MphDefaultConfiguration(apiKey: api_key)
let provider = MphWebProvider(configuration: config)
//Make web call
let task = provider.getAutoSwitchingAndProfitsStatistics(completion: { (response: MphListResponse<MphAutoSwitchingProfitStatistics>) in
print(response.toJSON())
}) { (error: Error) in
print(error.localizedDescription)
}
That's it! Swift bjects are returned fully parsed and ready to use!
To make a request to task, simply call: task.cancel()
The domains have been enumerated and are a variable on the MphWebProvider. To set the domain of interest, simply call
provider.set(domain: .litecoin)
Use the default .root
domain for the root domain of the site. For a perhaps newly released custom domain not yet supported by enumeration, call
provider.setCustom(domain: "someCustomDomain")
Floating Point Precision
As noted by this stackoverflow question, the Swift JSONSerialization
class used to handle core JSON serialization and deserialization will cast by default to Double instead of Decimal. Because of this, you may notice some rounding errors at the lowest decimal place. Sorry!
A special thanks to MiningPoolHub for a great community and site!