You should not be able to cal your own API using a GitHub URL.
You cannot execute any custom process on the server (GitHub) side, except GitHub actions (like those ones).
You can use for instance Netlify to test your API from your GitHub project.
Can we use Gitlab for achieving the result ?
No: GitHub or GitLab are for hosting repositories, not for serving any custom services from those repositories (beside GitHub Pages or GitLab Pages, for publishing static websites directly from a repository)
Again, for exposing a REST API, you need a third party server.