# appdotnet

> Wrapper for the App.net HTTP Stream API, following node idioms.

Latest version **0.2.0** (published 2012-08-18) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2012-08-18 |
| First published | 2012-08-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Damien Klinnert |
| Maintainers | damienklinnert |
| Keywords | app, dot, net, appdotnet, app.net, api, stream, node, wrapper, async, http |

## Links

- npm: https://www.npmjs.com/package/appdotnet
- Repository: https://github.com/damienklinnert/appdotnet
- npm.io page: https://npm.io/package/appdotnet

## Dependencies (1)

- [request](https://npm.io/package/request.md) ~2.10.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2012-08-18
- 0.1.3 — 2012-08-16
- 0.1.2 — 2012-08-16
- 0.1.1 — 2012-08-16
- 0.1.0 — 2012-08-15
- 0.0.3 — 2012-08-15
- 0.0.2 — 2012-08-15
- 0.0.1 — 2012-08-13

## README

appdotnet v0.2.0
================

A wrapper for the app.net http stream api, following node idioms.



Current State
-------------

app.net's api is not yet stable and is incomplete. Right now, this module supports all working parts of the official api (auth, user and post).


See https://github.com/appdotnet/api-spec for the state of the official api.




Developers
----------

Please make sure to include unit tests, if you want to contribute to this project.

To run the unit tests, there are several steps to do:

  1. get an app.net access token with `scope=stream%20email%20write_post%20follow%20messages%20export`
  2. move `config.example.json` to `config.json` and insert access token  
  3. just type `npm test`

All tests run against the official app.net api, so be sure to have an internet connection. When tests are timing out, try to increase the `scripts.test -> --timeout` value in `package.json`.

**Running this tests will result in automatic post creation, operation and deletion.** If you dislike this, be sure to remove the unit tests for object.createPost() and object.deletePost(). Those tests will mute and unmute one user as well, but you remove this line as well (object.muteUser() and object.unmuteUser()).



Examples
--------

The following examples are generated from the unit testing code. Be sure to checkout the complete api description at the bottom.

There are some applications already using this library, checkout https://npmjs.org/package/appdotcouch and https://npmjs.org/package/appdotauth.




### AppDotNet

#### AppDotNet.createAuthenticationUri()
returns an uriencoded string.

```js
var params = {
  client_id: '9ah9has9hsaf9hasf9hfsa9hfsa9hsafhhasoh',
  redirect_uri: 'http://localhost:3000/cb',
  scope: 'export write_post'
};

var expectedUri = AppDotNet.authHost
                + '/oauth/authenticate'
                + '?client_id=9ah9has9hsaf9hasf9hfsa9hfsa9hsafhhasoh'
                + '&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcb'
                + '&scope=export%20write_post'
                + '&response_type=code';

AppDotNet.createAuthenticationUri(params).should.equal(expectedUri);
```


#### object.getUser()
returns a user object.

```js
client.getUser(config.user_id, function (err, user) {
  should.exist(user);
  should.not.exist(err);
  done();
});
```

#### object.followUser()
returns a user object.

```js
client.followUser(config.user_id, function (err, user) {
  should.exist(user);
  should.not.exist(err);
  done();
});
```

#### object.unfollowUser()
returns a user object.

```js
client.unfollowUser(config.user_id, function (err, user) {
  should.exist(user);
  should.not.exist(err);
  done();
});
```

#### object.listFollowing()
returns an error when not authorized.

```js
errorClient.listFollowing(config.user_id, function (err, users) {
  should.not.exist(users);
  should.exist(err);
  done();
});
```

#### object.listFollowers()
returns an error when not authorized.

```js
errorClient.listFollowers(config.user_id, function (err, users) {
  should.not.exist(users);
  should.exist(err);
  done();
});
```

### object.muteUser()
returns a user object.

```js
client.muteUser(config.user_id, function (err, user) {
  should.exist(user);
  should.not.exist(err);
  done();
});
```

### object.unmuteUser()
returns a user object.

```js
client.unmuteUser(config.user_id, function (err, user) {
  should.exist(user);
  should.not.exist(err);
  done();
});
```

### object.listMutedUsers()
returns user objects.

```js
client.listMutedUsers(config.user_id, function (err, users) {
  should.exist(users);
  should.not.exist(err);
  done();
});
```

#### object.checkToken()
returns an auth object.

```js
client.checkToken(function (err, auth) {
  should.exist(auth);
  should.not.exist(err);
  done();
});
```

#### object.createPost()
returns a post object.

```js
client.createPost(config.post_data, function (err, post) {
  // save this for later use
  savedPostId = post.id;

  should.exist(post);
  should.not.exist(err);
  done();
});
```

#### object.retrievePost()
returns a post object.

```js
client.retrievePost(savedPostId, function (err, post) {
  should.exist(post);
  should.not.exist(err);
  done();
});
```

#### object.retrievePostReplies()
returns post objects.

```js
client.retrievePostReplies(savedPostId, {}, function (err, posts) {
  should.exist(posts);
  should.not.exist(err);
  done();
});
```

#### object.deletePost()
returns a post object.

```js
client.deletePost(savedPostId, function (err, post) {
  should.exist(post);
  should.not.exist(err);
  done();
});
```

#### object.retrieveCreatedPosts()
returns post objects.

```js
client.retrieveCreatedPosts(config.user_id, {}, function (err, posts) {
  should.exist(posts);
  should.not.exist(err);
  done();
});
```

#### object.retrieveMentions()
returns post objects.

```js
client.retrieveMentions(config.user_id, {}, function (err, posts) {
  should.exist(posts);
  should.not.exist(err);
  done();
});
```

#### object.retrievePersonalStream()
returns post objects.

```js
client.retrievePersonalStream({}, function (err, posts) {
  should.exist(posts);
  should.not.exist(err);
  done();
});
```

#### object.retrieveGlobalStream()
returns post objects.

```js
client.retrieveGlobalStream({}, function (err, posts) {
  should.exist(posts);
  should.not.exist(err);
  done();
});
```

#### object.retrieveTaggedPosts()
returns post objects.

```js
client.retrieveTaggedPosts(config.tag, {}, function (err, posts) {
  should.exist(posts);
  should.not.exist(err);
  done();
});
```



API
---

### AppDotNet()

Create a new AppDotNet object with `token`.

#### Params: 

* **String** *token* valid app.net access token

#### Return:

* **Object** new object

### AppDotNet.host

Host against which all request are made.

### AppDotNet.authHost

Host against which auth request are made.

### AppDotNet.create(token)

Convenience construtor for `AppDotNet`.

#### Params: 

* **String** *token* valid app.net access token

#### Return:

* **Object** new object

### AppDotNet.createAuthenticationUri(params)

Create a valid authentication uri with `params`.

#### Params: 

* **Object** *params* for the get parameters

#### Return:

* **String** uri

### AppDotNet.requestAccessToken(params, cb)

Request an access token with `params` and callback `cb(err, auth)`.

#### Params: 

* **Object** *params* for the get parameters

* **Function** *cb* 

### object.getUser(id, cb)

Retrieve the user with the given `id` and callback `cb(err, user)`.

#### Params: 

* **String** *id* 

* **Function** *cb* 

### object.followUser(id, cb)

Follow a user with the given `id` and callback `cb(err, user)`.

#### Params: 

* **String** *id* 

* **Function** *cb* 

### object.unfollowUser(id, cb)

Unfollow a user with the given `id` and callback `cb(err, user)`.

#### Params: 

* **String** *id* 

* **Function** *cb* 

### object.listFollowing(id, cb)

List users a user is following with the given `id` and callback `cb(err, users)`.

#### Params: 

* **String** *id* 

* **Function** *cb* 

### object.listFollowers(id, cb)

List users following a user with the given `id` and callback `cb(err, users)`.

#### Params: 

* **String** *id* 

* **Function** *cb* 

### muteUser(id, cb)

Mute a user with the given `id` and callback `cb(err, user)`.

#### Params: 

* **String** *id* of the user

* **Function** *cb* 

### unmuteUser(id, cb)

Unmute a user with the given `id` and callback `cb(err, user)`.

#### Params: 

* **String** *id* of the user

* **Function** *cb* 

### listMutedUsers(cb)

List muted users and callback `cb(err, user)`.

#### Params: 

* **Function** *cb* 

### object.checkToken(cb)

Check current access token and callback `cb(err, auth)`.

#### Params: 

* **Function** *cb* 

### object.createPost(data, cb)

Create a post with `data` and callback `cb(err, post)`.

#### Params: 

* **Object** *data* for the post

* **Function** *cb* 

### object.retrievePost(id, cb)

Retrieve a post with `id` and callback `cb(err, post)`.

#### Params: 

* **String** *id* of the post

* **Function** *cb* 

### object.retrievePostReplies(id, filters, cb)

Retrieve the replies to a post with `id` using `filters` and callback `cb(err, posts)`.

#### Params: 

* **String** *id* of a post

* **Object** *filters* 

* **Function** *cb* 

### object.deletePost(id, cb)

Delete a post with `id` and callback `cb(err, post)`.

#### Params: 

* **String** *id* of the post

* **Function** *cb* 

### object.retrieveCreatedPosts(id, filters, cb)

Retrieve posts created by a user with `id` using `filters` and callback `cb(err, posts)`.

#### Params: 

* **String** *id* of a user

* **Object** *filters* 

* **Function** *cb* 

### object.retrieveMentions(id, filters, cb)

Retrieve posts mentioning a user with `id` using `filters` and callback `cb(err, posts)`.

#### Params: 

* **String** *id* of a user

* **Object** *filters* 

* **Function** *cb* 

### object.retrievePersonalStream(filters, cb)

Retrieve logged in user's personalized stream using `filters` and callback `cb(err, posts)`.

#### Params: 

* **Object** *filters* 

* **Function** *cb* 

### object.retrieveGlobalStream(filters, cb)

Retrieve the global stream using `filters` and callback `cb(err, posts)`.

#### Params: 

* **Object** *filters* 

* **Function** *cb* 

### object.retrieveTaggedPosts(tag, filters, cb)

Retrieve tagged posts with `tag` using `filters` and callback `cb(err, posts)`.

#### Params: 

* **String** *tag* 

* **Object** *filters* 

* **Function** *cb*

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