Count Child Nodes Tana Helper

I had a need to know how many child nodes I had under a given parent and couldn’t see an easy way to get that information.
I created a very simple server that has a /count endpoint. Sending a POST request to the server with the JSON body that is a parent node and child nodes will return the number of direct children (it doesn’t do children of children).
I created a Tana Command to call the API. One thing I couldn’t figure out was how to display the result without having it written to Tana. Ideally I’d like to just show an alert with the number, but right now I need to write the returned value to a field.
DISCLAIMER: Using this will send the contents of your node to the API endpoint. No information is logged, saved or stored, but it is unencrypted. Don’t send anything private or confidential. Use at your own risk.

Here’s the command:

Setup

Create a Make API request Command:

– API method: POST
– Payload: Tana Paste of whole node
– Target node: Create a field and reference it (Count of Children)
– Url: https://tana-helpers.fly.dev/count
– Insert output strategy: replace contents (this is supposed to be the default, but I was having trouble:

If you want to also display an alert create a Show alert command:

– Prompt: Reference the same field at Target node

To use: put your cursor on a parent node and run the command from the command palette.

THE COMMAND IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE COMMAND OR THE USE OR OTHER DEALINGS IN THE COMMAND. 🐶
Tana logo