How to use Gitlab API to check if a pipeline/job is "stuck"

I am using Gitlap API to check the status of pipeline. There are time at which the pipeline is going to “pending” status with “stuck” flag. How do we check if a pipeline/job got a “stuck” flag using API? Currently I am only getting the status as pending when trying to fetch the details of pipeline or job.