Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

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
1 15 2,276
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

15 REPLIES 15

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?

 

Would be nice with a fix for this

api-jerry,

Can you elaborate on your statement?  What would a fix entail?

As far as I know there is no defect in how OPDK handles these queries. If there is some sort of problem, I'd say you need to contact Apigee support, with a clear set of instructions that will reproduce the broken behavior. With that they will log a bug for you, and get the engineering team to prioritize it. 

But Have you tried the script I recommended in my other reply? 

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

It should work with OPDK.  It will help you find the basepaths as specified in the API Proxy Endpoints, AND,  If you use the --verbose flag, the script will show what REST commands it is invoking!  The verbs and the URL paths - for this script all the verbs will be GET.  So you could invoke those same commands on your own.  

 

Hi Joshua,

     Can you tell me where we can use above script? 

    we are trying to fetch basepath of all the proxies in an organization,  Is there any other way we can fetch it?

You can find proxy basepaths using this script: 

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

It takes a good long while to run. 

You may want to list only basepaths for the latest revision of each proxy, or only for proxies with a name that matches a particular pattern.  The tool supports options for those purposes.

node ./listProxyBasepaths.js --help
Usage:
  node listProxyBasepaths.js [OPTION]

Options:
  -M, --mgmtserver=ARG   the base path, including optional port, of the Apigee mgmt server. Defaults to https://api.enterprise.apigee.com .
  -u, --username=ARG     org user with permissions to read Apigee configuration.
  -p, --password=ARG     password for the org user.
  -n, --netrc            retrieve the username + password from the .netrc file. In lieu of -u/-p
  -o, --org=ARG          the Apigee organization.
  -Z, --ssoZone=ARG      specify the SSO zone to use when authenticating.
      --ssoUrl=ARG       specify the SSO url to use when authenticating.
  -C, --passcode=ARG     specify the passcode to use when authenticating.
  -J, --keyfile=ARG      the keyfile for a service account, for use with apigee.googleapis.com.
      --token=ARG        use this explicitly-provided oauth token.
      --apigeex          use apigee.googleapis.com for the mgmtserver.
  -T, --notoken          do not try to obtain an oauth token.
  -N, --forcenew         force obtain a new oauth token.
  -v, --verbose
  -h, --help
      --env=ARG          Optional. an environment. Look only in proxies that are deployed to this environment.
      --proxypattern=ARG Optional. a regular expression. Look only in proxies that match this regexp.
      --latestrevision   Optional. only look in the latest revision number for each proxy.

 

An example for Apigee X is

  node ./listProxyBasepaths.js --token $TOKEN --apigeex -o $ORG  --latestrevision

Can you please help how to fetch via postman as I dont have access to server access. Is i can fetch the list of basepath using management api call. Can you please help me with an example.

For Apigee X there is no "single call" to accomplish this task.  The script described above automates the task by sending a sequence of calls.  It does this:

  • gets the list of all API proxies
  • for each API proxy, get the latest revision
  • query that revision, extract the basepath  
  • aggregate the results

The first call is 

 GET https://apigee.googleapis.com/v1/organizations/YOUR_ORG/apis

then for each API in that list, you need to

 GET https://apigee.googleapis.com/v1/organizations/YOUR_ORG/apis/SELECTED_API

...to find the revisions.  Then select the latest revision for each API and 

 GET https://apigee.googleapis.com/v1/organizations/YOUR_ORG/apis/SELECTED_API/revisions/REV

and in the result of that you will have a JSON payload, which gives the basepaths for that proxy revision. 

{
 "basepaths":  [
  "/basepath-for-proxyendpoint"
 ],
 "configurationVersion":  {
  "majorVersion":  4
 },
 ...

And then you would need to aggregate all those results.

I suppose you might be able to write some sort of sequence in Postman that replicates this behavior, but I am not a postman expert, so I can't guide you on that.  

good luck.