Weather Example
Context name: meteo_paris
Method: GET
URL: https://api.weather.example/current?city=Paris
Expression:
'cold_alert' if {meteo_paris.temperature} < 3 else 'ok'
Complete guide to context building for NotionPyx expressions.
Notionpyx uses Notion API version 2026-03-11. This version is centralized in the module core/notion/notion_client_wrapper.py.
Notion webhooks allow receiving real-time notifications when page content changes. The endpoint /webhooks/notion only accepts POST requests.
The np_ai property in a Notion page contains the local prompt. The pyx_ai engine:
blocks.children.listblocks.children.append after erase_contentAfter each pyx_ai execution, a comment is added to the page with:
Notionpyx records:
The Context Builder allows fetching external data (HTTP API) and custom variables to produce a global context usable in your expression rules.
All loaded values are normalized and exposed as variables that you can then reference in Notionpyx expressions.
A context is a named data source. Each context can call an API, return JSON, then inject this JSON into the global context under a prefix.
Context name: meteo_paris
JSON received: {"temperature": 18, "condition": "clear"}
Available variables:
- {meteo_paris.temperature}
- {meteo_paris.condition}
Choose GET for simple read calls. Use POST when the API expects a JSON body.
Add your headers as key/value pairs. For the Notion API, URLs starting with https://api.notion.com/v1/ trigger automatic header injection.
The body is used for POST requests. You can include configuration variables.
{
"filter": {
"property": "Status",
"select": {"equals": "Open"}
}
}
The Load button executes the HTTP call and displays two outputs:
JSON can be nested. Notionpyx transforms it into flat paths.
Source JSON:
{
"time": {"current_hour": 14},
"location": {"city": "Paris"}
}
Flattened variables:
- {meteo_paris.time.current_hour}
- {meteo_paris.location.city}
These flattened variables are the ones to use in your expressions and conditions.
Context values are used with the {variable} syntax.
Allowed string operations (examples):
{place_city_name}.strip()
{place_city_name}.lower()
{place_city_name}.replace(' ','_')
{place_city_name}.split(',')[0]
regex({place_city_name}, r'[A-Z]+')
Add static or computed key/value pairs to enrich the Global Context without HTTP calls.
Key: timezone
Value: Europe/Paris
=> Usable via {timezone}
# and / or
({meteo_paris.temperature} < 5) and ({meteo_paris.condition} != 'snow')
({timezone} == 'Europe/Paris') or ({timezone} == 'Europe/Brussels')
# ternary
'umbrella' if {meteo_paris.condition} == 'rain' else 'sunglasses'
Context name: meteo_paris
Method: GET
URL: https://api.weather.example/current?city=Paris
Expression:
'cold_alert' if {meteo_paris.temperature} < 3 else 'ok'
Context name: notion_tasks
Method: POST
URL: https://api.notion.com/v1/data_sources/<data_source_id>/query
Body:
{
"filter": {
"property": "Done",
"checkbox": {"equals": false}
}
}
Possible variables after load:
- {notion_tasks.results[0].id}
- {notion_tasks.results[0].properties.Name.title[0].plain_text}
Custom variable: user_lang = en
Expression:
'Bonjour' if {user_lang} == 'fr' else 'Hello'
meteo_paris, notion_tasks).