Upload a file in GitHub using GitHub APIs

Sumit Kumar Saraf
AxleWeb Technologies
2 min readJul 19, 2021



Sometimes, It is hectic to upload files manually into the GitHub repository. You can just upload the files using GitHub APIs programmatically into the various repositories like master, origin etc.

I can show you how to upload the files using GitHub API.

I’m using Node.js programing language to code the scripts.

Initial steps :

First you need to generate the access token for calling the GitHub API’s. So you can generate the token by going below link :


Then go to the ‘personal access token’ then click on ‘Generate new token’. You need to select the scopes so just select all scopes and generate the token.

Note : Make sure to copy your personal access token now. You won’t be able to see it again!

Token is something look like below one.

Token : ghp_SgpPBpxxxxxxxxxxxxxxxxxxxxxxxxxxxSqX1U

1. Upload files

For uploading the file into GitHub you can go through basic steps:

  1. Get the file content using ‘fs’ module.
  2. Encode the content into base64 format.
  3. then use GitHub API “https://api.github.com/repos/{owner}/{repo}/contents/{file name}”.
    owner = sumit-s03
    repo = Test
    file name = abc.txt
  4. Also pass the content of file (which is in encoded form) in data section under the API calling function.

The videos below will give you a good idea of how the technology works.👇

In case you’re interested in more technical videos, check out this channel .👇

Start your journey towards having a chatbot at a reasonable price. We’ll be pleased to serve you. 🙂

Here is our Website Link :- https://axlewebtech.com/



Sumit Kumar Saraf
AxleWeb Technologies

I’m a chatbot developer at Axleweb technologies base on district Rewa MP.