Bootstrap FreeKB - Kong Community Edition (KongCE) - get Plugins using REST API
Kong Community Edition (KongCE) - get Plugins using REST API


The curl GET command can be used to list the plugins associated with a certain service or route.


On the Kong server

If Kong is running on docker, refer to Kong - Docker container command line for the steps on how to issue commands in the Kong Docker container. Assuming you are using the default kong.conf file, the Kong Admin API will listen on port 8001.

If issuing this command on the Kong server, this command will display the Plugin JSON.

curl -X GET "http://localhost:8001/plugins"

 

This will display the plugin that has id 37d2dc5b-cd51-40cd-b312-317e4a3269e7.

curl -X GET "http://localhost:8001/plugins/37d2dc5b-cd51-40cd-b312-317e4a3269e7"

 

This command will display the json of every plugin with a specific service.

curl -X GET "http://localhost:8001/services/service_name_or_id/plugins"

 

This command will display the json of every plugin with a specific route.

curl -X GET "http://localhost:8001/routes/route_name_or_id/plugins"

 

This command will display the json of every plugin with a specific consumer.

curl -X GET "http://localhost:8001/consumers/consumer_name_or_id/plugins"

 


From a remote server

If issuing this command from a remote server, this command will display the Plugin JSON.

curl -X GET "http://hostname:8000/admin-api/plugins"

 

This command will display the plugin has id 37d2dc5b-cd51-40cd-b312-317e4a3269e7.

curl -X GET "http://hostname:8000/admin-api/plugins/37d2dc5b-cd51-40cd-b312-317e4a3269e7"

 

This command will display the json of every plugin with a specific service.

curl -X GET "http://hostname:8000/admin-api/services/service_name_or_id/plugins"

 

This command will display the json of every plugin with a specific route.

curl -X GET "http://hostname:8000/admin-api/routes/route_name_or_id/plugins"

 

This command will display the json of every plugin with a specific consumer.

curl -X GET "http://hostname:8000/admin-api/consumers/consumer_name_or_id/plugins"

 


Validation

If there are no plugins, something like this will be displayed.

{"next":null,"data":[]}

 

If there are plugins, something like this will be displayed.

{
 "created_at":1584418734,
 "config":{
            "key_names":[
                         "apikey"
                        ],
            "run_on_preflight":true,
            "anonymous":null,
            "hide_credentials":false,
            "key_in_body":false
          },
 "id":"75212b3c-2bdc-48b8-b39e-d94b46501a81",
 "service":{
             "id":"fbb57bfd-124b-451c-841c-dbfea2b9ee8b"
           },
 "enabled":true,
 "protocols":[
               "grpc",
               "grpcs",
               "http",
               "https"
             ],
 "name":"key-auth",
 "consumer":null,
 "route":null,
 "tags":null
}

 

 


100 results

Only the first 100 Plugins will be returned, starting with the Plugin that has the lowest numeric ID, and then ascending. The output will include offset, like this.

"offset":"WyI2MTQ4ZDU5MC0zNzdhLTQ5MWItYjMxYS1lMTYwYzYwNDgwYTYiXQ"

 

In this example, you would use the offset to return the next 100 records.

curl -X GET "http://hostname:8000/admin-api/plugins?offset=WyI2MTQ4ZDU5MC0zNzdhLTQ5MWItYjMxYS1lMTYwYzYwNDgwYTYiXQ"

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter dd9758 in the box below so that we can be sure you are a human.