docs: def get_endpoints_using_catalog_api(domain, token):
      """
      Implements a raw HTTP GET against the entire Socrata portal for the domain in question. This method uses the
      second of the two ways of getting this information, the catalog API.
  
      Parameters
      ----------
      domain: str
          A Socrata data portal domain. "data.seattle.gov" or "data.cityofnewyork.us" for example.
      token: str
          A Socrata application token. Application tokens can be registered by going onto the Socrata portal in
          question, creating an account, logging in, going to developer tools, and spawning a token.
  
      Returns
      -------
      Portal dataset metadata from the catalog API.
      """
      # Token required for all requests. Providing login info instead is also possible but I didn't implement it.
      headers = {"X-App-Token": token}
  
      # The API will return only 100 requests at a time by default. We can ask for more, but the server seems to start
      # to lag after a certain N requested. Instead, let's pick a less conservative pagination limit and spool up with
      # offsets.
      #
      # At the time this library was written, Socrata would return all of its results in a contiguous list. Once you
      # maxed out, you wouldn't get any more list items. Later on this was changed so that now if you exhaust portal
      # entities, it will actually take you back to the beginning of the list again!
      #
      # As a result we need to perform our own set-wise check to make sure that what we get isn't just a bit of the
      # same list all over again.
      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:  # we are continuing to stream
              # TODO: 999 not 1000 b/c the API suffers off-by-one errors. Can also do worse, however. Compensate?
              # cf. https://github.com/ResidentMario/pysocrata/issues/1
              ret += data['results']
              endpoints_thus_far.update(new_endpoints)
              offset += 1000
              continue
          else:  # we are ending on a stream with some old endpoints on it
              ret += [r for r in data['results'] if r['resource']['id'] in new_endpoints]
              break
  
      return ret