# API asynchronous query

**URL:** <https://forum.asana.com/t/api-asynchronous-query/134597>\
**Category:** API & Developers\
**Tags:** api, custom-fields, subtasks, tasks\
**Created:** [2 September 2021 18:32 UTC](https://forum.asana.com/t/api-asynchronous-query/134597 "2021-09-02T18:32:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles\_Lane](https://luna1.co/8d76cd.png) [@Charles\_Lane](https://forum.asana.com/u/Charles_Lane)\
**Post date:** [2 September 2021 18:32 UTC](https://forum.asana.com/t/api-asynchronous-query/134597/1 "2021-09-02T18:32:50Z")

</div>

I have written a sequence to gather all subtasks, along with their custom fields of tasks in a project. However, the execution time is long - several minutes for one project, about 13 min for 3 projects. I would like to run the sequence asynchronously, but can’t find examples of how to integrate asyncio or aiohttp modules with the asana module, specifically asana’s client class & ‘find\_by\_id’ tasks function. Is there a way to use this function with an asyncio session? My current approach for creation of the subtask dataframe for a list of projects is below:

########## dataframe comprised of all subtasks ##########

time.start()

df\_s=pd.DataFrame()

for j in s3:

```
l_path=r'/projects/'+j+r'/tasks' #api path for all tasks in the requisite project

i_tasks = t.request(method='get',path=str(l_path),verify=False) #all tasks for a particular project

for k in i_tasks:

    st=t.request(

        method='get',

        path=str(r'/tasks/'+(k['gid'])+r'/subtasks'),

        verify=False

        )

    if st == []:

        pass

    elif st != []:

        for l in st:

            s=t.tasks.find_by_id(task=l['gid'],headers=new_header) #get complete results for a particular subtask

            d=pd.json_normalize(

                s,

                record_path=['custom_fields'],

                meta=['gid','name','parent','assignee','completed'],

                record_prefix='cf_',

                )

            parent_name=[]

            parent_gid=[]

            assignee_name=[]

            assignee_gid=[]

            for m in d['parent']:

                parent_name.append(m['name'])

                parent_gid.append(m['gid'])

            for n in d['assignee']:

                if n == None:

                    assignee_name.append(None)

                    assignee_gid.append(None)

                else:

                    assignee_name.append(n['name'])

                    assignee_gid.append(n['gid'])

            d['parent_name']=parent_name

            d['parent_gid']=parent_gid

            d['assignee_name']=assignee_name

            d['assignee_gid']=assignee_gid

            d_clean=d.drop(['parent','cf_enum_options','assignee'],axis=1)

            df_s=df_s.append(d_clean,ignore_index=True)

```

time.stop()

########## end ##########

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [30 May 2025 19:05 UTC](https://forum.asana.com/t/api-asynchronous-query/134597/2 "2025-05-30T19:05:14Z")

</div>

Closed on 30 May 2025 19:05 UTC


