It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
#dependencies
import pandas as pd
import numpy as np
#from datetime import datetime #this library is not required
from sqlalchemy import create_engine, Column, Integer, String, Float
from sqlalchemy.orm import Session
from sqlalchemy.ext.declarative import declarative_base
#path of sqlite file goes here in relation to current file
database_path = 'merit.sqlite'
#create DataFrame from mert transaction history file on loyce.club
data = pd.read_csv('http://loyce.club/Merit/merit.all.txt', sep=' ', header=None)
#rename columns
data = data.rename(columns={0: 'time', 1: 'number_of_merit', 2:'message_id', 3:'UID_from', 4: 'UID_to'})
#connect to sqllite db
engine = create_engine(f"sqlite:///{database_path}")
session = Session(engine)
#use default declarative base function as variable 'Base'
Base = declarative_base()
#define table schema
class Merit(Base):
__tablename__ = 'merit'
id = Column(Integer, primary_key=True)#this is a column with a unique value for each transaction
time = Column(Integer) #unix time
number_of_merit = Column(Integer)
message_id = Column(String(25))
uid_from = Column(Integer)
uid_to = Column(Integer)
#create table in sqllite file
Base.metadata.create_all(engine)
#set first value for id as 1
id1 = 1
#loop through DataFrame to add each row in the DataFrame to the SQLlite DB.
for x in np.arange(len(data)):
session.add(Merit(id=id1, time=int(data['time'][x]), number_of_merit=int(data['number_of_merit'][x]),
message_id=data['message_id'][x], uid_from=int(data['UID_from'][x]), uid_to=int(data['UID_to'][x])))
id1 = id1 + 1 #after the row is added, the id1 variable value will be increased by one
#will commit rows in batches of 100
if len(session.new) > 100:
session.commit()
session.commit() #commit last batch of rows
#check to make sure all rows were successfully imported
if len(session.query(Merit.id).all()) == len(data):
print(f'All the data from the DataFrame was successfully imported into a SQL file found at {database_path}')
else:
print(f'There was a problem importing all the merit transactions and {len(data) - len(session.query(Merit.id).all())} were not imported. Troubleshooting is required')
#dependencies
import pandas as pd
import numpy as np
from datetime import datetime
from sqlalchemy import create_engine, Column, Integer, String, Float, func
from sqlalchemy.orm import Session
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.automap import automap_base
from flask import Flask, jsonify
#path of sqlite file goes here in relation to current file
database_path = 'merit.sqlite'
#connect to sqllite db
engine = create_engine(f"sqlite:///{database_path}")
#reflect an existing database into a new model
Base = automap_base()
# reflect the tables
Base.prepare(engine, reflect=True)
# Save reference to the table
Merit = Base.classes.merit
#set variable 'app' to run Flask
app = Flask(__name__)
@app.route("/")
def welcome():
description1 = '''
Available Routes:
/api/v0.1/number_received/[uid]
/api/v0.1/number_sent/[uid]
/api/v0.1/between/[uid_from]/[uid_to]
/api/v0.1/received/[uid]
/api/v0.1/sent/[uid]
/api/v0.1/number_received/[uid]
replace [uid] with uid of forum member, must be an integer
returns: Total Received Merit: the total merit the uid has received
uid: the uid you are querying
/api/v0.1/number_sent/[uid]
replace [uid] with uid of forum member, must be an integer
returns: Total Sent Merit: the total merit the uid has sent
uid: the uid you are querying
/api/v0.1/between/[uid_from]/[uid_to]
replace [uid_from] and [uid_to] with uids of forum members, must be integers
Queries merit transactions from [uid_from] to [uid_to]
returns:Total Received Merit: the total merit sent to [uid_to] from [uid_from]
Sent from: [uid_from]
Sent to: [uid_to]
Transactions: List of dictionaries of merit transactions that contain the following information:
time: time of merit transaction in the following format: yyyy-mm-dd hh:mm:ss
Month: Month of merit transaction
Day of Week: the day of the week of the merit transaction
number of merit: the number of merit that was sent from [uid_from] to [uid_to] in the merit transaction
Post: Post ID that received merit
/api/v0.1/received/[uid]
replace [uid] with uid of forum member, must be an integer
returns:
Total Received Merit: the total merit the uid has received
Sent to: the uid you are querying
Transactions: List of dictionaries of merit transactions that contain the following information:
time: time of merit transaction in the following format: yyyy-mm-dd hh:mm:ss
Month: Month of merit transaction
Day of Week: the day of the week of the merit transaction
number of merit: the number of merit that was sent to [uid] in the merit transaction
Post: Post ID that received merit
Sent from: the uid that sent the merit transaction
/api/v0.1/sent/[uid]
replace [uid] with uid of forum member, must be an integer
returns:
Total Sent Merit: the total merit the uid has sent
Sent to: the uid you are querying
Transactions: List of dictionaries of merit transactions that contain the following information:
time: time of merit transaction in the following format: yyyy-mm-dd hh:mm:ss
Month: Month of merit transaction
Day of Week: the day of the week of the merit transaction
number of merit: the number of merit that was sent from [uid_from] in the merit transaction
Post: Post ID that received merit
Sent to: the uid that merit was sent to in the subject transaction
'''
return (description1)
@app.route('/api/v0.1/number_received/')
def number_received(uid):
try:
#confirm the input was an integer
uid1 = int(uid)
#connect to sqllite DB
session = Session(engine)
response = session.query(func.sum(Merit.number_of_merit)).filter(Merit.uid_to == uid1).all()
session.close()
response = list(np.ravel(response))
response = int(response[0])
response_list = []
merit_received = {}
merit_received['Total Received Merit'] = response
merit_received['uid'] = uid1
response_list.append(merit_received)
return jsonify(response_list) #jsonify
except ValueError:
value1 = {'Error': f'{uid} is not an Integer. Please reformat into an Integer and try again'}
return jsonify(value1)
except TypeError:
no_merit = {"Total Received Merit":0, "uid":uid1}
return jsonify(no_merit)
@app.route('/api/v0.1/number_sent/')
def number_sent(uid):
try:
#confirm the input was an integer
uid1 = int(uid)
#connect to sqllite DB
session = Session(engine)
response = session.query(func.sum(Merit.number_of_merit)).filter(Merit.uid_from == uid1).all()
session.close()
response = list(np.ravel(response))
response = int(response[0])
response_list = []
merit_sent = {}
merit_sent['Total Sent Merit'] = response
merit_sent['uid'] = uid1
response_list.append(merit_sent)
return jsonify(response_list)
except ValueError:
value1 = {'Error': f'{uid} is not an Integer. Please reformat into an Integer and try again'}
return jsonify(value1)
except TypeError:
no_merit = {"Total Sent Merit":0, "uid":uid1}
return jsonify(no_merit)
@app.route('/api/v0.1/between// ')
def between(fromm, to):
try:
#confirm the input was an integer
from1 = int(fromm)
to1 = int(to)
#connect to sqllite DB
session = Session(engine)
response = session.query(func.sum(Merit.number_of_merit)).filter(Merit.uid_from == from1).filter(Merit.uid_to == to1).all()
response2 = session.query(Merit.number_of_merit, Merit.message_id, Merit.time).filter(Merit.uid_from == from1).filter(Merit.uid_to == to).all()
session.close()##pick up coding here
response = list(np.ravel(response))
response = int(response[0])
response_list = []
merit_sent = {}
merit_sent['Total Received Merit'] = response
merit_sent['Sent from'] = from1
merit_sent['Sent to'] = to1
response3 = []
for merit_number, message_id, time in response2:
response2_dict = {}
time1 = datetime.utcfromtimestamp(int(time)).strftime('%Y-%m-%d %H:%M:%S')
time_day = datetime.utcfromtimestamp(int(time)).strftime('%A') #day of week
time_month = datetime.utcfromtimestamp(int(time)).strftime('%B') #month
response2_dict['time'] = time1
response2_dict['Month'] = time_month
response2_dict['Day of Week'] = time_day
response2_dict['number of merit'] = merit_number
response2_dict['Post'] = message_id
response3.append(response2_dict)
merit_sent['Transactions'] = response3
response_list.append(merit_sent)
return jsonify(response_list)
except ValueError:
value1 = {'Error': f'{fromm} or {to} is not an Integer. Please reformat into an Integer and try again'}
return jsonify(value1)
except TypeError:
no_merit = {"Total Received Merit":0, "Sent from":from1, 'Sent to': to1,
'Transactions':[{'time': '2009-01-08 08:21:00','Month':
'January','Day of Week': 'Thursday','number of merit': 0,
'Post': '9999999.msg999999999'}] }
return jsonify(no_merit)
@app.route('/api/v0.1/received/')
def transactions_received(to):
try:
#confirm the input was an integer
to1 = int(to)
#connect to sqllite DB
session = Session(engine)
response = session.query(func.sum(Merit.number_of_merit)).filter(Merit.uid_to == to1).all()
response2 = session.query(Merit.uid_from, Merit.number_of_merit, Merit.message_id, Merit.time).filter(Merit.uid_to == to).all()
session.close()
response = list(np.ravel(response))
response = int(response[0])
response_list = []
merit_sent = {}
merit_sent['Total Received Merit'] = response
merit_sent['Sent to'] = to1
response3 = []
for received_from, merit_number, message_id, time in response2:
response2_dict = {}
time1 = datetime.utcfromtimestamp(int(time)).strftime('%Y-%m-%d %H:%M:%S')
time_day = datetime.utcfromtimestamp(int(time)).strftime('%A') #day of week
time_month = datetime.utcfromtimestamp(int(time)).strftime('%B') #month
response2_dict['time'] = time1
response2_dict['Month'] = time_month
response2_dict['Day of Week'] = time_day
response2_dict['number of merit'] = merit_number
response2_dict['Post'] = message_id
response2_dict['Sent from'] = received_from
response3.append(response2_dict)
merit_sent['Transactions'] = response3
response_list.append(merit_sent) #this might need to be moved to the end
return jsonify(response_list)
except ValueError:
value1 = {'Error': f'{to} is not an Integer. Please reformat into an Integer and try again'}
return jsonify(value1)
except TypeError:
no_merit = {"Total Received Merit":0, 'Sent to': to1,
'Transactions':[{'time': '2009-01-08 08:21:00','Month':
'January','Day of Week': 'Thursday','number of merit': 0,
'Post': '9999999.msg999999999', 'Sent from': 2}] }
return jsonify(no_merit)
@app.route('/api/v0.1/sent/')
def transactions_sent(fromm):
try:
#confirm the input was an integer
from1 = int(fromm)
#connect to sqllite DB
session = Session(engine)
response = session.query(func.sum(Merit.number_of_merit)).filter(Merit.uid_from == from1).all()
response2 = session.query(Merit.uid_to, Merit.number_of_merit, Merit.message_id, Merit.time).filter(Merit.uid_from == from1).all()
session.close()##pick up coding here
response = list(np.ravel(response))
response = int(response[0])
response_list = []
merit_sent = {}
merit_sent['Total Sent Merit'] = response
merit_sent['Sent from'] = from1
response3 = []
for sent_to, merit_number, message_id, time in response2:
response2_dict = {}
time1 = datetime.utcfromtimestamp(int(time)).strftime('%Y-%m-%d %H:%M:%S')
time_day = datetime.utcfromtimestamp(int(time)).strftime('%A') #day of week
time_month = datetime.utcfromtimestamp(int(time)).strftime('%B') #month
response2_dict['time'] = time1
response2_dict['Month'] = time_month
response2_dict['Day of Week'] = time_day
response2_dict['number of merit'] = merit_number
response2_dict['Post'] = message_id
response2_dict['sent to'] = sent_to
response3.append(response2_dict)
merit_sent['Transactions'] = response3
response_list.append(merit_sent) #this might need to be moved to the end
return jsonify(response_list)
except ValueError:
value1 = {'Error': f'{fromm} is not an Integer. Please reformat into an Integer and try again'}
return jsonify(value1)
except TypeError:
no_merit = {"Total Received Merit":0, "Sent from":from1,
'Transactions':[{'time': '2009-01-08 08:21:00','Month':
'January','Day of Week': 'Thursday','number of merit': 0,
'Post': '9999999.msg999999999', 'Sent to': 2}] }
return jsonify(no_merit)
if __name__ == '__main__':
app.run(debug=False)
#debug needs to be set to False in production, but can be set to True in a non-public facing setting.
".date("d.m.Y H:i:s", $val["DTG"])." | .$val["Msg"]."#". strstr($val["Msg"], "msg")."'>".$val["Msg"]." | .$val["Donor"]."'>".$val["Donor"]." | -(".$val["Merits"].")-> | .$val["Recipient"]."'>".$val["Recipient"]." |
".date("d.m.Y H:i:s", $val["DTG"])." | .$val["Msg"]."#". strstr($val["Msg"], "msg")."'>".$val["Msg"]." | .$val["Recipient"]."'>".$val["Recipient"]." | <-(".$val["Merits"].")- | .$val["Donor"]."'>".$val["Donor"]." |