i'm new to bitcoin and was wondering, does anyone know how to get unconfirmed transactions with python?
If you had a bitcoin node:
import requests
import json
url = "http://127.0.0.1:PORT"
payload = json.dumps({
"jsonrpc": "1.0",
"id": "test",
"method": "getrawmempool",
"params": [
True
]
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Basic dXNlcjpwYXNz'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.json())
Else you could use API for any 2 block explorers:
import requests
url = "https://mempool.space/api/mempool/txids"
headers = {
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers)
print(response.json())
URL can be https://blockstream.info/api/mempool/txids for blockstream.info explorer.