Add a new Service Provider

The Service class connects to providers such as or to retreive transaction, network, block, address information, etc

The Service class automatically selects a provider which has requested method available and selects another provider if method fails.

Steps to add a new provider

  • The preferred way is to create a github clone and update code there (and do a pull request…)

  • Add the provider settings in the providers.json file in the configuration directory.


    "bitgo": {
        "provider": "bitgo",
        "network": "bitcoin",
        "client_class": "BitGo",
        "provider_coin_id": "",
        "url": "",
        "api_key": "",
        "priority": 10,
        "denominator": 1,
        "network_overrides": null
  • Create a new Service class in Create a method for available API calls and rewrite output if needed.


from import BaseClient


class BitGoClient(BaseClient):

    def __init__(self, network, base_url, denominator, api_key=''):
        super(self.__class__, self).\
            __init__(network, PROVIDERNAME, base_url, denominator, api_key)

    def compose_request(self, category, data, cmd='', variables=None, method='get'):
        if data:
            data = '/' + data
        url_path = category + data
        if cmd:
            url_path += '/' + cmd
        return self.request(url_path, variables, method=method)

    def estimatefee(self, blocks):
        res = self.compose_request('tx', 'fee', variables={'numBlocks': blocks})
        return res['feePerKb']
  • Add this service class to

  • Remove install.log file in bitcoinlib’s log directory, this will copy all provider settings next time you run the bitcoin library. See ‘initialize_lib’ method in

  • Specify new provider and create service class object to test your new class and it’s method

from bitcoinlib import services

srv = Service(providers=['blockchair'])