# kauri-api-client

Latest version **0.1.6** (published 2019-10-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install kauri-api-client
pnpm add kauri-api-client
yarn add kauri-api-client
bun add kauri-api-client
```

## 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.1.6 |
| Published | 2019-10-07 |
| First published | 2019-08-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 17 |
| Unpacked size | 161.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | gregjeanmart |

## Links

- npm: https://www.npmjs.com/package/kauri-api-client
- npm.io page: https://npm.io/package/kauri-api-client

## Dependencies (17)

- [ws](https://npm.io/package/ws.md) ^5.1.1
- [bs58](https://npm.io/package/bs58.md) ^4.0.1
- [web3](https://npm.io/package/web3.md) 0.20.6
- [keccak](https://npm.io/package/keccak.md) ^1.4.0
- [connect](https://npm.io/package/connect.md) ^3.6.5
- [secp256k1](https://npm.io/package/secp256k1.md) ^3.5.0
- [kafka-node](https://npm.io/package/kafka-node.md) ^4.0.1
- [superagent](https://npm.io/package/superagent.md) ^4.1.0
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^6.0.0
- [serve-static](https://npm.io/package/serve-static.md) ^1.13.1
- [ethereumjs-tx](https://npm.io/package/ethereumjs-tx.md) ^1.3.4
- [ethereumjs-util](https://npm.io/package/ethereumjs-util.md) ^5.1.5
- [performance-now](https://npm.io/package/performance-now.md) ^2.1.0
- [node-rest-client](https://npm.io/package/node-rest-client.md) ^3.1.0
- [truffle-contract](https://npm.io/package/truffle-contract.md) ^3.0.1
- [ethereumjs-wallet](https://npm.io/package/ethereumjs-wallet.md) ^0.6.2
- [truffle-hdwallet-provider](https://npm.io/package/truffle-hdwallet-provider.md) 0.0.3

## Recent versions

- 0.1.6 (latest) — 2019-10-07
- 0.1.5 — 2019-10-07
- 0.1.4 — 2019-08-23
- 0.1.3 — 2019-08-23
- 0.1.2 — 2019-08-23
- 0.1.1 — 2019-08-23
- 0.1.0 — 2019-08-23

## README

# kauri-scripts


## Getting started

1. Init a npm project

```
npn init
```

2. Load the dependency

```
npm install -s kauri-api-client
```

3. Create a js file like this

```
(async () => {
    // Import kauri-client
    const KauriClient   = require('kauri-api-client');

    // Init the client (that's for dev, for production, just change api.dev.kauri.io to api.kauri.io)
    const kauriClient = await KauriClient.init({
        "MNEMONIC": "word1 word2 ... word12",
        "HOST": "api.dev2.kauri.io",
    });

    // Example 1: Get user details
    var user = await kauriClient.getUser("F0f15Cedc719B5A55470877B0710d5c7816916b1");
    console.log(user)

    // Example 2: Search latest articles
    var articles = await kauriClient.searchArticles();
    console.log(articles)

    // Example 3: Submit and Publish an article
    var article = await kauriClient.submitAndSelfPublishArticle({
            "content": "blabla",
            "title": "title",
            "attributes": {},
            "tags": ["tag1", "tag2"]
        });
    console.log(article)

    process.exit();
})();
```

4. Run the script

```
node myscript.js
```

### Documentation

```
/**
 * getUser
 * @description: Retrieve public user profile
 * @args: userId User Account Address (withtout 0x)
 */
KauriClient.prototype.getUser = async function(userId)

/**
 * saveUser
 * @description: Save (create/edit) a user profile
 * @args: userInput User Data
 *        { "name": name, "username": username, "email": email, "title": title, "website": website, "avatar": avatar, "social": {"twitter": "username"}, "subscriptions": {"newletters": true} }
 */
KauriClient.prototype.saveUser = async function(userInput)

/**
 * countVote
 * @description: Get vote result for a resource
 * @args: parent Resource Identifier
 *        { "type": "ARTICLE", "id": "123123" }
 */
KauriClient.prototype.countVote = async function(parent)

/**
 * addVote
 * @description: Record a vote
 * @args: parent
 *       {"parent": { "type": "ARTICLE", "id": "123123" } }
 */
KauriClient.prototype.addVote = async function(voteInput)

/**
 * getComments
 * @description: Get Comments for a resource
 * @args: parent Resource Identifier
 *        { "type": "ARTICLE", "id": "123123" }
 */
KauriClient.prototype.getComments = async function(parent)

/**
 * addComment
 * @description: Record comment
 * @args: parent
 *       {"body": "my comment", "parent": { "type": "ARTICLE", "id": "123123" } }
 */
KauriClient.prototype.addComment = async function(commentInput)

/**
 * getCollection
 * @description: Get collection
 * @args: collectionId Collection ID
 */
KauriClient.prototype.getCollection = async function(collectionId)

/**
 * createCollection
 * @description: Create a collection
 * @args: collectionInput
 *       {"name": collectionName, "description": collectionDescription, "attributes": {}, "sections": [{ "name": "section name", "description": "section desc", "resourcesId": [{ "type": "ARTICLE", "id": "123123" }] }], "tags": ["tag1"]}
 */
KauriClient.prototype.createCollection = async function(collectionInput)

/**
 * editCollection
 * @description: Edit a collection
 * @args: collectionInput
 *       { "id": id, "name": collectionName, "description": collectionDescription, "attributes": {}, "sections": [{ "name": "section name", "description": "section desc", "resourcesId": [{ "type": "ARTICLE", "id": "123123" }] }], "tags": ["tag1"]}
 */
KauriClient.prototype.editCollection = async function(collectionInput)

/**
 * addCollectionSection
 * @description: Add a section to a collection
 * @args: id Collection ID
 * @args: section Section
 *      { "name": "section name", "description": "section desc", "resourcesId": [{ "type": "ARTICLE", "id": "123123" }] }
 * @args: position Position of the section (default: last)
 */
KauriClient.prototype.addCollectionSection = async function(id, section, position)

/**
 * removeCollectionSection
 * @description: Remove a section from a collection
 * @args: id Collection ID
 * @args: sectionId Section ID
 */
KauriClient.prototype.removeCollectionSection = async function(id, sectionId)

/**
 * moveCollectionSection
 * @description: Move a section within a collection
 * @args: id Collection ID
 * @args: sectionId Section ID
 * @args: position Position of the section (default: last)
 */
KauriClient.prototype.moveCollectionSection = async function(id, sectionId, position)

/**
 * addCollectionResource
 * @description: Add a resource to a collection section
 * @args: id Collection ID
 * @args: sectionId Section ID
 * @args: resource Resource Identifier
 *      { "type": "ARTICLE", "id": "123123" }
 * @args: position Position of the section (default: last)
 */
KauriClient.prototype.addCollectionResource = async function(id, sectionId, resource, position)

/**
 * removeCollectionResource
 * @description: Remove a resource from a collection section
 * @args: id Collection ID
 * @args: sectionId Section ID
 * @args: resource Resource Identifier
 *      { "type": "ARTICLE", "id": "123123" }
 */
KauriClient.prototype.removeCollectionResource = async function(id, sectionId, resource)

/**
 * moveCollectionResource
 * @description: Move a resource within a collection section
 * @args: id Collection ID
 * @args: sectionId Section ID
 * @args: resource Resource Identifier
 *      { "type": "ARTICLE", "id": "123123" }
 * @args: position Position of the section (default: last)
 */
KauriClient.prototype.moveCollectionResource = async function(id, sectionId, resource, position)


/**
 * getCuratedList
 * @description: Get a curated List
 * @args: curatedListId CuratedList ID
 */
KauriClient.prototype.getCuratedList = async function(curatedListId)

/**
 * createCuratedList
 * @description: Creat a curated List
 * @args: curatedListInput
 *        { "name": curatedListName, "description": curatedListDescription, "header": { "type": "ARTICLE", "id": "123123" }, "resources": [{ "type": "ARTICLE", "id": "123123" }], "links": links }
 */
KauriClient.prototype.createCuratedList = async function(curatedListInput)

/**
 * editCuratedList
 * @description: Edit a curated List
 * @args: curatedListInput
 *        { "id": id, "name": curatedListName, "description": curatedListDescription, "header": { "type": "ARTICLE", "id": "123123" }, "resources": [{ "type": "ARTICLE", "id": "123123" }], "links": links }
 */
KauriClient.prototype.editCuratedList = async function(curatedListInput)

/**
 * removeCuratedList
 * @description: Remove a curated List
 * @args: curatedListId CuratedList ID
 */
KauriClient.prototype.removeCuratedList = async function(curatedListId)

/**
 * getCommunity
 * @description: Get community details
 * @args: communityId Community ID
 */
KauriClient.prototype.getCommunity = async function(communityId)

/**
 * createCommunity
 * @description: Create a community
 * @args: communityInput
 *        { "name": name,  "description": desc, "website": website, "social": {"twitter": twitter}, "tags": ["tag1"] }
 */
KauriClient.prototype.createCommunity = async function(communityInput)

/**
 * editCommunity
 * @description: Edit a community
 * @args: communityInput
 *        { "id": id,  "name": name,  "description": desc, "website": website, "social": {"twitter": twitter}, "tags": ["tag1"] }
 */
KauriClient.prototype.editCommunity = async function(communityInput)

/**
 * submitResourceToCommunity
 * @description: Submit a resource to a community (curation)
 * @args: communityId Community ID
 * @args: resourceId Resource Identifier
 *        { "type": "ARTICLE", "id": "123123" }
 */
KauriClient.prototype.submitResourceToCommunity = async function(communityId, resourceId)

/**
 * approveResourceToCommunity
 * @description: Approve a resource to a community (curation)
 * @args: communityId Community ID
 * @args: resourceId Resource Identifier
 *        { "type": "ARTICLE", "id": "123123" }
 */
KauriClient.prototype.approveResourceToCommunity = async function(communityId, resourceId)

/**
 * removeResourceFromCommunity
 * @description: Remove a resource from a community (curation)
 * @args: communityId Community ID
 * @args: resourceId Resource Identifier
 *        { "type": "ARTICLE", "id": "123123" }
 */
KauriClient.prototype.removeResourceFromCommunity = async function(communityId, resourceId)

/**
 * addMember
 * @description: Add member to a community
 * @args: communityId Community ID
 * @args: member Member address
 * @args: role Role (1: ADMIN, 2: CURATOR)
 */
KauriClient.prototype.addMember = async function(communityId, member, role)

/**
 * removeMember
 * @description: Remove member from a community
 * @args: communityId Community ID
 * @args: member Member address
 * @args: role Role (1: ADMIN, 2: CURATOR)
 */
KauriClient.prototype.removeMember = async function(communityId, member, role)

/**
 * getArticle
 * @description: Get Article details
 * @args: id Article ID
 * @args: version Article version (optional)
 * @args: published Last published article (optional) (true|false)
 */
KauriClient.prototype.getArticle = async function(id, version, published)

/**
 * searchArticles
 * @description: Search Article
 * @args: filter Article Filter
 *        {"dateCreatedLessThan": "2019-03-21T10:42:04.612Z", "dateCreatedGreaterThan": "2019-03-21T10:42:04.612Z", "idEquals": "c253adf5afb34548b14c4725ebba87e5", "authorIdEquals": "f0f15cedc719b5a55470877b0710d5c7816916b1", "ownerIdEquals": "f0f15cedc719b5a55470877b0710d5c7816916b1", "checkpointEquals": "", "statusIn": ["PUBLISHED", "DRAFT"], "latestVersion": true, "versionIn": [1, 2]}
 * @args: page Page No (default 0)
 * @args: size Page Size (default 20)
 * @args: sort Sorting attribute (default dateCreate)
 * @args: dir Sorting direction (default DESC)
 */
KauriClient.prototype.searchArticles = async function(filter, page, size, sort, dir)

/**
 * submitArticle
 * @description: Submit an article as a DRAFT
 * @args: articleInput
 *        { "content": "the content", "title": "the title", "attributes": {"origin_source": "canonical url", "original_name": "medium"},  "tags": ["tag1"] }
 */
KauriClient.prototype.submitArticle = async function(articleInput)

/**
 * publishArticle
 * @description: Publish a DRAFT
 * @args: id Article ID
 * @args: version Article version
 * @args: signature (see generateArticleSignature)
 * @args: owner Article Owner (individual or community)
 * @args: updateComment Revision message
 */
KauriClient.prototype.publishArticle = async function(id, version, signature, owner, updateComment)

/**
 * submitAndSelfPublishArticle
 * @description: Submit and Publish an article
 * @args: articleInput
 *        { "content": "the content", "title": "the title", "attributes": {"origin_source": "canonical url", "original_name": "medium"},  "tags": ["tag1"] }
 */
KauriClient.prototype.submitAndSelfPublishArticle = async function(articleInput)

/**
 * approveArticle
 * @description: Approve a pending article version
 * @args: id Article ID
 * @args: version Article version
 * @args: signature (see generateArticleSignature)
 */
KauriClient.prototype.approveArticle = async function(id, version, signature)

/**
 * rejectArticle
 * @description: Approve a pending article version
 * @args: id Article ID
 * @args: version Article version
 * @args: cause Cause of the rejection
 */
KauriClient.prototype.rejectArticle = async function(id, version, cause)

/**
 * cancelArticle
 * @description: Delete a DRAFT
 * @args: id Article ID
 * @args: version Article version
 */
KauriClient.prototype.cancelArticle = async function(id, version)

/**
 * generateArticleSignature
 * @description: Generate a cryptoggraphic signature of the article
 * @args: id Article ID
 * @args: version Article version
 * @args: author Articl Author address
 * @args: contentHash Article  IPFS content hash
 * @args: dateCreated Article date Created
 */
KauriClient.prototype.generateArticleSignature = async function(id, version, author, contentHash, dateCreated)

/**
 * searchAutocomplete
 * @description: Make a global search across kauri resources (any type)
 * @args: query Query search
 */
KauriClient.prototype.searchAutocomplete = async function(query)

/**
 * searchTags
 * @description: Suggest tags
 * @args: query Query search
 */
KauriClient.prototype.searchTags = async function(query)

/**
 * searchMoreLikeThis
 * @description: Find related content
 * @args: resourceId Resource Identifier
 *        { "type": "ARTICLE", "id": "123123" }
 */
KauriClient.prototype.searchMoreLikeThis = async function(resourceId)

/**
 * checkpointArticles
 * @description: Initiate the checkpointer to pick-up no-checkpointed articles and checkpoint them
 */
KauriClient.prototype.checkpointArticles = async function()

/**
 * submitCheckpoint
 * @description: Submit a checkpoint to the chain
 * @args: checkpoint Checkpoint hash
 */
KauriClient.prototype.submitCheckpoint = async function(checkpoint)

/**
 * getArticleProof
 * @description: Retrieve an article proof
 * @args: id Article ID
 * @args: version Article version
 */
KauriClient.prototype.getArticleProof = async function(id, version)

/**
 * validateArticleProof
 * @description: Validate a proof
 * @args: id Article ID
 * @args: version Article version
 * @args: contentHash Article IPFS content hash
 * @args: creator Article Author account address
 * @args: timestamp Article date created
 * @args: checkpointRoot Article Checkpoint hash
 * @args: proof Article proof to validate
 */
KauriClient.prototype.validateArticleProof = async function(id, version, contentHash, creator, timestamp, checkpointRoot, proof)

/**
 * upload
 * @description: Upload a file on IPFS
 * @args: filePath file to upload
 */
KauriClient.prototype.upload = async function(filePath)

/**
 * download
 * @description: Download a file from IPFS
 * @args: filePath file to store the result
 */
KauriClient.prototype.download = async function(filePath) {

/**
 * addTemplate
 * @description: Add a template
 * @args: name
 * @args: content
 * @args: criteria
 */
KauriClient.prototype.addTemplate = async function(name, content, criteria)

/**
 * getTemplates
 * @description: Find templates
 * @args: articleContext
 */
KauriClient.prototype.getTemplates = async function(articleContext)

/**
 * getSitemap
 * @description: Get latest sitemap
 */
KauriClient.prototype.getSitemap = async function()

/**
 * generateSitemap
 * @description: Trigger the generation of the sitemap
 */
KauriClient.prototype.generateSitemap = async function()
```

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