hi, I don't believe there's a way to do this. If you were to take a look at the API explorer section for "share" you can see the most it includes is the ID of the thing you are sharing with (user, team, role, group, company) and the type of access you have given it (e.g. sharing a project with manage access vs with contribute access).
i.e. you can search for documents shared with users by their specific ID, so you could try to search for all your external users by listing all their IDs. But you cannot query for a user's license in order to not have to put in everyone's ID.