etcd

How to get a list of all keys using the restful api?


In ETCD, how can I get a list of all keys using the restful api /v3/kv? I can get a range of keys using this endpoint [POST] /v3/range but the end of the range is not known so I am looking for an API that can list all keys.


Solution

  • you can retrieve all keys (and values) using the value 0x00 (AA== in base64) for both key and range_end in the request body

    example: curl --request POST --header 'content-type: application/json' --data '{"key":"AA==","range_end":"AA=="}' http://[::1]:2379/v3/kv/range

    source

    enjoy!