# memex-js-sdk

> Memex SDK

Latest version **1.1.25** (published 2018-01-06) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install memex-js-sdk
pnpm add memex-js-sdk
yarn add memex-js-sdk
bun add memex-js-sdk
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.25 |
| Published | 2018-01-06 |
| First published | 2017-05-18 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 21 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Adam Zdara |
| Maintainers | zdaraa |
| Keywords | memex |

## Links

- npm: https://www.npmjs.com/package/memex-js-sdk
- Repository: https://github.com/memexapp/memex-js-sdk
- Homepage: https://github.com/memexapp/memex-js-sdk#readme
- Issues: https://github.com/memexapp/memex-js-sdk/issues
- npm.io page: https://npm.io/package/memex-js-sdk

## Dependencies (21)

- [chai](https://npm.io/package/chai.md) 3.4.1
- [utf8](https://npm.io/package/utf8.md) ^2.1.2
- [babel](https://npm.io/package/babel.md) ^6.3.13
- [mocha](https://npm.io/package/mocha.md) 2.3.4
- [react](https://npm.io/package/react.md) ^15.6.1
- [escope](https://npm.io/package/escope.md) ^3.3.0
- [eslint](https://npm.io/package/eslint.md) 1.7.2
- [base-64](https://npm.io/package/base-64.md) ^0.1.0
- [webpack](https://npm.io/package/webpack.md) 1.12.9
- [babel-core](https://npm.io/package/babel-core.md) 6.1.18
- [babel-eslint](https://npm.io/package/babel-eslint.md) 4.1.3
- [babel-loader](https://npm.io/package/babel-loader.md) 6.1.0
- [whatwg-fetch](https://npm.io/package/whatwg-fetch.md) ^2.0.3
- [eslint-loader](https://npm.io/package/eslint-loader.md) 1.1.0
- [babel-preset-react](https://npm.io/package/babel-preset-react.md) ^6.24.1
- [babel-preset-es2015](https://npm.io/package/babel-preset-es2015.md) 6.3.13
- [eslint-plugin-babel](https://npm.io/package/eslint-plugin-babel.md) ^4.1.1
- [eslint-plugin-react](https://npm.io/package/eslint-plugin-react.md) ^7.1.0
- [babel-preset-stage-0](https://npm.io/package/babel-preset-stage-0.md) ^6.24.1
- [eslint-plugin-flowtype](https://npm.io/package/eslint-plugin-flowtype.md) ^2.34.0
- [babel-plugin-add-module-exports](https://npm.io/package/babel-plugin-add-module-exports.md) 0.1.2

## Recent versions

- 1.1.25 (latest) — 2018-01-06
- 1.1.24 — 2017-12-28
- 1.1.23 — 2017-12-28
- 1.1.22 — 2017-12-28
- 1.1.21 — 2017-12-28
- 1.1.20 — 2017-12-28
- 1.1.19 — 2017-10-11
- 1.1.18 — 2017-10-11
- 1.1.17 — 2017-10-07
- 1.1.16 — 2017-06-30
- 1.1.15 — 2017-06-28
- 1.1.14 — 2017-06-04
- 1.1.13 — 2017-05-31
- 1.1.12 — 2017-05-29
- 1.1.11 — 2017-05-29
- … 11 more at https://npm.io/package/memex-js-sdk/versions

## README

# Memex JavaScript SDK


## What is Memex?

Memex is lightweight personal knowladge base with automatic content management. It means that it helps organise every piece of knowledge (notes, urls, sketches, comments, etc.). These pieces (spaces) are interconnected using memory links which helps to navigate and associate it into more compact knowledge. It is just like web but more lightweight and only personal.

### Space
Core concept of Memex is space which is bundle/collection/folder of small pieces of knowledge. It can be piece of text (text space) note or large collection of links to other collections (collection space).

There is a few standard space types in two core categories:

1. Collection-oriented - defined/represented by its caption
	* Collection - abstract set of links to other spaces
2. Atomic (shortly atoms) - defined/represented by caption and linked media
	* WebPage - decorated URL to any webpage
	* Text - small textual piece of information/note or anything that can be written
	* Image - visual piece of knowledge

Space has wollowing structure:

```javascript
class Space {
  MUID: ?string;
  spaceType: SpaceType;
  caption: ?string;
  representations: ?Array<Media>;
  color: ?string;
  state: EntityState;
}
```

### Link

Another core principle of memex is link which is nothing more than connection between two spaces. So if there exists association between two things/ideas/spaces in users brain there should be also oriented link in memex.

```javascript
class Link {
  MUID: ?string;
  origin: Space;
  target: Space;
  state: EntityState;
}
```

### Media

Piece of data that can be users avatar or image/textual representation of space.

```javascript
class Media {
  MUID: ?string;
  state: EntityState;
  mediaType: MediaType;
  embedData: ?ArrayBuffer;
  dataDownloadURL: ?string;
  dataUploadURL: ?string;
  dataState: MediaDataState;
  representsSpace: ?Space;
}
```

## Smart Fetaures

Today memex supports two smart features that will help user to automatically manage his content.

#### Auto-Categorization (Autodump)

First one is called autodump and will automatically link new space with most fitting already existing space. Eg. If user drops webpage url and there already exists similar collection of spaces then Memex will try to automatically create link from this collection to newly created space. See Examples section.

#### Auto-Captioning

Are you creating collection of spaces but dont know how to name it?Another smart feature that is offered by Memex is automatic captioning/summarization of space. Just provide set of space MUIDs and we will tell you what is the best name for it.


## Setup
### 1. Create app and get your app token

Go to [Memex Dev Center](https://memex.co/apps/dev) and create your app. You dont need to wait for approval and continue to step 2.  


### 2. Add memex-js-sdk module to your NPM package.json

Go to root directory of your app and run this command in Terminal.

```
npm install memex-js-sdk --save
```

### 3. Import module

Import memex sdk into every JavaScript file where you want to use it.

```javascript
import Memex from 'memex-js-sdk';
```

### 4. Configure SDK with app token

In your app.js or any place where you bootstrap your libraries place this line.

```javascript
Memex.sharedClient.setAppToken('<YOUR APP TOKEN>');
```

## Examples

### Authentication

Only supported user authentication method in JS sdk is using clients credentials (email & password).

```javascript
import Memex from 'memex-js-sdk';

// ...

Memex.sharedClient.login(email, password, (token: ?string, success: bool) => {
  if (success === false) {
	 // failure
    return;
  }
  // success
});
```

### Get origin/space

If you want get users origin space or any other space use its MUID (memex unique identifier).

```javascript
Memex.sharedClient.getSpace(this.props.originMuid, (space: ?Memex.Space, success: bool) => {
  if (success === false || space == null) {
  	 // something wrong happened
    return;
  }
  // start using space object
});
```

### Get links

```javascript
Memex.sharedClient.getSpaceLinks(muid, (links: ?Array<Memex.Link>, success: bool) => {
  if (success === false) {
    // failure
  	return;
  }
  // success, show links to user
});
```


### Create space

If you want to create new space in users memex you can use one of following three options for webpage space, textual space or image space.

```javascript
Memex.sharedClient.createWebPageSpace(url, true, completion);
```

```javascript
Memex.sharedClient.createTextSpace(text, true, completion);
```

```javascript
Memex.sharedClient.createImageSpace(imageURL, true, completion);
```

Or you can create any other space.

```javascript
let space = new Space();
space.caption = ...
space.representations = ...
Memex.sharedClient.createSpace(space, false, completion);
```

## Documentation

Each function of SDK is documented using JSDoc. See generated [documentation](http://memex.co/apps/dev/doc/js).

## Other Platform APIs

* [REST API](https://github.com/memexapp/memex-rest-api-doc)  
* [Swift SDK](https://github.com/memexapp/memex-swift-sdk)  
* [Go SDK](https://github.com/memexapp/memex-go-sdk)  

## Contact Us

If you need any other help please contact us at [hello@memex.co](mailto:hello@memex.co)

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