Retrieve via REST api only the projects I am allowed to access

Hi,

I try to use your REST api to retrieve all projects I am allowed to access:

But unfortunately I can retrieve thousands of projects.
These are for sure not ours.

I would like to only retrieve the projects I am having access to.

At the end I want to resolve the projectId for the projectName.

Any suggestions?

Thanks in advance

Hey Alexander,

You are seeing all the public projects, which is by design, but I agree isn’t what you are probably wanting.

There might be an undocumented way of doing it. One of my teammates is going to help out later to see if there’s a better way of doing it. We’ll let you know what we find out.

1 Like

Hi Taylor,

thanks for your explanation.

I’m seeing forward to your suggestion how to do it better!

Regads

Hi @alexander.pehm,

You can get a list of all the orgs you belong to, and then loop over those to get the projects. Authenticate the same way you would for Retrieving list of Projects in the reference above.

Example curl command for getting orgs(page and per_page seem to be required. Max per_page is 100):

curl -v 'https://next-api.stoplight.io/orgs?page=1&per_page=100' -H 'Authorization: Bearer {replace with your token}'

/orgs returns an object, that has a data property on it. data, is an array of orgs. Iterate over the orgs and get all the projects for an org. Here is an example curl request:

curl -v 'https://next-api.stoplight.io/orgs/{org.path}/projects?page=1&per_page=100' -H 'Authorization: Bearer {replace with your token}'

Again, if successful returns an object with a data property on it. It is an array of projects.

Let me know if you have any questions.

Quick note: Because these aren’t publicly documented, they can change if needed. Chances of that happening in the near future are low though.

1 Like