-
Notifications
You must be signed in to change notification settings - Fork 7
/
4traits.py
40 lines (26 loc) · 2.99 KB
/
4traits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import requests, tabulate
fourTraits = ['9993', '9916', '9905', '9859', '9855', '9793', '9758', '9773', '9672', '9665', '9619', '9607', '9606', '9543', '9463', '9493', '9507', '9381', '9351', '9347', '9343', '9247', '9212', '9195', '9217', '9183', '9110', '9104', '9091', '9079', '8877', '8907', '8887', '8886', '8845', '8816', '8764', '8742', '8687', '8633', '8607', '8574', '8560', '8477', '8454', '8408', '8286', '8235', '8265', '8256', '8146', '8159', '8012', '7910', '7834', '7801', '7779', '7740', '7612', '7531', '7524', '7453', '7439', '7342', '7317', '7287', '7257', '7208', '7182', '7136', '7119', '7108', '7061', '7054', '7071', '7008', '6905', '6858', '6873', '6866', '6865', '6736', '6756', '6621', '6459', '6327', '6265', '6186', '6182', '6159', '6111', '6028', '6022', '5980', '5949', '5938', '5892', '5903', '5898', '5840', '5797', '5794', '5662', '5558', '5576', '5552', '5567', '5569', '5501', '5468', '5467', '5428', '5423', '5376', '5285', '5261', '5250', '5243', '5207', '5199', '5132', '5093', '5083', '4985', '4844', '4777', '4691', '4687', '4507', '4489', '4418', '4397', '4392', '4355', '4346', '4296', '4252', '4244', '4231', '4204', '4212', '4159', '4156', '4155', '4150', '4135', '4101', '4070', '4069', '4039', '4025', '3953', '3880', '3866', '3855', '3829', '3804', '3739', '3665', '3619', '3606', '3514', '3432', '3356', '3415', '3410', '3317', '3287', '3235', '3221', '3173', '3162', '3160', '3144', '3132', '3131', '3126', '3113', '3068', '2995', '2939', '2922', '2897', '2909', '2910', '2822', '2773', '2743', '2733', '2702', '2632', '2651', '2623', '2507', '2441', '2429', '2425', '2344', '2276', '2237', '2234', '2220', '2175', '2156', '2118', '2101', '2087', '2072', '1963', '1929', '1866', '1822', '1811', '1802', '1787', '1784', '1677', '1626', '1620', '1569', '1525', '1450', '1433', '1329', '1307', '1281', '1159', '1124', '1005', '949', '947', '938', '872', '860', '821', '790', '735', '683', '660', '650', '582', '563', '485', '469', '422', '397', '324', '309', '255', '236', '204', '192', '159', '29']
querystring = {"token_ids":[],"asset_contract_address":"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d","order_direction":"desc","offset":"0","limit":"50"}
total = 254
count = 0
pageSize = 50
apes = []
while count < total:
thisQuery = querystring.copy()
thisQuery['token_ids'] = fourTraits[count:count + pageSize]
response = requests.request("GET", "https://api.opensea.io/api/v1/assets", params=thisQuery)
for ape in response.json()['assets']:
thisApe = {}
thisApe['id'] = ape['token_id']
thisApe['link'] = ape['permalink']
thisApe['price'] = None
if ape['sell_orders'] and ape['sell_orders'][0]['sale_kind'] == 0:
thisApe['price'] = float(ape['sell_orders'][0]['current_price']) / 1000000000000000000.0
for trait in ape['traits']:
thisApe[trait['trait_type']] = trait['value']
if thisApe['price']:
apes.append(thisApe)
count += pageSize
if total - count < pageSize:
pageSize = total - count
print tabulate.tabulate(sorted(apes, key = lambda i:i['price']), headers="keys")