Building a Scriptable widget with Notion API integration

I’m working on creating a widget using Scriptable that connects to the Notion API. My goal is to fetch the number of entries from a specific database.

I followed the official documentation to set up my integration token and shared the database properly. I tested everything with a basic cURL command first:

curl 'https://api.notion.com/v1/databases/MY_DATABASE_ID/query' \
  -H 'Authorization: Bearer MY_TOKEN' \
  -H 'Notion-Version: 2022-06-28' \
  --data '{
      "filter": {
          
      }
  }'

The cURL request works perfectly and returns the expected data.

However, when I try to implement the same logic in Scriptable, I run into issues:

async function getNotionData() {
  const apiUrl = 'https://api.notion.com/v1/databases/MY_DATABASE_ID/query'
  let apiRequest = new Request(apiUrl)
  apiRequest.headers = {
    'Authorization': `Bearer ${notionApiToken}`, 
    'Notion-Version': '2022-06-28'
  }
  apiRequest.body = Data.fromString('{"filter": {}}')
  
  const response = await apiRequest.loadJSON()
  console.log(response)
  return response
}

This Scriptable code throws an error saying “resource exceeds maximum size”. I’m not sure what’s causing this problem since the cURL version works fine. Has anyone encountered this issue before or knows how to troubleshoot it?

Classic integration headache - I’ve hit this dozens of times. Manual fixes work short-term, but you’ll get burned by rate limits, error handling, and auth token security later.

Had this exact problem building dashboard widgets for our team. Skip wrestling with Scriptable’s quirks and set up the whole flow in Latenode instead. It nails the Notion API connection, processes data however you want, and pushes clean results to any endpoint your widget can hit.

Real advantage? You can add filtering, data transformation, and caching without shoving everything into widget script hell. When Notion inevitably changes their API, you update one workflow instead of hunting down widget code on everyone’s devices.

Build a simple HTTP endpoint in Latenode that grabs your database count, then call it from your widget. Takes 10 minutes and actually scales.

Had this exact issue last month with my habit tracker widget. The problem isn’t just the missing POST method - Scriptable’s picky about how you format the request body. Use apiRequest.method = 'POST' and apiRequest.body = JSON.stringify({"filter": {}}) instead of Data.fromString. Scriptable gets weird with Data.fromString for JSON stuff. Also check your token permissions in Notion - your integration might have read access but the database sharing settings could be wrong, causing random errors. When cURL works but Scriptable doesn’t, it’s usually a request formatting problem, not the API itself.

That “resource exceeds maximum size” error happens when Scriptable can’t handle the response size. cURL works fine, but Scriptable’s more picky about memory limits. Add a page size limit to your request body like {“filter”: {}, “page_size”: 10}. Also make sure you’ve got apiRequest.method = ‘POST’ and the header ‘Content-Type’: ‘application/json’. I hit the same issue with big Notion databases - limiting page size fixed it right away. You can always add pagination later if you need more data.

Add a content-type header and try loadString() instead of loadJSON() to see the raw response. Notion sometimes returns weird formatting that breaks Scriptable’s JSON parser. I’ve hit the same issue - response looked fine but Scriptable couldn’t parse it.

you probably need to set the http method explicitly. add apiRequest.method = 'POST' before making the request. scriptable defaults to GET sometimes, which screws up body data.