0

In trying get data from this API (I have a token..): https://devtools.dol.gov/APISampler/Home/Index1?datasetName=OUI%20Initial%20Claims

It seems that I'm not getting all the data, the latest year I get is 2016.

What am I doing wrong?

def _get(url):
    response = requests.get(url)
    return response.json()

def get_data(url):
    data = _get(url)
    all_data = []
    while True:
        for r in data['d']['results']:
            all_data.append(r)
        next_url = data['d'].get('__next')
        if not next_url:
            break
        data = _get(next_url)
    return all_data

url = "https://api.dol.gov/V1/Statistics/OUI_InitialClaims/unemploymentInsuranceInitialClaims"
all_data = get_data(url)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.