⚠️ This project is not maintained anymore. While https://api.qbit.ninja/ and https://tapi.qbit.ninja/ you can't expect those to work reliably. If all you want is to broadcast a transaction, use https://blockstream.info/tx/push . If you want to build on Bitcoin, please use https://github.com/dgarage/NBXplorer/ instead. This is lightweight, works on linux and do not require indexing the whole blockchain.
You can see the API documentation on api.qbit.ninja and on apiary.
You can try the API in .NET with the nuget package.
Public servers :
- Mainnet : api.qbit.ninja
- Testnet : tapi.qbit.ninja
- Download and install .NET Framework 4.7.1 Dev Pack.
- Download and install Visual studio 2017. You need to enable .NET Development and ASP.NET Web development.
- Download and install Bitcoin Core 0.16.2, and wait it is synchronized.
- Get a Microsoft Azure account.
In Azure, create one App resource group then you need to create:
- Storage resource
- Azure Bus resource
- Web App resource,
- Azure VM with 1 data disk of 1 TB attachd to it. (I advise you
D1 v2
)
The indexer is the application which will listener your full node and index everything into your Azure Storage
.
You can run it through the QBitNinja.Listener.Console
project.
Assuming your Bitcoin node is fully synched,
git clone https://github.com/MetacoSA/QBitNinja/
Then edit QBitNinja.Listener.Console/App.config
.
Your QBitNinja.Listener.Console
app.config
file should looks like.
<appSettings>
<add key="Azure.AccountName" value="azurestorageaccountname" />
<add key="Azure.Key" value="azurestoragekey" />
<add key="RPCConnectionString" value="default"/>
<add key="Network" value="mainnet" />
<add key="Chain" value="BTC" />
<add key="Node" value="127.0.0.1" />
<add key="ServiceBus" value="Endpoint=sb://example.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=mysecretkey" />
</appSettings>
Azure.AccountName
andAzure.Key
are in the Azure Portal, in the settings of your Azure Storage Resource,Network
can bemainnet
,testnet
,regtest
.Chain
can beBTC
orLTC
or any chainNode
represented the P2P connection to your bitcoin node. Do not forget to whitelist the indexer in your node's settings (typically addingwhitelist=127.0.0.1
inbitcoin.conf
)ServiceBus
connection string to your Service Bus Namespace (inShared access policies
inside Azure)RPCConnectionString
optional, but needed for more reliably broadcast transactions.
Example of RPCConnectionString
:
default
: Assume your are runningbitcoind
locally with default settings.cookiefile=C:\path\to\.cookie
: If you runbitcoind
in a different data directory with default authentication, you need to set the path to it.server=http://127.0.0.1:29292
: If you runbitcoind
RPC on a different port than default.myuser:password
: If you runbitcoind
withrpcuser
andrpcpassword
.server=http://127.0.0.1:29292;myuser:password
: If you runbitcoind
RPC withrpcuser
andrpcpassword
, on a different port than default.server=http://127.0.0.1:29292;cookiefile=C:\path\to\.cookie
: If you runbitcoind
RPC withrpcuser
andrpcpassword
, in a different data directory with default authentication.
Be careful:You need to compile QBitNinja in (preferably in Release mode) for the configuration to be effective, because QBitNinja will ultimately use the QBitNinja.Listener.Console.exe.config
file which is in the same folder as QBitNinja.Listener.Console.exe
for its configuration.
Do not forget to disable Secure transfer Required
in your storage configuration.
One you have setup everything, build QBitNinja.Listener.Console
in Release
mode and run QBitNinja.Listener.Console.exe --init
.
You can repeat the same operation on multiple machine to index faster.
Once it finished, run QBitNinja.Listener.Console.exe
.
We advise you to the Windows Task Scheduler to run QBitNinja.Listener.Console.exe --Listen
and bitcoind.exe
automatically even when the user is not logged on or when the virtual machine reboot.
The front is a web application which will query your Azure Storage
for blocks/transactions/balances indexed by the indexer.
You can run find it in the QBitNinja
project.
The easiest is deploy via Visual Studio 2017
.
- Download your Web App profile by going into your Web App resource settings in Azure, and clicking on
Get publish profile
- Open the solution under
Visual Studio 2017
- Setup the
Web.config
exactly how you set up theApp.config
in the previous step - Right click on the
QBitNinja
project and click onPublish
. - Click on
New profile...
- In the new window, click on the bottom left
Import Profiles
and select your downloaded publish profile - Click on
Publish
- Download and install Visual studio 2017. (You need to enable .NET Development and ASP.NET Web development)
- Download and install .NET Framework 4.7.1 Dev Pack.
Open the solution and build.
- Download and install Build Tools for Visual studio 2017.
Then use msbuild.exe
:
msbuild.exe /restore
msbuild.exe /p:Configuration=Release
In order for the API to work in Unity with .NET 4.6 for Android devices you should:
QBitNinjaClient.SetCompression(false);
Because it's missing the DLL MonoPosixHelper from the buildQBitNinjaClient client = new QBitNinjaClient("http://api.qbit.ninja/", NBitcoin.Network.Main);
because HTTPS withHttpClient
seems to not work correctly.- Scripting Runtime Version: Select "Experimental (.NET 4.6 Equivalent)"
This project is released under the terms of the MIT license. See LICENSE.