List basepaths of all API Proxies in the Organization

Hi, is there a way to get all the API Proxy Names and its basepaths?. Its just that our organization has about 300+ and more API proxies, its quite hard to navigate and locate API proxies when investigating issues or developing apis as we only know the APIs by its basepath/path. How do I query all the most api proxies basepaths in the organization?. TIA

 

 

Solved Solved
0 9 1,368
3 ACCEPTED SOLUTIONS

Thanks, I was able to trigger the script now and query all API Proxies basepaths in the organization.

I'm currently querying it with this,

node listProxyBasepaths.js -o <ORG NAME> -u <EMAIL> -p <PASSWORD> --proxypattern ^\S+ --latestrevision



Though, would it also be possible to filter it per environment?, Its just  that an API proxy could have different basepaths depending on the revision and deployment environment it was deployed on.  And that there could also be API proxies that could have a latest revision but not deployed in any environment at all as could be the case for many of our 300+ APIs. Would that be a possible filter or it it there already?. its just that I could not see it as an option in the help menu.

But for now, this would be helpful alright to at least make it easy for us to find APIs using its basepaths assuming they are also the same basepaths for the latest revision used on different env.. Thanks.

 

View solution in original post

ok I've updated that script to search only proxies that are deployed to a specific environment. Pull the latest to get that update.

 

NB: this isn't a supported script. I offer it only to show an example of using the Google API for Apigee to retrieve proxies and basepaths. You can do whatever you like with the documented API !

View solution in original post

Thanks, I was finally able to query the all APIs deployed in a specific environment with the command below. Thanks.

 

node listProxyBasepaths.js -o <ORG NAME> -u <USERNAME OR EMAIL> -p <PASSWORD> --proxypattern ^\S+ --env=<ENVIRONMENT NAME>

 



BTW, yes, I know about the Edge APIs, though I don't have quite the time to mint my own script to remap the existing APIs to the specific use case like this that I am looking for. Hence I was really looking for this specific feature on the Edge API or some custom script as navigating our organization to develop and even debug APIs is a hassle especially when you can only search for the API proxy name and not the basepath/path of the API you're looking for which is the common way an API is being investigated for bugs whenever one occurs.


@dchiesa1 wrote:

ok I've updated that script to search only proxies that are deployed to a specific environment. Pull the latest to get that update.

 

NB: this isn't a supported script. I offer it only to show an example of using the Google API for Apigee to retrieve proxies and basepaths. You can do whatever you like with the documented API !


 

 

 

View solution in original post

9 REPLIES 9

You will have to write custom code to do it:

If you want to get all the API's and their paths irrespective of deployment status you can follow below steps:

1. Make a get call to fetch list of all API's : https://apidocs.apigee.com/docs/api-proxies/1/routes/organizations/%7Borg_name%7D/apis/get

2. For each API from the above response get the revisions details: https://apidocs.apigee.com/docs/api-proxies/1/routes/organizations/%7Borg_name%7D/apis/%7Bapi_name%7...

3: Get the basepaths for the revision you want https://apidocs.apigee.com/docs/api-proxies/1/routes/organizations/%7Borg_name%7D/apis/%7Bapi_name%7...

 

If you just want to get the list of API's and path that are deployed in any environment you can use: https://apidocs.apigee.com/docs/deployments/1/routes/organizations/%7Borg_name%7D/deployments/get and parse the response.

 

the way to list the basepaths for all proxies is to use the Apigee API (See answer from maloosatyam).   Build a script that queries all proxies and interrogates the (latest?) deployed  revision  for the basepath.

There is an outstanding feature request to expose this via the Admin UI. But I can't guarantee that the team will deliver this feature, and if they will deliver it, when.


Keep in mind in the general case, each proxy bundle can have multiple proxy endpoints, and there is a distinct basepath for each endpoint. So it's not "show me the basepath for each proxy bundle" but "show me the basepathS for each proxy bundle".  

Here is an example script that lists the basepaths for the endpoints in the various API proxies in an organization.

https://github.com/DinoChiesa/apigee-edge-js-examples/blob/main/listProxyBasepaths.js 

There are some options to tune the behavior of the search. For example, i can use the script to inquire all proxies with a name that starts with "test" this way: 

 

node ./listProxyBasepaths.js -n  -o $MYORG -J $SAKEY --proxypattern ^test.\* 

 

And the output of that is: 

 

[
  {
    "proxyname": "test-GetOAuthV2Info",
    "found": [
      {
        "revision": "1",
        "endpoint": [
          {
            "name": "default",
            "basePath": "/test-getoauthv2info",
            "adminPath": "apis/test-GetOAuthV2Info/revisions/1/endpoints/default"
          }
        ]
      },
      {
        "revision": "2",
        "endpoint": [
          {
            "name": "default",
            "basePath": "/test-getoauthv2info",
            "adminPath": "apis/test-GetOAuthV2Info/revisions/2/endpoints/default"
          }
        ]
      }
    ]
  },
  {
    "proxyname": "test-every",
    "found": [
      {
        "revision": "1",
        "endpoint": [
          {
            "name": "endpoint1",
            "basePath": "/test-every",
            "adminPath": "apis/test-every/revisions/1/endpoints/endpoint1"
          }
        ]
      },
      {
        "revision": "2",
        "endpoint": [
          {
            "name": "endpoint1",
            "basePath": "/test-every",
            "adminPath": "apis/test-every/revisions/2/endpoints/endpoint1"
          }
        ]
      }
    ]
  },
  {
    "proxyname": "test-soap-xml-e4x",
    "found": [
      {
        "revision": "1",
        "endpoint": [
          {
            "name": "endpoint1",
            "basePath": "/test-soap-xml-e4x",
            "adminPath": "apis/test-soap-xml-e4x/revisions/1/endpoints/endpoint1"
          }
        ]
      },
      {
        "revision": "2",
        "endpoint": [
          {
            "name": "endpoint1",
            "basePath": "/test-soap-xml-e4x",
            "adminPath": "apis/test-soap-xml-e4x/revisions/2/endpoints/endpoint1"
          }
        ]
      },
      {
        "revision": "3",
        "endpoint": [
          {
            "name": "endpoint1",
            "basePath": "/test-soap-xml-e4x",
            "adminPath": "apis/test-soap-xml-e4x/revisions/3/endpoints/endpoint1"
          }
        ]
      },
      {
        "revision": "4",
        "endpoint": [
          {
            "name": "endpoint1",
            "basePath": "/test-soap-xml-e4x",
            "adminPath": "apis/test-soap-xml-e4x/revisions/4/endpoints/endpoint1"
          }
        ]
      }
    ]
  }
]

 

You can also use the --latestrevision option to examine only the latest revision of a proxy bundle. 

Doesnt work for me. Does this extract the basepath for the latest deployed api proxy for the specific environment or all environments?. Its just that I need to extract the latest basepaths for each API Proxies for each environment. 

joshuacarino_0-1630493634704.png

 

 

Can you pull the latest?  The failure you noted.... can occur if there is no HTTPProxyConnection in the proxyendpoint.  That seems unusual to me.  I've never seen it. In any case I've tried to insert some more careful handling of the proxy data to consider that case.  

Can you try again? With version 20210901-1254.

Thanks, I was able to trigger the script now and query all API Proxies basepaths in the organization.

I'm currently querying it with this,

node listProxyBasepaths.js -o <ORG NAME> -u <EMAIL> -p <PASSWORD> --proxypattern ^\S+ --latestrevision



Though, would it also be possible to filter it per environment?, Its just  that an API proxy could have different basepaths depending on the revision and deployment environment it was deployed on.  And that there could also be API proxies that could have a latest revision but not deployed in any environment at all as could be the case for many of our 300+ APIs. Would that be a possible filter or it it there already?. its just that I could not see it as an option in the help menu.

But for now, this would be helpful alright to at least make it easy for us to find APIs using its basepaths assuming they are also the same basepaths for the latest revision used on different env.. Thanks.

 

ok I've updated that script to search only proxies that are deployed to a specific environment. Pull the latest to get that update.

 

NB: this isn't a supported script. I offer it only to show an example of using the Google API for Apigee to retrieve proxies and basepaths. You can do whatever you like with the documented API !

Thanks, I was finally able to query the all APIs deployed in a specific environment with the command below. Thanks.

 

node listProxyBasepaths.js -o <ORG NAME> -u <USERNAME OR EMAIL> -p <PASSWORD> --proxypattern ^\S+ --env=<ENVIRONMENT NAME>

 



BTW, yes, I know about the Edge APIs, though I don't have quite the time to mint my own script to remap the existing APIs to the specific use case like this that I am looking for. Hence I was really looking for this specific feature on the Edge API or some custom script as navigating our organization to develop and even debug APIs is a hassle especially when you can only search for the API proxy name and not the basepath/path of the API you're looking for which is the common way an API is being investigated for bugs whenever one occurs.


@dchiesa1 wrote:

ok I've updated that script to search only proxies that are deployed to a specific environment. Pull the latest to get that update.

 

NB: this isn't a supported script. I offer it only to show an example of using the Google API for Apigee to retrieve proxies and basepaths. You can do whatever you like with the documented API !


 

 

 

Yes, that makes sense to me.  I have opened a feature request to allow search and sort by basepath.  In fact I re-opened an older feature request. There's no telling whether it will be accepted this time. This is the reference: b/199329634 

 

Looking to list all basepaths also, I have found two mgmt api resources that seemed promising for this. They are however not working properly or giving you wrong information.

/organizations/{{edge.organization}}/apis/:apiname/deployments
- Gives you / as basepath for everything.

/organizations/{{edge.organization}}/apis/:api_name/revisions/:rev_number
- Gives you the basepath value from the proxy manifest, which is not necessarily the same as the actual basepath.

We are using onprem edge and the above seems to be bugged in Version 4.51.00.00 at least.

Is there some other mgmt api we could use to get this information accurately?