Query user data

Creating an app where user’s submit what country they are from. Now need to run query to count number of users per country. How can this be done in Blockstack?

Hey @blockchain.id.blocks,

You would need to make a client program that did the following:

  • crawl through the set of usernames (via the /v1/names and /v1/subdomains endpoints)
  • for each username, if they have a profile with an apps entry with your app, then do the following:
    • read the country file
    • increment your per-country file

You have to do a scan each time. A couple good examples of real-world apps that do this are theblockstacks.com, afari.io, and app.travelstack.club. In the latter two cases, the apps have an accompanying ‘indexer’ service that not only crawls profiles per the above, but also implements a write-through cache of app data – each client writes to both their Gaia bucket via putFile(), as well as posts the same information to the indexer, thereby ensuring that the indexer state stays up-to-date with writes.

ok will try that. thank you for prompt response.

do you have an example of how to use indexer service on blockstack. thks