Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smartiden/latest-transactions-mempool.space
Python script that gets the latest transactions from the mempool.space website and saves them into a text file.
https://github.com/smartiden/latest-transactions-mempool.space
bitcoin bitcoin-wallet mempool mempool-monitoring-engine transactions
Last synced: 7 days ago
JSON representation
Python script that gets the latest transactions from the mempool.space website and saves them into a text file.
- Host: GitHub
- URL: https://github.com/smartiden/latest-transactions-mempool.space
- Owner: smartiden
- Created: 2024-03-28T19:19:30.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-29T01:51:48.000Z (8 months ago)
- Last Synced: 2024-10-11T12:02:20.877Z (about 1 month ago)
- Topics: bitcoin, bitcoin-wallet, mempool, mempool-monitoring-engine, transactions
- Language: Python
- Homepage: https://keyhunters.ru/getting-the-latest-transactions-mempool-space/
- Size: 5.55 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Getting the latest transactions mempool.space
Python script that gets the latest transactions from the mempool.space website and saves them into a text file can use the following approach. We will use the library
requests
to query data from the mempool.space API andjson
work with the resulting data in JSON format.First make sure you have the required libraries installed. If they are not already installed, they can be installed using pip:
pip install requests
Now you can use the following script to get the latest transactions and save them to a text file:
import requests
import jsondef fetch_latest_transactions():
# URL to get latest transactions from mempool.space API
url = "https://mempool.space/api/mempool/recent"try:
# Send a GET request and receive data
response = requests.get(url)
response.raise_for_status() # Checking for request errors
transactions = response.json() # Receiving data in JSON format# Opening a file for writing
with open("latest_transactions.txt", "w") as file:
for transaction in transactions:
# We record information about each transaction in a file
file.write(json.dumps(transaction) + "\n")print("We record information about each transaction in a file 'latest_transactions.txt'.")
except requests.RequestException as e:
print(f"Error while receiving data: {e}")# Calling the function
fetch_latest_transactions()This script first makes a request to the mempool.space API to get the latest transactions. It then stores this data in a text file, where each transaction is recorded on a separate line in JSON format.
Make sure that you have access to the Internet and that the mempool.space website is accessible, as this will determine whether the script will run successfully.
Source: https://keyhunters.ru/getting-the-latest-transactions-mempool-space
GitHub: https://github.com/smartiden/Latest-Transactions-mempool.space