import json import asyncio import aiohttp QUERY = """ query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name description locations args { ...InputValue } } } } fragment FullType on __Type { kind name description fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue } interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } } fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } fragment TypeRef on __Type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } } """ async def main(): url = 'https://api.ardaudiothek.de/graphql' params = { 'query': QUERY, 'variables': '{}', } async with aiohttp.ClientSession() as session: async with session.get(url, params=params) as response: response.raise_for_status() data = await response.json() short = {} for t in data['data']['__schema']['types']: short[t['name']] = { 'kind': t['kind'], } if t['description']: short[t['name']]['description'] = t['description'] if t['fields']: short[t['name']]['fields'] = { f['name']: f['type']['name'] for f in t['fields'] } if t['enumValues']: short[t['name']]['enumValues'] = [ v['name'] for v in t['enumValues'] ] print(json.dumps(short, indent=2)) if __name__ == '__main__': asyncio.run(main())