paint-brush
3 ways to get data from GitHub Gistsby@m1guelpf
4,146 reads
4,146 reads

3 ways to get data from GitHub Gists

by Miguel PiedrafitaNovember 28th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<em>Originally published on </em><a href="https://miguelpiedrafita.com/github-gists/" target="_blank"><em>my blog</em></a>

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - 3 ways to get data from GitHub Gists
Miguel Piedrafita HackerNoon profile picture

Originally published on my blog

GitHub Gist Logo (https://github.com/logos)

While working on my side-projects (UnMarkDocs and Webslides), I had to get data from GitHub Gists. Here are the three ways to do it:

1. The JS way

This is the official way to do it, the one that is mentioned in the GitHub Documentation. It consists on adding .js and including it in an script tag:

2. The JSON way

Adding .json to the end of the Gist URL returns something like this:

This is very useful when working with Gists server-side

3. GitHub API

Of course, you can use the GitHub API to get this content. According to the API documentation, you have to make a GET request to https://api.github.com/gists/$GIST_ID where Gist ID is the part of the URL that appears after your username.

Here’s an example response:

About the Author

👋 Hi! I’m Miguel Piedrafita, a 15-year-old PHP artisan and open-source lover. How about connecting on Twitter?

Originally published at dev.to.