# etcd

> etcd client for node

Latest version **0.0.3** (published 2013-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install etcd
pnpm add etcd
yarn add etcd
bun add etcd
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2013-10-16 |
| First published | 2013-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| Author | Garrett Johnson |
| Maintainers | gjohnson, tjholowaychuk |
| Keywords | etcd, coreos, raft |

## Links

- npm: https://www.npmjs.com/package/etcd
- Repository: git@github.com:gjohnson/node-etcd
- Issues: https://github.com/gjohnson/node-etcd/issues
- npm.io page: https://npm.io/package/etcd

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ~0.7.2
- [superagent](https://npm.io/package/superagent.md) ~0.15.5

## Recent versions

- 0.0.3 (latest) — 2013-10-16
- 0.0.2 — 2013-10-16
- 0.0.1 — 2013-10-16
- 0.0.0 — 2013-10-12

## README

# etcd-node

An alternative client library for interacting with etcd from node.js (without coffeescrpt). If you don't mind having coffeescript dependencies, [there is already is a module for that](https://github.com/stianeikeland/node-etcd).

## Notice

This is not stable at all! I am writing this module as I learn more about [etcd](http://coreos.com/docs/guides/etcd/), feel free to [help](https://github.com/gjohnson/etcd-node/issues)!

## Install

```sh
$ npm install etcd
```

## Configuring.

I made the client a singleton for the time being (up for suggestions). If you need to set `host` or `port`, use the `configure` method.

```js
var etcd = require('etcd');

etcd.configure({
  host: '127.0.0.1',
  port: 40001
});
```

*NOTE: I still need to add SSL support.*

## Commands

I am still implementing commands, but here is what we have so far:

### .set(string, mixed, [options], [callback])

```js
etcd.set('hello', 'world', function (err) {
  if (err) throw err;
});
```

Set with a TTL:

```js
etcd.set('hello', 'world', { ttl: 5 }, function (err) {
  if (err) throw err;
});
```

Set using a "setAndTest":

```js
etcd.set('hello', 'world', { prev: 'world' }, function (err) {
  if (err) throw err;
});
```

### .get(string, [callback])

```js
etcd.get('hello', function (err, result) {
  if (err) throw err;
  assert(result.value);
});
```

### .del(string, [callback])

```js
etcd.del('hello', function (err) {
  if (err) throw err;
});
```

### .list(string, [callback])

```js
etcd.list('prefix', function (err, items) {
  if (err) throw err;
});
```

### .watch(string, [callback])

```js
etcd.watch('prefix', function (err) {
  if (err) throw err;
});
```

### .machines(callback)

```js
etcd.machines(function (err, list) {
  if (err) throw err;
});
```

### .leader(callback)

```js
etcd.leader(function (err, host) {
  if (err) throw err;
});
```

## TODO

  - encoding (json|string)

## License

MIT

---
_Source: https://npm.io/package/etcd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
