1

Is there an option to create new Gist with PyGithub?

There is such API option on GitHub, however it seems to be missing in PyGithub.

Asclepius
  • 57,944
  • 17
  • 167
  • 143
MrBr
  • 481
  • 4
  • 5

1 Answers1

1

Use Github.get_user followed by AuthenticatedUser.create_gist:

gh = github.Github("auth token")
gh_auth_user = gh.get_user()
gist = gh_auth_user.create_gist(public=False, files={"myfile.txt": github.InputFileContent("my contents")}, description="my description")
Asclepius
  • 57,944
  • 17
  • 167
  • 143
MrBr
  • 481
  • 4
  • 5
  • do you happen to know how to *update* an existing gist? – XoXo Jan 02 '20 at 22:56
  • Gist is a git repository. I'm cloning it locally after creation, then working with it like with regular git repo. – MrBr Jan 04 '20 at 11:21