Asynchronous API Requests

182 Views Asked by At

I am trying to send multiple requests to an API using grequests, but I am getting no response, when I map the list. The API has a limit of about 1000 requests so it cannot be that I am getting denied.

import pandas as pd
import grequests
df = pd.read_csv(r"C:\Users\file.csv")
df['checked']= 'no'

data = pd.DataFrame(columns=['Company Name','First Name','Last Name','E-mail','phone'])
async_list = []

for index in range(2):
    print(index)
    print('tuk')
    params = {'api_key': '',
              'location': '',
              'q': df.loc[index,'companyName']
             }

    action_item = grequests.get('https://api.name.com/search',stream=False, params=params)
    async_list.append(action_item)




s = grequests.map(async_list)
print(async_list)
print(s)

I get the following result:

[<grequests.AsyncRequest object at 0x000002B29E6EEF70>, <grequests.AsyncRequest object at 0x000002B29C8D0AC0>]
[None, None]
0

There are 0 best solutions below