A simple bitcoin API to detect payments via bitcoin easily. Create bitcoin invoices & check the status of them. No bitcoin nodes or any of that needed.
-
Install the required packages using pip:
pip install requests websockets flask bit pymongo colorama
-
Replace the
BLOCKCYPHER_TOKENS
list andMONGO_URI
with your BlockCypher API tokens and MongoDB connection URI respectively. -
Choose whether to use the Bitcoin mainnet or testnet by setting the
TESTING
variable accordingly. -
Run the file:
py main.py
-
Endpoint:
/create
-
Method:
GET
-
Query Parameters:
usd
(required): The amount in USD for the invoice.destination
(required): The final destination address for the invoice.
-
Example:
GET /create?usd=100&destination=your_destination_address
- Response:
{
"invoice_id": "generated_invoice_id",
"destination": "your_destination_address",
"payment": {
"address": "generated_bitcoin_address",
"amounts": {
"btc": bitcoin_amount,
"sats": satoshis_amount,
"usd": usd_amount
}
},
"status": "waiting"
}
-
Endpoint:
/status
-
Method:
GET
-
Query Parameters:
invoice_id
-
Example:
GET /status?invoice_id=generated_invoice_id
- Response:
{
"status": "unconfirmed", <- can also be confirmed, waiting, or completed
"txid": "confirmed_transaction_id" <- will only show if status is confirmed
}
- This API is for educational and experimental purposes. Please do not rely on this.
- Ensure you have a solid understanding of Bitcoin transactions, confirmations, and security before deploying this API.
- This API does not handle error cases and edge scenarios comprehensively. You may need to enhance error handling and implement additional security measures for production use.
- Be cautious when sharing sensitive information such as private keys, API tokens, and access credentials.