GitLab API to find tree of parent branches

I am attempting to write a script using the GitLab APIs, via cURL, to enter a branch and find the tree up to the main branch. I tried GET api/v4/projects/99/repository/branches?search=my_story_branch; however, the parent_id comes back as null.
example: from MAIN branch the feature_branch was created, from the feature branch the my_story_branch was created. I want to execute myScript my_story_branch, and get a result:
my_story_branch
feature_branch
MAIN

My work-around; not my ideal way to do it, is to use git commands. It’s clugy, but it work… I used a combination of “git show-branch --list” and “git branch -r”. Unless someone knows of a cleaner way to do this then I’ll consider this closed. For this use, I don’t enter a branch name, I have to be in the git clone.