Pithub::Gists(3pm)

πŸ“¦
version 0.01043 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ Pithub::Gists ✨

okay bestie, welcome to the Pithub::Gists era πŸ’… this is the Github v3 Gists API wrapper and it's literally about to be your new obsession. part of the Pithub family, manual page Pithub::Gists(3pm), let's GO πŸ¦‹

🌸 VERSION 🌸

version 0.01043 β€” yes she's got a version, respect her πŸ’–


πŸŽ€ METHODS πŸŽ€

πŸ’¬ comments

gives you the keys to Pithub::Gists::Comments β€” like, the whole comment situation lives over there. go say hi πŸ‘‹

πŸ†• create

okay so we're making a brand new gist, main character energy fr:

POST /gists

Parameters:

  • data β€” mandatory hashref, and it's giving structured. it needs these keys:
    • description β€” optional string (yes optional, she's chill)
    • public β€” mandatory boolean (no skipping this one, bestie)
    • files β€” mandatory hashref, and pls check the examples section below for the deets πŸ‘€

Examples:

my $g = Pithub::Gists->new;
my $result = $g->create(
    data => {
        description => 'the description for this gist',
        public      => 1,
        files       => { 'file1.txt' => { content => 'String file content' } }
    }
);
if ( $result->success ) {
    printf "The new gist is available at %s\n", $result->content->{html_url};
}

Response: Status: 201 Created πŸ”₯

{
    "url": "https://api.github.com/gists/1",
    "id": "1",
    "description": "description of gist",
    "public": true,
    "user": {
        "login": "octocat",
        "id": 1,
        "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
        "url": "https://api.github.com/users/octocat"
    },
    "files": {
        "ring.erl": {
            "size": 932,
            "filename": "ring.erl",
            "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
            "content": "contents of gist"
        }
    },
    "comments": 0,
    "git_pull_url": "git://gist.github.com/1.git",
    "git_push_url": "git@gist.github.com:1.git",
    "created_at": "2010-04-14T02:15:15Z",
    "forks": [
    {
        "user": {
            "login": "octocat",
            "id": 1,
            "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
            "url": "https://api.github.com/users/octocat"
        },
        "url": "https://api.github.com/gists/5",
        "created_at": "2011-04-14T16:00:49Z"
    }
    ],
    "history": [
    {
        "url": "https://api.github.com/gists/1/57a7f021a713b1c5a6a199b54cc514735d2d462f",
        "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
        "user": {
            "login": "octocat",
            "id": 1,
            "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
            "url": "https://api.github.com/users/octocat"
        },
        "change_status": {
            "deletions": 0,
            "additions": 180,
            "total": 180
        },
        "committed_at": "2010-04-14T02:15:15Z"
    }
    ]
}

πŸ—‘οΈ delete

bye bye gist, we hardly knew ye 😭

DELETE /gists/:id

Parameters:

  • gist_id β€” mandatory integer

Examples:

my $g = Pithub::Gists->new;
my $result = $g->delete( gist_id => 784612 );
if ( $result->success ) {
    print "The gist 784612 has been deleted\n";
}

Response: Status: 204 No Content

🍴 fork

steal it (affectionately), make it your own ✨

POST /gists/:id/forks

Parameters:

  • gist_id β€” mandatory integer

Examples:

my $g = Pithub::Gists->new;
my $result = $g->fork( gist_id => 784612 );
if ( $result->success ) {
    printf "The gist 784612 has been forked: %s\n", $result->content->{html_url};
}

Response: Status: 201 Created πŸ”₯

{
    "url": "https://api.github.com/gists/1",
    "id": "1",
    "description": "description of gist",
    "public": true,
    "user": {
        "login": "octocat",
        "id": 1,
        "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
        "url": "https://api.github.com/users/octocat"
    },
    "files": {
        "ring.erl": {
            "size": 932,
            "filename": "ring.erl",
            "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
            "content": "contents of gist"
        }
    },
    "comments": 0,
    "git_pull_url": "git://gist.github.com/1.git",
    "git_push_url": "git@gist.github.com:1.git",
    "created_at": "2010-04-14T02:15:15Z"
}

πŸ” get

just one gist, singular, focused, it's giving main character πŸ’…

GET /gists/:id

Parameters:

  • gist_id β€” mandatory integer

Examples:

my $g = Pithub::Gists->new;
my $result = $g->get( gist_id => 784612 );
if ( $result->success ) {
    print $result->content->{html_url};
}

Response: Status: 200 OK ✨

{
    "url": "https://api.github.com/gists/1",
    "id": "1",
    "description": "description of gist",
    "public": true,
    "user": {
        "login": "octocat",
        "id": 1,
        "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
        "url": "https://api.github.com/users/octocat"
    },
    "files": {
        "ring.erl": {
            "size": 932,
            "filename": "ring.erl",
            "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
            "content": "contents of gist"
        }
    },
    "comments": 0,
    "git_pull_url": "git://gist.github.com/1.git",
    "git_push_url": "git@gist.github.com:1.git",
    "created_at": "2010-04-14T02:15:15Z",
    "forks": [
    {
        "user": {
            "login": "octocat",
            "id": 1,
            "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
            "url": "https://api.github.com/users/octocat"
        },
        "url": "https://api.github.com/gists/5",
        "created_at": "2011-04-14T16:00:49Z"
    }
    ],
    "history": [
    {
        "url": "https://api.github.com/gists/1/57a7f021a713b1c5a6a199b54cc514735d2d462f",
        "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
        "user": {
            "login": "octocat",
            "id": 1,
            "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
            "url": "https://api.github.com/users/octocat"
        },
        "change_status": {
            "deletions": 0,
            "additions": 180,
            "total": 180
        },
        "committed_at": "2010-04-14T02:15:15Z"
    }
    ]
}

⭐ is_starred

the vibe check: has this gist been starred or not πŸ‘‘

GET /gists/:id/star

Parameters:

  • gist_id β€” mandatory integer

Examples:

my $g = Pithub::Gists->new;
my $result = $g->is_starred( gist_id => 784612 );

Response: Status: 204 No Content / "Status: 404 Not Found" πŸ’€

πŸ“‹ list

so this one's got RANGE, bestie, she does multiple things depending on what you ask for 🌈

  • List a user's gists:
GET /users/:user/gists

Parameters:

  • user β€” string

Examples:

my $g = Pithub::Gists->new;
my $result = $g->list( user => 'miyagawa' );
if ( $result->success ) {
    while ( my $row = $result->next ) {
        printf "%s => %s\n", $row->{html_url}, $row->{description} || 'no description';
    }
}
  • List the authenticated user's gists β€” or if called anonymously, this will returns all public gists:
GET /gists

Examples:

my $g = Pithub::Gists->new;
my $result = $g->list;
  • List all public gists:
GET /gists/public

Parameters:

  • public β€” boolean

Examples:

my $g = Pithub::Gists->new;
my $result = $g->list( public => 1 );
  • List the authenticated user's starred gists:
GET /gists/starred

Parameters:

  • starred β€” boolean

Examples:

my $g = Pithub::Gists->new;
my $result = $g->list( starred => 1 );

Response: Status: 200 OK ✨

[
    {
        "url": "https://api.github.com/gists/1",
        "id": "1",
        "description": "description of gist",
        "public": true,
        "user": {
            "login": "octocat",
            "id": 1,
            "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
            "url": "https://api.github.com/users/octocat"
        },
        "files": {
            "ring.erl": {
                "size": 932,
                "filename": "ring.erl",
                "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
                "content": "contents of gist"
            }
        },
        "comments": 0,
        "git_pull_url": "git://gist.github.com/1.git",
        "git_push_url": "git@gist.github.com:1.git",
        "created_at": "2010-04-14T02:15:15Z"
    }
]

🌟 star

giving it the star it deserves, iconic behavior πŸ‘‘

PUT /gists/:id/star

Parameters:

  • gist_id β€” mandatory integer

Examples:

my $g = Pithub::Gists->new;
my $result = $g->star( gist_id => 784612 );

Response: Status: 204 No Content

πŸ’” unstar

actually, no, taking that star back, we're unstanning 😭

DELETE /gists/:id/star

Parameters:

  • gist_id β€” mandatory integer

Examples:

And the response for unstar? She's serving pure confirmation:

Response: Status: 204 No Content


update πŸ’– (the edit-a-gist method)

Okay bestie, this one edits a gist. The endpoint is:

PATCH /gists/:id

Parameters:

  • gist_id β€” mandatory integer, the gist's ID, no cap.
  • data β€” mandatory hashref, and it's gotta have these keys inside:
    • description β€” optional string, the lil description.
    • public β€” mandatory boolean, is it public or not?
    • files β€” mandatory hashref, please see the examples section below for the tea.
NOTE: All files from the previous version of the gist are carried over by default if not included in the hash. Deletes can be performed by including the filename with a null hash.

Examples:

my $g      = Pithub::Gists->new;
my $result = $g->update(
    gist_id => 784612,
    data    => {
        description => 'the description for this gist',
        files       => {
            'file1.txt'    => { content => 'updated file contents' },
            'old_name.txt' => {
                filename => 'new_name.txt',
                content  => 'modified contents'
            },
            'new_file.txt'         => { content => 'a new file' },
            'delete_this_file.txt' => undef
        }
    }
);

Response: Status: 200 OK

{
    "url": "https://api.github.com/gists/1",
    "id": "1",
    "description": "description of gist",
    "public": true,
    "user": {
        "login": "octocat",
        "id": 1,
        "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
        "url": "https://api.github.com/users/octocat"
    },
    "files": {
        "ring.erl": {
            "size": 932,
            "filename": "ring.erl",
            "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
            "content": "contents of gist"
        }
    },
    "comments": 0,
    "git_pull_url": "git://gist.github.com/1.git",
    "git_push_url": "git@gist.github.com:1.git",
    "created_at": "2010-04-14T02:15:15Z",
    "forks": [
    {
        "user": {
            "login": "octocat",
            "id": 1,
            "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
            "url": "https://api.github.com/users/octocat"
        },
        "url": "https://api.github.com/gists/5",
        "created_at": "2011-04-14T16:00:49Z"
    }
    ],
    "history": [
    {
        "url": "https://api.github.com/gists/1/57a7f021a713b1c5a6a199b54cc514735d2d462f",
        "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
        "user": {
            "login": "octocat",
            "id": 1,
            "gravatar_url": "https://github.com/images/error/octocat_happy.gif",
            "url": "https://api.github.com/users/octocat"
        },
        "change_status": {
            "deletions": 0,
            "additions": 180,
            "total": 180
        },
        "committed_at": "2010-04-14T02:15:15Z"
    }
    ]
}

✨ AUTHOR ✨

This masterpiece was authored by Johannes Plunien <plu@cpan.org> β€” absolute icon behavior, we stan. πŸ’–


Okay so legal tea, no cap:

This software is copyright (c) 2011 by Johannes Plunien.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

And that's the whole vibe, bestie. This page is serving perl v5.40.1, dated 2025-06-08, and it's Pithub::Gists(3pm) β€” periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from