With nested queries, Airstack finds the intersection of common holders of multiple POAPs in the following order:
Filtering POAP holders on the 1st outermost query
Comparing POAP holders of 1st outermost query against the POAP holders on 2nd outermost query
Comparing POAP holders of the 1st and 2nd outermost query against the POAP holders on the 3rd outermost query
Comparing POAP holders of 1st, 2nd, ..., nth outermost query against the POAP holders on (n + 1)-th outermost query
Since the number of objects returned in the responses will be dependent on the number of POAP holders on the 1st outermost query, it's most efficient that you have the POAP with the least amount of holders on the 1st outermost query.
Suppose there are two POAPs:
POAP A: 100,000 holders
POAP B: 1,000 holders.
If POAP A is the input on the 1st outermost query, then the end result will be 100,000 objects in the response array.
On the other hand, if POAP B is the input on the 1st outermost query, then the end result will be instead ONLY 1,000 objects in the response array.
The latter approach will be more efficient and easier for further formatting.
defformat_function(data): result = []if data isnotNoneand'Poaps'in data and'Poap'in data['Poaps']:for item in data['Poaps']['Poap']:if'owner'in item and'poaps'in item['owner']:for poap in item['owner']['poaps']:if'owner'in poap and'addresses'in poap['owner']: result.append(poap['owner']['addresses']) result = [item for sublist in result for item in sublist] result = [item for sublist in result for item in sublist] result =list(set(result))return result
The final result will the the list of all common holders in an array:
Fetching common holders for more than 2 POAPs works the same way as fetching only 2 POAPs with the addition of more POAP event ID parameters and additional nesting as shown below:
defformat_function(data): result = []if data isnotNoneand'Poaps'in data and'Poap'in data['Poaps']:for item in data['Poaps']['Poap']:if'owner'in item and'poaps'in item['owner']:for poap in item['owner']['poaps']:if'owner'in poap and'poaps'in poap['owner']:for nested_poap in poap['owner']['poaps']:if'owner'in nested_poap and'addresses'in nested_poap['owner']: result.append(nested_poap['owner']['addresses']) result = [item for sublist in result for item in sublist] result = [item for sublist in result for item in sublist] result = [item for sublist in result for item in sublist] result =list(set(result))return result
Developer Support
If you have any questions or need help regarding fetching holders or attendees of multiple POAPs, please join our Airstack's Telegram group.