This is a python interface to the are.na API.
pip install arena
Bulk adding urls to a channel:
from arena import Arena
arena = Arena(my_access_token)
chan = arena.channels.channel('<channel-slug>')
for url in urls:
chan.add_block(source=url)
You first need an access token, which you can obtain via the authentication flow (below) or by creating a new application and grabbing the access token shown after creation.
from arena import Arena
arena = Arena(my_access_token)
arena.channels.channel('faq')
Endpoints which support pagination accept the keyword arguments page
(1-indexed) and per_page
. They return a tuple consisting of the results for that page and pagination info.
For example:
chans, page = arena.channels.list(page=1, per_page=10)
Resources (Block, Channel, User) have a nested .data
attribute that contains the raw API fields return from the are.na API. For example:
channels, page = user.channels()
for chanl in channels:
if chanl.data['status'] not in ['private', 'closed']:
...
chans, page = arena.channels.list(page=1, per_page=10)
arena.channels.create(title='My Channel', status='public')
status
can be one of ['public', 'private', 'closed']
.
By slug:
arena.channels.channel('yuppie-dystopia')
arena.channels.search('climate')
chan = arena.channels.channel('yuppie-dystopia')
items, page = chan.contents()
# Low-fidelity
chans, page = chan.connections()
# High-fidelity
chans, page = chan.channels()
users, page = chan.collaborators()
(This is also how you create blocks in general.)
# A block is added as a url
block = chan.add_block(source='https://github.com/frnsys/arena')
# Or as content
block = chan.add_block(content='Hello are.na')
# Removing a block
chan.remove_block(block_id)
chan.delete()
By id:
arena.blocks.block('896296')
arena.blocks.search('climate')
Blocks are created via the channel API (see above).
block = arena.blocks.block('896296')
block.update(title='Burrito Galaxy', description='A cool game')
Note that text block also support the content
argument, which supports markdown.
block = arena.blocks.block('896296')
chans, page = block.channels()
By slug:
arena.users.user('francis-tseng')
arena.users.search('climate')
user = arena.users.user('francis-tseng')
chans, page = user.channels()
user = arena.users.user('francis-tseng')
following, page = user.following()
followers, page = user.followers()
Note that following
can include users and channels.
To get the authenticated user's feed:
items, page = arena.feed(offset=0)
from arena import Auth
auth_flow = Auth(
client_id=YOUR_CLIENT_ID,
client_secret=YOUR_CLIENT_SECRET,
callback_url=YOUR_CALLBACK_URL,
)
# Direct your user to this request url,
# which redirects them to YOUR_CALLBACK_URL/?code=CODE
request_url = auth_flow.request_url()
# Using the provided CODE:
resp = auth_flow.request_access_token(CODE)
access_token = resp['access_token']
Export your Are.na token as an environment variable called ARENA
, then run nosetests
, e.g.:
export ARENA=my-token
nosetests tests