Hello, @simonecorsi
I noticed that this issue #161 has been open for nearly a year, but it seems that the GitHub official community hasn't been very proactive in following up. As a result, there is still no official API for lists. I find it quite regrettable. Of course, the lists feature is currently in beta, so it's somewhat understandable that there hasn't been much progress.
I have been following this issue #161 for a long time, and I'm also using the official Android client. Recently, I became curious about how the client implements the lists feature, so I captured some network packets and found that GraphQL is being used. I would like to dive deeper into it, but my abilities are limited. I'm not a software developer, so all I can do is provide you with some of the data packets I captured. The data returned by these APIs includes information about lists. I hope you can implement the functionality of categorizing based on lists soon.
Fetching lists
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.github.com/graphql',
'headers': {
'Host': 'api.github.com',
'User-Agent': 'GitHub/1.112.0 (com.github.android; build:719; Android 13; M2012K11AC)',
'Authorization': 'Bearer PersonalAccessToken',
'Content-Type': 'application/json',
'Accept': '*/*',
'Connection': 'keep-alive'
},
body: JSON.stringify({
"operationName": "UserLists",
"variables": {
"login": "wavetg",
"first": 100
},
"query": "query UserLists($login: String!, $first: Int) { user(login: $login) { id hasCreatedLists lists(first: $first) { nodes { ...UserListFragment id } } } } fragment UserListFragment on UserList { id name isPrivate description items { totalCount } }"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Fetching starred repositories with lists information
Omit repetitive code, the key is the query string in the request body. Also, please pay attention to parameters: first , authorization , slug
body: JSON.stringify({
"operationName": "StarredRepositoriesQuery",
"variables": {
"login": "wavetg",
"first": 100,
"after": null
},
"query": "query StarredRepositoriesQuery($login: String!, $first: Int!, $after: String) { repositoryOwner(login: $login) { __typename ...NodeIdFragment ... on User { starredRepositories(first: $first, after: $after, orderBy: { field: STARRED_AT direction: DESC } ) { pageInfo { hasNextPage endCursor } nodes { __typename ...RepositoryListItemFragment ...IssueTemplateFragment id } } id } } } fragment NodeIdFragment on Node { id __typename } fragment avatarFragment on Actor { __typename ...NodeIdFragment avatarUrl } fragment RepositoryStarsFragment on Repository { __typename id stargazerCount viewerHasStarred } fragment RepositoryListItemFragment on Repository { __typename shortDescriptionHTML id name url isPrivate isArchived owner { __typename id login ...avatarFragment } primaryLanguage { color name id __typename } usesCustomOpenGraphImage openGraphImageUrl isInOrganization hasIssuesEnabled isDiscussionsEnabled isFork parent { name owner { id login } id __typename } ...RepositoryStarsFragment lists(first: 100, onlyOwnedByViewer: true) { nodes { id name __typename } } } fragment IssueTemplateFragment on Repository { issueTemplates { name about title body filename } contactLinks { name about url } issueFormLinks { about name url } isBlankIssuesEnabled isSecurityPolicyEnabled securityPolicyUrl id __typename }"
})
Fetching all repositories under a specific list
body: JSON.stringify({
"operationName": "FetchList",
"variables": {
"login": "wavetg",
"slug": "ListName",
"first": 100,
"after": null
},
"query": "query FetchList($login: String!, $slug: String!, $first: Int!, $after: String) { list(login: $login, slug: $slug) { id name description user { __typename ...actorFields id } items(first: $first, after: $after) { pageInfo { hasNextPage endCursor } nodes { __typename ...RepositoryListItemFragment ...IssueTemplateFragment } totalCount } __typename } } fragment NodeIdFragment on Node { id __typename } fragment avatarFragment on Actor { __typename ...NodeIdFragment avatarUrl } fragment actorFields on Actor { __typename login url ...avatarFragment ...NodeIdFragment } fragment RepositoryStarsFragment on Repository { __typename id stargazerCount viewerHasStarred } fragment RepositoryListItemFragment on Repository { __typename shortDescriptionHTML id name url isPrivate isArchived owner { __typename id login ...avatarFragment } primaryLanguage { color name id __typename } usesCustomOpenGraphImage openGraphImageUrl isInOrganization hasIssuesEnabled isDiscussionsEnabled isFork parent { name owner { id login } id __typename } ...RepositoryStarsFragment lists(first: 100, onlyOwnedByViewer: true) { nodes { id name __typename } } } fragment IssueTemplateFragment on Repository { issueTemplates { name about title body filename } contactLinks { name about url } issueFormLinks { about name url } isBlankIssuesEnabled isSecurityPolicyEnabled securityPolicyUrl id __typename }"
})
I have personally tested the above APIs, and they all return data successfully. If there are any errors, it might be due to some parameters that I may have missed, as I am not a software developer. However, if there are any omissions, I will do my best to assist and apologize for any inconvenience caused.
Thank you!๐