How to create a GitHub repository using REST API?

Step 1: Create a personal access token on GitHub

Step 2: Create a GitHub repository using REST API.

Step 3: Get GitHub repository details using REST API.

GitHub create repository REST API arguments:

  • name(string)(required): The name of the repository.
  • org(string)(required for organization repo): The organization name. The name is not case sensitive.
  • description(string): A short description of the repository.
  • homepage(string): A URL with more information about the repository.
  • private(boolean): Whether the repository is private. Default: true
  • visibility(string): Can be public or private for individual and public, private, and internal for organization. Default: private.
  • has_issues(boolean): Either true to enable issues for this repository or false to disable them. Default: true.
  • has_projects(boolean): Either true to enable projects for this repository or false to disable them. Default: true.
  • has_wiki(boolean): Either true to enable the wiki for this repository or false to disable it. Default: true.
  • is_template(boolean): Either true to make this repo available as a template repository or false to prevent it. Default: false.
  • auto_init(boolean): Pass true to create an initial commit with empty README. Default: false.
  • gitignore_template(string): Desired language or platform .gitignore template to apply.
  • allow_squash_merge(boolean): Either true to allow squash-merging pull requests, or false to prevent squash-merging. Default: true.
  • allow_merge_commit(boolean): Either true to allow merging pull requests with a merge commit, or false to prevent merging pull requests with merge commits. Default: true
  • allow_rebase_merge(boolean): Either true to allow rebase-merging pull requests, or false to prevent rebase-merging. Default: true
  • allow_auto_merge(boolean): Either true to allow auto-merge on pull requests, or false to disallow auto-merge. Default: false.
  • delete_branch_on_merge(boolean): Either true to allow automatically deleting head branches when pull requests are merged, or false to prevent automatic deletion. Default: false.

To get additional details, please refer to the below documentation.