Skip to content

MatthewYork/MiningPoolHub-Swift

Repository files navigation

MiningPoolHub-Swift

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

Donate

bitcoin: 17ZEBFw5peuoUwYaEJeGkpoJwP1htViLUY

litecoin: LSzwWG35KqfuR5SEiKeJrGq4L3Z36vzjdR

ethereum: 0x339c744e0c08862c0943431079e5a406413bf4ed

Installation

CocoaPods

pod 'MiningPoolHub-Swift'

Manual Installation

Copy into your project all the files found in MiningPoolHub/Sources

How To Use

What you need

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

Import Files

If using cocoapods, import the library: import MiningPoolHub_Swift

Making a Request

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!

Cancelling a Request

To make a request to task, simply call: task.cancel()

Domains

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")

Limitations

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!

Thanks

A special thanks to MiningPoolHub for a great community and site!

About

MiningPoolHub API wrapper written in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published