Hi, I m trying to fetch the status of all jobs in ...
# ask-community
c
Hi, I m trying to fetch the status of all jobs in a repository of dagster, Is there API exposed by dagster for that.
🤖 1
t
You can use the Dagster's GraphQL API to fetch these. The endpoint is
/graphql
relative to the the URL of your deployment. Here's a simple GraphQL query help get you started:
Copy code
query GetJobs {
  repositoriesOrError {
    ... on RepositoryConnection {
      nodes {
        location {
          name
          repositories {
            name
          }
        }
        jobs {
          name
        }
      }
    }
  }
}
s
Hi Chahat, Like Tim said, the GQL API might be useful for you here, but there might be a simpler solution-- exactly what information do you mean when you say “status of jobs”?
c
Hi Sean, I need help creating a Flask app that fetches the status of jobs in the current repository of Dagster running on any server, the status of the job meaning is it running, queued, canceled or failed.
s
I see-- in that case I think Tim’s suggestion is the way to go. You can modify his query like so to get the status of the most recent run (the runs should be ordered by recency by default):
Copy code
query GetJobs {
  repositoriesOrError {
    ... on RepositoryConnection {
      nodes {
        location {
          name
          repositories {
            name
          }
        }
        jobs {
          name
          runs(limit: 1) {
             status
          }
        }
      }
    }
  }
}