Package: bitnob
BitnobThis is a Python package for easy integration of Bitnob For Business API for various applications from Bitnob.Getting startedRequirementsThis package requires Python 3.6+Installationpip install bitnobUsageThis SDK can be used both for Bitnob Sandbox and Production API.Setting ENV KEYSFor sucessfully running of the SDK; theBITNOB_API_KEYmust be set.Now this will throw aBitnobBadKeyErrorerror, if you do not set it as an environment variable, when initiatizing a function.By default the SDK assumes that you are currently working on production, and yourBITNOB_API_KEYmust be a production-grade secret key.To run on sandbox(development mode), setBITNOB_PRODUCTION=falseas an environment variable.Instantiate The Bitnob FunctionsBefore making use of any bitnob functions, it should be instantiated. Below is a demonstration:from bitnob import Lightninglightning = Lightning()customer = Customer()onchain = Onchain()wallet = Wallets()CustomersTo manage customers in your application, instantiate a newCustomerclass.The following functions are available:create_customerget_customer_by_emailget_customerupdate_customerLightningTo create Lightning Transactions, instantiate a newLightningclass.The following functions are available:create_invoicepay_invoiceinitiate_paymentdecode_payment_requestget_invoiceFull Lightning WorkflowfrombitnobimportLightninglightning=Lightning()payload={"customerEmail":"bernard@bitnob.com","description":"Enjoy Life!","tokens":300,"expires_at":"24h","private":false,"is_including_private_channels":false,"is_fallback_included":true,}# Create a lightning invoicenew_ln_invoice=lightning.create_invoice(payload)OnchainTo create Onchain Transactions, instantiate a newOnchainclass.The following functions are available:send_bitcoingenerate_addresslist_addressesFull Onchain Transaction WorkflowfrombitnobimportOnchainon_chain=Onchain()payload={"customerEmail":"bernard@bitnob.com","reference":"txt-ref-09fdcsf-7658dcgfh-84738pokli","satoshis":30000,"address":"btcjshlidlsidskdslisidsdosilsdmxksjsjldksossjoioidjifkji.zjijsi","description":"Go buy your momma a house!","priorityLevel":"priority"}# Send bitcoin using onchainnew_onchain=on_chain.send_bitcoin(payload)WalletsTo get wallets information, simply follow the instruction at the beginning of this sub-heading and instantiate a newWalletsclass.The following functions are available:wallet_detailget_transactionlist_transactionsWebhook AuthenticationThe Bitnob SDK comes with a function that enables your business authenticate events sent to your webhook. It is advised to authenticate all requests sent to your endpoint to avoid fake transactions.UsagefromfastapiimportFastAPIfrombitnobimportwebhook_authenicationapp=FastAPI()@app.post("/webhook_endpoint/")asyncdefwebhook_event_handler(event):ifwebhook_authenication(event):#Handle event#return 200else:#do nothing or throw errorDevelopmentContributingBug reports and pull requests are welcome on GitHub athttps://github.com/bitnob/bitnob_python_sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct. Simply create a new branch and raise a Pull Request, we would review and merge.LicenseThe package is available as open source under the terms of theBSD License