Get file content from github repo on specified line number(s)

Viewed 165

Question

I am wondering if there is a way to get the content of a file on a github repo with specified line number(s) through GitHub APIs. I know that it is possible to generate a permanent link to a code snippet from the github UI as follows

https://github.com/<org_name>/<repo_name>/blob/master/<path_to_file>#L{Start}-L{End}

Screenshot

However I cant seem to find a way to get the content of a file on a specific line number(s) through their Github APIs. I tried the Search API but couldnt find anything useful. Any help on that is greatly appreciated!

Use Case

I am creating a tutorials application and I would like to query lines of code to generate dynamic code snippets from a file hosted on github.

0 Answers
Related