Skip to content
OpenSmartRoute
Skillv1.0.0

palantir-hello-world

Create a minimal working Palantir Foundry example querying Ontology objects. Use when starting a new Foundry integration, testing your setup, or learning basic Foundry API and Ontology patterns. Trigg

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (skills/.curated/palantir-hello-world/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill palantir-hello-world. Copyright stays with the author (MIT).

Palantir Hello World

Overview

Build a minimal working example that connects to Palantir Foundry, queries Ontology objects via the REST API, reads a dataset, and applies an action. Uses real foundry-platform-sdk Python API calls.

Prerequisites

  • Completed palantir-install-auth setup
  • Valid bearer token or OAuth2 credentials
  • At least one Ontology with object types configured in your Foundry enrollment

Instructions

Step 1: List Available Ontologies

import os
import foundry

client = foundry.FoundryClient(
    auth=foundry.UserTokenAuth(
        hostname=os.environ["FOUNDRY_HOSTNAME"],
        token=os.environ["FOUNDRY_TOKEN"],
    ),
    hostname=os.environ["FOUNDRY_HOSTNAME"],
)

# List all ontologies you have access to
for ont in client.ontologies.Ontology.list():
    print(f"Ontology: {ont.api_name}  RID: {ont.rid}")

Step 2: Query Ontology Objects

# List objects of type "Employee" from the default ontology
# The object type api_name comes from your Ontology configuration
ONTOLOGY = "your-ontology-api-name"
OBJECT_TYPE = "Employee"

objects = client.ontologies.OntologyObject.list(
    ontology=ONTOLOGY,
    object_type=OBJECT_TYPE,
    page_size=5,
)

for obj in objects.data:
    props = obj.properties
    print(f"  {props.get('fullName', 'N/A')}{props.get('department', 'N/A')}")

Step 3: Get a Single Object by Primary Key

employee = client.ontologies.OntologyObject.get(
    ontology=ONTOLOGY,
    object_type=OBJECT_TYPE,
    primary_key="EMP-001",
)
print(f"Found: {employee.properties}")

Step 4: Read a Dataset

# Read rows from a Foundry dataset (tabular)
DATASET_RID = "ri.foundry.main.dataset.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

# Get dataset metadata
dataset = client.datasets.Dataset.get(dataset_rid=DATASET_RID)
print(f"Dataset: {dataset.name}, Path: {dataset.path}")

# Read rows from the dataset (CSV format)
content = client.datasets.Dataset.read(
    dataset_rid=DATASET_RID,
    branch_id="master",
    format="arrow",  # or "csv"
)
print(f"Read {len(content)} bytes of data")

Step 5: Apply an Ontology Action

# Actions modify objects — e.g., updating an employee's department
result = client.ontologies.Action.apply(
    ontology=ONTOLOGY,
    action_type="updateDepartment",
    parameters={
        "employeeId": "EMP-001",
        "newDepartment": "Engineering",
    },
)
print(f"Action result: {result.validation}")

Step 6: Run and Verify

set -euo pipefail
python hello_foundry.py
# Expected output:
# Ontology: my-company  RID: ri.ontology.main.ontology.xxx
# Employee: Jane Doe — Engineering
# Action result: VALID

Output

  • Authenticated connection to Palantir Foundry
  • Listed ontologies and object types
  • Retrieved objects with property values
  • Read dataset content
  • Applied an action to modify an object

Error Handling

Error Cause Solution
ObjectTypeNotFound Wrong api_name Check Ontology Manager for exact object type names
ObjectNotFound Invalid primary key Verify the key exists; keys are case-sensitive
ActionValidationFailed Missing required params Check action definition for required parameters
DatasetNotFound Wrong RID or no access Verify RID in Foundry UI; check project permissions
401 Unauthorized Token expired Regenerate in Developer Console

Examples

Using the REST API Directly (curl)

# List objects via REST
curl -s -H "Authorization: Bearer $FOUNDRY_TOKEN" \
  "https://$FOUNDRY_HOSTNAME/api/v2/ontologies/my-ontology/objects/Employee?pageSize=5" \
  | python -m json.tool

TypeScript OSDK Equivalent

import { createClient } from "@osdk/client";
import { Employee } from "@my-app/sdk";  // generated from OSDK

const employees = await client(Employee)
  .where({ department: "Engineering" })
  .fetchPage({ pageSize: 10 });

employees.data.forEach(emp => console.log(emp.fullName));

Resources

Next Steps

  • Set up iterative development: palantir-local-dev-loop
  • Build data pipelines with transforms: palantir-core-workflow-a
  • Query and link objects: palantir-core-workflow-b

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-palantir-hello-world/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-palantir-hello-world.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-palantir-hello-world",
  "kind": "skill",
  "name": "palantir-hello-world",
  "description": "Create a minimal working Palantir Foundry example querying Ontology objects. Use when starting a new Foundry integration, testing your setup, or learning basic Foundry API and Ontology patterns. Trigger with phrases like \"palantir hello world\", \"palantir example\", \"palantir quick start\", \"foundry first query\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general_chat",
      "coding"
    ],
    "tags": [
      "skill-md",
      "saas",
      "palantir",
      "foundry",
      "ontology",
      "getting-started",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Create a minimal working Palantir Foundry example querying Ontology objects. Use when starting a new Foundry integration, testing your setup, or learning basic Foundry API and Ontology patterns. Trigger with phrases like \"palantir hello world\", \"palantir example\", \"palantir quick start\", \"foundry first query\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "skills/.curated/palantir-hello-world/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/skills/.curated/palantir-hello-world/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/skills/.curated/palantir-hello-world/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit,",
      "Bash(pip:*),",
      "Bash(npm:*)"
    ],
    "license": "MIT"
  },
  "instructions": "# Palantir Hello World\n\n## Overview\n\nBuild a minimal working example that connects to Palantir Foundry, queries Ontology objects via the REST API, reads a dataset, and applies an action. Uses real `foundry-platform-sdk` Python API calls.\n\n## Prerequisites\n\n- Completed `palantir-install-auth` setup\n- Valid bearer token or OAuth2 credentials\n- At least one Ontology with object types configured in your Foundry enrollment\n\n## Instructions\n\n### Step 1: List Available Ontologies\n\n```python\nimport os\nimport foundry\n\nclient = foundry.FoundryClient(\n    auth=foundry.UserTokenAuth(\n        hostname=os.e",
  "cost": {
    "context_tokens": 1154
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-palantir-hello-world/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.