Use the REST API to get .gitignore templates that can be used to ignore files and directories.
When you create a new repository on GitHub via the API, you can specify a .gitignore template to apply to the repository upon creation. You can use the REST API to get .gitignore templates from the GitHub .gitignore repository.
Note
Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.
GET /gitignore/templates
List all templates available to pass as an option when creating a repository.
200 - OK
304 - Not modified
Request:
curl -L \
-X GET \
https://api.github.com/gitignore/templates
Response schema (Status: 200):
Array of string
GET /gitignore/templates/{name}
Get the content of a gitignore template.
This endpoint supports the following custom media types. For more information, see "Media types."
application/vnd.github.raw+json: Returns the raw .gitignore contents.
accept (string)application/vnd.github+json is recommended.name (string) (required)200 - OK
304 - Not modified
Request:
curl -L \
-X GET \
https://api.github.com/gitignore/templates/NAME
Response schema (Status: 200):
name: required, stringsource: required, string