FreeKB - Kong Community Edition (KongCE) get Consumers using curl
Kong Community Edition (KongCE) - get Consumers using curl

The curl GET command can be used to list Consumers.


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 Consumer JSON.

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

 

This command will display a specific Consumer.

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

 


From a remote server

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

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

 

This command will display a specific Consumer.

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

 


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

{
 "message":"Not Found"
}

 

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

{
 "custom_id":null
 "created_at":1583244607
 "id":"a51b05c4-fc81-4552-88a0-17842065e8b2"
 "tags":null
 "username":"john.doe"
}

 


100 results

Only the first 100 Consumers will be returned, starting with the Consumer 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/consumers?offset=WyI2MTQ4ZDU5MC0zNzdhLTQ5MWItYjMxYS1lMTYwYzYwNDgwYTYiXQ"

 

When there are no more records, offset will not be included in the output, like this.

  {  
   "custom_id":null
   "created_at":1565816518
   "id":"ffb481c2-a3d9-4b14-9a59-022ca4cda18d"
   "tags":null
   "username":"john.doe"
  }
 ]
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |