Advertisement
Guest User

Nasfaq basic API noobs

a guest
Oct 17th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. import json
  2. #Convert your timezone to unix time. Use an epoch accurate to the second.
  3. epoch = 1634475600
  4. #Change fdatetime to match your .json filename.
  5. fdatetime = '211017_2254'
  6. #Change this to 'inCirculation' for number of coins, or 'price' for price.
  7. fdata = 'inCirculation'
  8. #Change this to rename the output .txt file.
  9. ftype = 'daily'
  10.  
  11. #don't change this
  12. fname = 'getMarketInfo'+fdatetime+'.json'
  13. #don't change this
  14. epoch *= 1000
  15.  
  16. txt = ftype+fdata+fdatetime+'_'+str(epoch)+'.txt'
  17. outf = open(txt, 'w')
  18. outf.write(str(epoch)+'\n')
  19.  
  20. with open(fname) as f:
  21.   data = json.load(f)
  22.  
  23. for h in data['coinInfo']['data']:
  24.   looping = 1
  25.  
  26.   for i in data['coinInfo']['data'][h]['history']:
  27.  
  28.     for j in i:
  29.       if(looping==0):
  30.         break
  31.       if(j=='timestamp'):
  32.         if(i[j]>=epoch):
  33.           if(h=='himemoriluna'):
  34.             print('luna ' + str(i[fdata]))
  35.             outf.write('luna ' + str(i[fdata]) + '\n')
  36.           else:
  37.             print(h + ' ' + str(i[fdata]))
  38.             outf.write(h + ' ' + str(i[fdata]) + '\n')
  39.           looping = 0
  40.           break
  41.  
  42. outf.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement