githubgithub-apigithub-projects

GitHub Projects Beta - How to get the data from a view in the API


My company is using the new GitHub projects beta and we're really enjoying the experience, but we're facing a problem and it is how to export the data from a specific view (or even all the data) with all the custom columns that we have.

enter image description here

The ideal solution for us is to get this same data as JSON using the API.

Using https://api.github.com/orgs/.../issues does not work because the issues does not have the custom columns that we create inside the project, and https://api.github.com/orgs/.../projects does not have the data of the issues.

Any idea or work-around to get this data easily using APIs?


Solution

  • After reading the feedback post on GitHub, it's not possible to do it with API, just GraphQL, at least for now.

    So my problem was solved with this useful code.

    To get the first 100 project from your organization and their ID:

    query{
        organization(login: "MY_ORG") {
          projectsNext(first: 20) {
            nodes {
              id
              title
            }
          }
        }
      }
    

    To get the first 100 issues and drafts from a specific project:

    {
      node(id: "My_Project_ID") {
        ... on ProjectNext {
          items(first: 100, after: null) {
            edges {
              cursor
            }
            nodes {
              content {
                ... on Issue {
                  title
                  assignees(first: 1) {
                    nodes {
                      login
                    }
                  } 
                  milestone {
                    title
                  }
                  labels(first: 5) {
                    nodes {
                      name
                    }
                  }
                  repository{
                    name
                  }
                }
              }
              fieldValues(first: 15) {
                nodes {
                  value
                  projectField {
                    name
                    settings
                  }
                }
              }
            }
          }
        }
      }
    }
    

    Those codes can be easily tested in THIS LINK