The gateway accepts a JSON mapping for etcd’s message definitions. Note that and value fields are defined as byte arrays and therefore must be base64 encoded in JSON. The following examples use curl, but any HTTP/JSON client should work all the same.

    gRPC gateway endpoint has changed since etcd v3.3:

    • etcd v3.2 or before uses only [CLIENT-URL]/v3alpha/*.
    • etcd v3.3 uses [CLIENT-URL]/v3beta/* while keeping [CLIENT-URL]/v3alpha/*.
    • etcd v3.5 or later uses only [CLIENT-URL]/v3/*.
      • [CLIENT-URL]/v3beta/* is deprecated.

    Use the and /v3/kv/put services to read and write keys:

    Use the /v3/watch service to watch keys:

    1. curl -N http://localhost:2379/v3/watch \
    2. -X POST -d '{"create_request": {"key":"Zm9v"} }' &
    3. # {"result":{"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"1","raft_term":"2"},"created":true}}
    4. curl -L http://localhost:2379/v3/kv/put \
    5. # {"result":{"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"2"},"events":[{"kv":{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}}]}}
    1. curl -L http://localhost:2379/v3/kv/txn \
    2. -X POST \
    3. -d '{"compare":[{"version":"4","result":"EQUAL","target":"VERSION","key":"Zm9v"}],"success":[{"requestRange":{"key":"Zm9v"}}]}'
    4. # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"6","raft_term":"3"},"succeeded":true,"responses":[{"response_range":{"header":{"revision":"6"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"6","version":"4","value":"YmF6"}],"count":"1"}}]}

    Set up authentication with the /v3/auth service:

    Authenticate with etcd for an authentication token using /v3/auth/authenticate:

    1. # get the auth token for the root user
    2. curl -L http://localhost:2379/v3/auth/authenticate \
    3. # {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"},"token":"sssvIpwfnLAcWAQH.9"}

    Swagger

    Generated Swagger API definitions can be found at .