Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@4-us-4-others/are.na
Advanced tools
Interface to are.na API. A fork of @ivangreene's are.na package (https://github.com/ivangreene/arena-js).
Uses Axios, which is Promise-based and compatible with Node.js/io.js or modern browsers. Use it server side, or in your React, Vue or Angular apps.
This repo is our fork of @ivangreene's arena-js ↗.
At the moment, we're publishing it to provide some quick fixes to dependency vulnerabilities, and maybe pushing some small updates.
⚠️ Experimental
— Don't use this!
Available from npm:
$ npm install are.na
# or:
$ yarn add are.na
const Arena = require('are.na');
const arena = new Arena();
arena.channel('arena-influences').get()
.then(chan => {
chan.contents.map(item => {
console.log(item.title);
});
})
.catch(err => console.log(err));
The class is organized hierarchically as nested objects. Emulates the are.na api documentation structure.
new Arena([config])
accessToken
: Your are.na API access tokenbaseURL
: Base URL to make requests on (default: https://api.are.na/v2/
)let arena = new Arena({ accessToken: 'abcd' });
Methods that resolve with an Array will have an attrs
property that contains the other data returned. For example, channel(slug).connections()
will resolve with an Array of the channel's block's connections, and an attrs
property containing properties like length
, total_pages
, current_page
, etc.
Some methods have pagination available. Pass params
as an object, in the form { page: 3, per: 10 }
.
channel([slug || id][, params])
Method | Returns | Description |
---|---|---|
.get([params]) | Promise<Object> | Get the channel as an Object. Gets a list of public channels if slug/id not specified. Supports pagination. |
.thumb([params]) | Promise<Object> | Limited view of the channel. |
.connections([params]) | Promise<Array> | Get all of the connections of the channel (channels where this channel is connected). Supports pagination. |
.channels([params]) | Promise<Array> | Get all of the channels connected to blocks in the channel. Supports pagination. |
.contents([params]) | Promise<Array> | Get the channel's contents only, as an array. Supports pagination. |
.collaborators([params]) | Promise<Array> | Get the channel's collaborators. Supports pagination. |
.create([title || status][, status]) | Promise<Object> | Creates a new channel. Can be called as channel(title).create([status]) or channel().create(title[, status]) . Title is required, status is optional. |
.delete([slug]) | Promise | Delete the channel. Can be called as channel(slug).delete() or channel().delete(slug) . |
.update(params) | Promise<Object> | Update the channel's attributes. params should be an object and can include title and/or status . Currently it appears that the are.na API requires both values. If title is not set, an error will occur. If status is not set, it will default to "public". |
.addCollaborators(...userIds) | Promise<Array> | Add collaborators to a channel. Pass userIds as an Array or multiple arguments. channel(slug).addCollaborators(123, 456) or channel(slug).addCollaborators([123, 456]) works. |
.deleteCollaborators(...userIds) | Promise<Array> | Remove collaborators from a channel. Accepts userIds in the same format as addCollaborators. |
.createBlock(content||source) | Promise<Object> | Create a block and add it to the channel. Specify textual content or a source link. |
.deleteBlock(blockId) | Promise | Remove a block from the channel. |
// Get first 3 pieces of content from a channel and print their titles
arena.channel('arena-influences').contents({ page: 1, per: 3 })
.then(contents => {
contents.map(content => {
console.log(content.title);
});
})
.catch(err => console.log(err));
// Create a new channel called "beautiful foods" that is closed
arena.channel('beautiful foods').create('closed');
// or
arena.channel().create('beautiful foods', 'closed')
.then(chan => console.log('Slug: ' + chan.slug))
.catch(err => console.log(err));
block([id][, params])
Method | Returns | Description |
---|---|---|
.get([params]) | Promise<Object> | Get the block specified by id. |
.channels([params]) | Promise<Array> | Get a list of the channels a block belongs to. |
.create(channelSlug, content || source) | Promise<Object> | Create a block and add it to the channel. Specify textual content or a source link. |
.update({ content, title, description }) | Promise | Update a block. Pass an object with one or more of content, title or description fields to update those fields. |
// Get a block, print its title
arena.block(8693).get()
.then(block => console.log(block.title))
.catch(console.error);
// Create a block in the channel 'great-websites'
arena.block().create('great-websites', 'https://are.na/');
// Update a block
arena.block('65234').update({ content: 'New content', title: 'New title', description: 'New description' });
user(id || slug[, params])
Method | Returns | Description |
---|---|---|
.get([params]) | Promise<Object> | Get a user specified by id. |
.channels([params]) | Promise<Array> | Get a user's channels, as an array. Supports pagination. |
.following([params]) | Promise<Array> | Get a list of users and/or blocks the user is following. Supports pagination. |
.followers([params]) | Promise<Array> | Get a list of the user's followers. Supports pagination. |
// Get a user, print their name
arena.user(23484).get().then(user => console.log(user.full_name));
search(query[, params])
All methods support pagination.
Method | Returns | Description |
---|---|---|
.all([params]) | Promise<Object> | Search for channels, blocks, and users matching query. (The API currently only seems to return channels and blocks, and the users array will be empty?) |
.users([params]) | Promise<Array> | Search for users. |
.channels([params]) | Promise<Array> | Search for channels. |
.blocks([params]) | Promise<Array> | Search for blocks. |
// Get the 2nd page of 3 channel results for 'art',
// print links to them
arena.search('art').channels({ page: 2, per: 3})
.then(channels => {
channels.map(chan => {
console.log('https://www.are.na/channels/' + chan.slug);
});
});
In order to run tests, you will have to add an are.na Personal Access Token as a shell variable (passed when running $ yarn test
).
~/.bash_profile
, .zshrc
, etc) ⤵
export ARENA_ACCESS_TOKEN="YOUR_PERSONAL_ACCESS_TOKEN"
FAQs
Interface to are.na API. A fork of @ivangreene's are.na package (https://github.com/ivangreene/arena-js).
The npm package @4-us-4-others/are.na receives a total of 0 weekly downloads. As such, @4-us-4-others/are.na popularity was classified as not popular.
We found that @4-us-4-others/are.na demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.