Tool

Get file contents

The GitHub Get File Contents tool allows users to retrieve the contents of files or directories directly from any GitHub repository. It supports specifying branches, tags, pull requests, or specific commits to access the exact version of the file or directory you need.

GitHub

Features

  • Fetch file or directory contents from any public GitHub repository.
  • Specify the repository owner and repository name to target the desired project.
  • Use optional parameters to specify git references such as branches, tags, pull requests, or commit SHAs.
  • Supports retrieving entire directories by specifying paths ending with a slash '/'
  • Read-only access ensuring safe extraction of content without modifying the source repository.

Benefits

  • Easily access and review code or documentation without cloning the repository.
  • Improve development workflow by programmatically retrieving files on demand.
  • Supports integration with automation tools that require GitHub file data.
  • Facilitates code audits, reviews, and content analysis directly from GitHub.
  • Saves time and resources by avoiding unnecessary repository cloning.

Description

Get the contents of a file or directory from a GitHub repository

Parameters

5 parameters

NameTypeDescription
ownerrequiredstring

Repository owner (username or organization)

pathstring

Path to file/directory (directories must end with a slash '/')

refstring

Accepts optional git refs such as refs/tags/{tag}, refs/heads/{branch} or refs/pull/{pr_number}/head

reporequiredstring

Repository name

shastring

Accepts optional commit SHA. If specified, it will be used instead of ref

Try Needle today

Streamline AI productivity at your company today

Join thousands of people who have transformed their workflows.

Agentic workflowsAutomations, meet AI agents
AI SearchAll your data, searchable
Chat widgetsDrop-in widget for your website
Developer APIMake your app talk to Needle
    Needle LogoNeedle
    Like many websites, we use cookies to enhance your experience, analyze site traffic and deliver personalized content while you are here. By clicking "Accept", you are giving us your consent to use cookies in this way. Read our more on our cookie policy .