Unified API
KDeps v2 simplifies data access with a unified API. Just a few core functions provide access to all data sources, replacing the complex API surface of previous versions.
Core Functions
These functions are available in all expression contexts (string interpolation {{ }} and expr blocks).
1. get()
The workhorse function for retrieving data. It uses a smart priority chain to find what you're looking for.
# Auto-detect source
query: get('q')Priority Chain:
- Items (Iteration context)
- Memory (Request-scoped storage)
- Session (User persistent storage)
- Outputs (Resource execution results)
- Query (URL parameters)
- Body (Request body)
- Headers (HTTP headers)
- Files (Uploaded files)
- Metadata (System info)
Explicit Source: You can bypass the chain by specifying a type hint:
get('q', 'param') # Force query/body param
get('auth', 'header') # Force header
get('user', 'session') # Force session2. set()
Stores data for later use.
# Store in memory (current request only)
expr:
- set('count', 1)
# Store in session (persists across requests)
expr:
- set('user_id', '123', 'session')3. file()
Accesses file content.
# Get uploaded file content
content: file('doc.pdf')
# Get by pattern
images: file('*.jpg')4. info()
Accesses request and system metadata.
id: info('requestId')
ip: info('clientIp')
path: info('path')Advanced Functions
For more specialized needs, additional helper functions are available:
json(data)- Convert data to JSON stringsafe(obj, path)- Safely access nested propertiesdebug(obj)- Inspect objectsdefault(val, fallback)- Handle missing values
See the Expression Functions Reference for the complete list.
Resource Accessors
While get('resourceId') is the standard way to access outputs, resource-specific accessors provide granular data:
- Python/Exec:
python.stdout('id'),python.stderr('id'),python.exitCode('id') - HTTP:
http.responseBody('id'),http.responseHeader('id', 'Name') - LLM:
llm.response('id'),llm.prompt('id')
These are typically used in expr blocks for conditional logic or error handling.
Next Steps
- Request Object - HTTP request data and file methods
- Resources Overview - Learn about resource types
- Tools - LLM function calling
- Workflow Configuration - Session settings