Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How get all repositories and their URL via REST API in Stash

Shuaibing Li August 16, 2015
 

3 answers

1 accepted

1 vote
Answer accepted
Felix
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 16, 2015

Stash's REST API uses a paged system and will, in general never just return all of something. This is to ensure performance of the system is maintained and REST requests can be processed very quickly.

You can check the REST documentation here for more info on how the paging works.

To retrieve all repositories on any given Stash instance, you would need to:

  1. GET all pages of projects from the Project REST Endpoint to retrieve all projects
  2. call the repos REST Endpoint and retrieve all pages of repositories for each project

The REST response for the repos contains that repository's clone URLs (for HTTP and SSH, depending on availability).

Another thing of note: the caller needs to have at least read access to all projects and repos for this to work. 

Gustavo Segura May 6, 2020

I have a small python script that will get you this info here.

Like Evan Slaughter likes this
0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 17, 2015

Stash Command Line Interface (CLI) has both getProjectList and getRepositoryList. You can also use runFromProjectList and combine that with getRepositoryList to get all repositories across all projects.

0 votes
Shuaibing Li August 16, 2015

Hi Felix Haehnel

Thanks for your prompt reply.

I am a Stash administrator. I want to get all none-fork repositories and backup them.

Can I use  'http://example.com/rest/api/1.0/repos' to implement.

Thank very much

Felix
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 16, 2015

Hi @Shuaibing Li, sorry for the confusion in my answer above. Yes, as you rightly pointed out, you can use the /rest/api/1.0/repos endpoint with no query parameters. That will save you having to query all the projects. That endpoint is also paged and, depending on the number of repos your Stash instance contains, you will still need to make multiple requests to retrieve all repos .

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 18, 2015

Why do you want to back up the not forked repos? Just because a repo is forked doesn't give you any kind of backup.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events