Bootstrap FreeKB - Kong Community Edition (KongCE) - List routes using REST API
Kong Community Edition (KongCE) - List routes using REST API


The curl GET command can be used to determine if a service exists. This assumes you have already created a service. If not, refer to Kong - create service using cURL. Let's say you've created a service named "foo-service".


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 every route.

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

 

This will display every route with foo-service.

curl -X GET "http://localhost:8001/services/foo-service/routes"

 


From a remote server

If issuing this command from a remote server, this command will display every route.

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

 

This will display every route with foo-service.

curl -X GET "http://hostname:8000/admin-api/services/foo-service/routes"

 


Validation

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

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

 

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

{
 "next":null,
 "data":[
          {
            "id":"a714d55e-a168-4efc-ae1a-6c380b0d5c84",
            "path_handling":"v0",
            "paths" => [
                         "/example/endpoint"
                       ],
            "destinations":null,
            "headers":null,
            "protocols":["http","https"],
            "methods":null,
            "snis":null,
            "service":{
                        "id":"fbb57bfd-124b-451c-841c-dbfea2b9ee8b"
                      },
            "name":null,
            "strip_path":true,
            "preserve_host":false,
            "regex_priority":0,
            "updated_at":1584417746,
            "sources":null,
            "hosts":[
                      "example.com"
                    ],
            "https_redirect_status_code":426,
            "tags":null,
            "created_at":1584417746
          }
        ]
}

 




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 153bfb in the box below so that we can be sure you are a human.