Search code examples
github-apioctokit.netprobot

How can I enable GitHub preview features, like topics?


I'm using Apps - listRepos to get a list of all the repositories installed on my Probot GitHub application.

I want the response data to include the GitHub topics for each repository. This is currently only available as a preview feature:

The topics property for repositories on GitHub is currently available for developers to preview. To view the topics property in calls that return repository results, you must provide a custom media type in the Accept header:

application/vnd.github.mercy-preview+json

So I think I want to "provide a custom media type in the Accept header".

Is there a way to enable GitHub preview features in Probot? Perhaps by somehow setting RequestOptions?


Solution

  • Success: I added a headers object to my listRepos() call.

    const repositories = await octokit.paginate(
      octokit.apps.listRepos({
        per_page: 100,
        headers: {
          accept: 'application/vnd.github.machine-man-preview+json,application/vnd.github.mercy-preview+json'
        }
      }),
      res => res.data.repositories // Pull out only the list of repositories from each response.
    );