Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
This API wrapper mainly focuses on the Gists part of the GitHub API, not the entire API
All unchecked features are planned
GET
ing from /gists
, to get authenticated user's GistsGET
ing from /users/{username}/gists
to get a user's GistsGET
ing from /gists/public
to get public GistsGET
ing from /gists/starred
to get authenticated user's starred GistsPOST
ing to /gists
, to create a GistGET
ing from /gists/{gist_id}
to get a GistPATCH
ing to /gists/{gist_id}
, to edit a GistDELETE
ing from /gists/{gist_id}
to delete a GistPOST
ing to /gists/{gist_id}/forks
to fork a Gist to the authenticated user's profileGET
ing from /gists/{gist_id}/star
to check if a gist is starred by the authenticated userPUT
ing /gists/{gist_id}/star
to star a Gist with the authenticated userDELETE
ing from /gists/{gist_id}/star
to unstar a Gist with the authenticated userGET
ing from /gists/{gist_id}/comments
to get all comments on a GistPOST
ing to /gists/{gist_id}/comments
to create a comment on a GistGET
ing from /gists/{gist_id}/comments/{comment_id}
to get a comment on a GistPATCH
ing to /gists/{gist_id}/comments/{comment_id}
to edit a comment of the authenticated user on a GistDELETE
ing from /gists/{gist_id}/comments/{comment_id}
to delete a comment of the authenticated user on a Gistpip install gists.py
or
pip install git+https://github.com/WitherredAway/gists.py
This section is a work in progress
# Import asyncio
import asyncio
# Import the package
import gists
# Create a client instance
client = gists.Client()
async def main_get():
# Getting a gist does not require authorization
# This method fetches the gist associated with the provided gist id, and returns a Gist object
gist = await client.get_gist("GIST ID")
return gist
# Run the main_get() function
gist = asyncio.run(main_get())
# Print the gist's description
print(gist.description)
async def main_create() -> gists.Gist:
# Creating a gist requires authorization, use client.authorize to authorize the client
await client.authorize("YOUR GITHUB PERSONAL ACCESS TOKEN")
# The description to set
description = "Hi this is a gist"
# The files to create in the new gist
files = [
gists.File(name="example.txt", content="I like turtles"),
gists.File(name="helloworld.py", content="print(\"Hello, world!\")"),
]
# Whether or not the gist should be public
public = True
# This method creates a new gist and returns a Gist object associated with that gist
gist = await client.create_gist(files, description=description, public=public)
return gist
# Run the main_create() function
gist_1 = asyncio.run(main_create())
# Print the gist's id
print(gist_1.id)
async def main_edit():
# Editing a gist requires authorization, but we already authorized the client when creating the gist
# The description to edit to
description = "Hello this is a gist, but edited"
# The files to edit in gist
files = [
# Use a unique filename for the name parameter to create a new file
gists.File(name="newfile.txt", content="New file"),
# Use an existing filename for the name parameter to edit that file
gists.File(name="example.txt", content="I like all animals"),
# Use an existing filename for the name parameter and
# pass in the new_name parameter to edit the name of that file,
# in which case the content parameter is not mandatory
gists.File(name="helloworld.py", new_name="hellouniverse.py")
]
await gist_1.edit(files=files, description=description)
# Run the main_edit() function
asyncio.run(main_edit())
# Print the gist's edited description
print(gist_1.description)
FAQs
A simple asynchronous python wrapper for the GitHub Gists API
We found that github-gists demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.