[Python] Palantir Foundry REST API endpoint for dataset queries?

Discussão em 'Python' iniciado por Stack, Março 11, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to be able to query a dataset via Palantir Foundry's REST API, but keep getting a 404 response code. The documentation does not appear to have any information about how to do this, but it seems like a fairly basic need. I've also encountered a few endpoints in the past that aren't a part of their official documentation, so I'm hoping that it's available and I'm just not calling it correctly.

    Any help would be greatly appreciated.

    Code is as follows:

    import requests

    foundry_token = "api_token"
    foundry_base_url = "https://fiserv.palantirfoundry.com"
    dataset_rid = "ri.foundry.main.dataset.xxxx"

    def query_foundry_dataset(base_url, token, dataset_rid):
    headers = {
    "Authorization": f'Bearer {token}',
    "Content-Type": 'application/json'
    }

    query_payload = {
    "sql": "SELECT Column1, Column2 FROM dataset LIMIT 1000"
    }

    url = f"{base_url}/api/v2/datasets/{dataset_rid}/transactions/query"

    response = requests.post(url, headers=headers, json=query_payload)

    if response.status_code == 200:
    return response.json()
    else:
    print(f"Query Failed: {response.status_code}")
    print(response.text)
    return None

    result = query_foundry_dataset(
    base_url=foundry_base_url,
    token=foundry_token,
    dataset_rid=dataset_rid
    )

    print(result)

    Continue reading...

Compartilhe esta Página