Returns a list of resources (data endpoints) on a Socrata domain.

    The catalog API and JSON endpoint both return useful information, but the information that they return is useful
    in slightly different ways. The JSON endpoint provides less information about the resource in question,
    including lacking a field for what *type* of resources the entity in question is, but has the advantage of
    returning only data resources (endpoints of other things, like charts and filters, are excluded). The catalog API
    provides more information, and does so for all endpoints, but provides no way of filtering that set down to
    resources only because of issues with its categorization of "map" entities.

    Hence, to capture the actual data resources on the portal, we match the APIs against one another.

    Note that it is technically possible for a resource to be published as a filter or view of a private endpoint.
    This method does not capture resources published in this (highly discouraged, but nevertheless occasionally
    practiced) manner.

    Also note that this method does not filter out resources with a community provenance. You can filter these out
    yourself downstream using the `provenance` metadata field.

    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
    -------
    A list of metadata stores for all data resources on the domain.

def get_resources(domain, token):
    """
    Returns a list of resources (data endpoints) on a Socrata domain.

    The catalog API and JSON endpoint both return useful information, but the information that they return is useful
    in slightly different ways. The JSON endpoint provides less information about the resource in question,
    including lacking a field for what *type* of resources the entity in question is, but has the advantage of
    returning only data resources (endpoints of other things, like charts and filters, are excluded). The catalog API
    provides more information, and does so for all endpoints, but provides no way of filtering that set down to
    resources only because of issues with its categorization of "map" entities.

    Hence, to capture the actual data resources on the portal, we match the APIs against one another.

    Note that it is technically possible for a resource to be published as a filter or view of a private endpoint.
    This method does not capture resources published in this (highly discouraged, but nevertheless occasionally
    practiced) manner.

    Also note that this method does not filter out resources with a community provenance. You can filter these out
    yourself downstream using the `provenance` metadata field.

    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
    -------
    A list of metadata stores for all data resources on the domain.
    """
    json_endpoints = get_endpoints_using_raw_json_emission(domain)
    catalog_api_output = get_endpoints_using_catalog_api(domain, token)
    catalog_endpoints = [d['permalink'].split("/")[-1] for d in catalog_api_output]
    json_endpoints = [d['landingPage'].split("/")[-1] for d in json_endpoints['dataset']]
    resources = []
    for i, endpoint in enumerate(json_endpoints):
        try:
            catalog_ind = catalog_endpoints.index(json_endpoints[i])
        except ValueError:  # The catalog does not contain this dataset. Skip it.
            pass
        else:
            resources.append(catalog_api_output[catalog_ind])

    # Exclude stories, which are remixed, not published, data.
    resources = [d for d in resources if d['resource']['type'] != 'story']

    return resources