Sorry this is put as an answer as I can't comment due to the rep requirement, but I think you need to use the GraphQL API instead of REST.