Yaak Logo
Yaak
Docs/Templating/Template Function Reference

Template Function Reference

Every built-in template function, with its arguments

Every template function below is built in and available without installing anything. Use them anywhere Yaak accepts text, with the ${[ name(arg='value') ]} syntax described in Template Functions.

Run yaak func show <name> to see the full argument definition for any function, or yaak func list to list what’s installed — including functions added by your own plugins, which won’t appear here.

1password

Function Description
1password.item(vault, item, field) Get a secret.

base64

Function Description
base64.decode(value) Decode a value from base64.
base64.encode(encoding=base64, value) Encode a value to base64.
Function Description
cookie.value(name, domain?) Read the value of a cookie in the jar, by name.

ctx

Function Description
ctx.environment() Get the ID of the currently active environment.
ctx.request() Get the ID of the currently active request.
ctx.workspace() Get the ID of the currently active workspace.

fs

Function Description
fs.readFile(path, encoding=utf8, trim) Read the contents of a file as utf-8.

hash

Function Description
hash.md5(input, encoding=base64) Hash a value to its hexadecimal representation.
hash.sha1(input, encoding=base64) Hash a value to its hexadecimal representation.
hash.sha256(input, encoding=base64) Hash a value to its hexadecimal representation.
hash.sha512(input, encoding=base64) Hash a value to its hexadecimal representation.

hmac

Function Description
hmac.md5(input, key, encoding=base64) Compute the HMAC of a value.
hmac.sha1(input, key, encoding=base64) Compute the HMAC of a value.
hmac.sha256(input, key, encoding=base64) Compute the HMAC of a value.
hmac.sha512(input, key, encoding=base64) Compute the HMAC of a value.

json

Function Description
json.escape(input) Escape a JSON string, useful when using the output in JSON values.
json.jsonpath(input, formatted, query) Filter JSON-formatted text using JSONPath syntax.
json.minify(input) Remove unnecessary whitespace from a valid JSON string.

keychain

Function Description
keychain(service, account) Access application passwords from the macOS Login keychain. Also available as keyring.

keychain reads from whichever secret store the host OS provides. The description above is the macOS one; on Windows it reads from Credential Manager, and on Linux from the Secret Service (GNOME Keyring, KWallet, and similar).

prompt

Function Description
prompt.text(label?, store=none) Prompt the user for input when sending a request.

random

Function Description
random.range(min=0, max=1, decimals?) Generate a random number between two values.

regex

Function Description
regex.match(input, regex=.*) Extract text using a regular expression.
regex.replace(input, regex=.*, replacement, flags=g?) Replace text using a regular expression.

request

Function Description
request.body.path(requestId, path)
request.body.raw(requestId) Also available as request.body.
request.header(requestId, header) Read the value of a request header, by name.
request.name(requestId)
request.param(requestId, param)

response

Function Description
response.body.path(request, path) Access a field of the response body using JsonPath or XPath. Also available as response.
response.body.raw(request) Access the entire response body, as text. Also available as response.
response.header(request, header) Read the value of a response header, by name.

secure

Function Description
secure(value) Securely store encrypted text.

timestamp

Function Description
timestamp.format(date?, format?) Format a date using a date-fns format string.
timestamp.iso8601(date?) Get the date in ISO8601 format.
timestamp.offset(date?, expression?) Get the offset of a date based on an expression.
timestamp.unix(date?) Get the timestamp in seconds.
timestamp.unixMillis(date?) Get the timestamp in milliseconds.

url

Function Description
url.decode(value) Decode a percent-encoded URL value.
url.encode(value) Encode a value for use in a URL (percent-encoding).

uuid

Function Description
uuid.v1() Generate a UUID V1.
uuid.v3(name, namespace) Generate a UUID V3.
uuid.v4() Generate a UUID V4.
uuid.v5(name, namespace) Generate a UUID V5.
uuid.v6(timestamp?) Generate a UUID V6.
uuid.v7() Generate a UUID V7.

xml

Function Description
xml.xpath(input, query) Filter XML-formatted text using XPath syntax.

Was this helpful?

Loading...