def get_endpoints_using_catalog_api(domain, token):
    headers = {"X-App-Token": token}
    uri = "http://api.us.socrata.com/api/catalog/v1?domains={0}&offset={1}&limit=1000"
    ret = []
    endpoints_thus_far = set()
    offset = 0
    while True:
        try:
            r = requests.get(uri.format(domain, offset), headers=headers)
            r.raise_for_status()
        except requests.HTTPError:
            raise requests.HTTPError("An HTTP error was raised during Socrata API ingestion.".format(domain))
        data = r.json()
        endpoints_returned = {r['resource']['id'] for r in data['results']}
        new_endpoints = endpoints_returned.difference(endpoints_thus_far)
        if len(new_endpoints) >= 999:
            ret += data['results']
            endpoints_thus_far.update(new_endpoints)
            offset += 1000
            continue
        else:
            ret += [r for r in data['results'] if r['resource']['id'] in new_endpoints]
            break
    return ret