Xively

From Omnia
Revision as of 04:55, 16 December 2015 by Kenneth (talk | contribs) (→‎Xively)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

DEAD

The free version of Xively is no more!

Xively

Xively – Public Cloud for the Internet of Things - http://xively.com

COSM

COSM has been renamed to Xively

Cosm is now Xively. Read more

Libraries

Xively library xively-python - https://github.com/xively/xively-python

Welcome to Xively Python’s documentation — Xively Python 0.1.0-rc2 documentation - http://xively.github.io/xively-python/

Xively REST API - Xively - https://xively.com/dev/docs/api/

Libraries - Xively - https://xively.com/dev/libraries/

  • Android
  • Arduino
  • ARM® mbed
  • C
  • Electric Imp
  • Java
  • JavaScript
  • Objective-C
  • PHP
  • Python
  • Ruby

Single Datastream - PNG Graphs - Xively - https://xively.com/dev/docs/api/data/read/single_datastream/

Technology Projects: Live embedded Cosm graphs - http://matt-electronicsprojects.blogspot.com/2012/09/live-embedded-cosm-graphs.html

Oeey Gooey Raspberry Pi: Data Logging with the Internet of Things - http://www.oeey.com/2013/09/data-logging-with-internet-of-things.html

curl

Curl - How-to use Xively API on the command-line - https://xively.com/dev/tutorials/curl/

Create feed:

curl --request POST \
--data '{"title":"My feed", "version":"1.0.0"}' \
--header "X-ApiKey: YOUR_API_KEY_HERE" \ # replace this with your key
--verbose \
https://api.xively.com/v2/feeds

Update feed:

curl --request PUT \
--data-binary @feed_update_payload.json \
--header "X-ApiKey: YOUR_API_KEY_HERE" \ # replace this with your key
--verbose \
NEW_FEED_URL # replace this with new feed's URL

Retrieve feed:

curl --request GET \
--header "X-ApiKey: YOUR_API_KEY_HERE" \ # replace this with your key
--verbose \
NEW_FEED_URL # replace this with new feed's URL

Free Developer Account

Get a free Developer Account - https://xively.com/pricing/#developer-account

Limits:

  • Unlimited Development Devices with unlimited channels
  • Development devices store data for 30 days.
  • Developer Account API limit 25 API calls per minute, 3 minute moving average.

Installation

# Xively Library Installation 
git clone https://github.com/kennethreitz/requests
git clone https://github.com/xively/xively-python
cd xively-python
ln -s ../requests/requests

# verify import throws no errors
echo "import xively" | python

---

Alternative:

# also installs 'requests'
pip install xively-python

# verify import throws no errors
echo "import xively" | python

Note: if you are getting an error message that says “Could not find a version that satisfies the requirement”, you should try running: [1]

pip install --pre xively-python.

Update Script

#!/usr/bin/python2.7

# NOTE: xively requires Python 2.7+

import sys
import datetime
import xively

API_KEY = "API_KEY"  # set to your API Key
FEED_ID = "FEED_ID"  # set to your Feed ID

if len(sys.argv) != 3:
    print "Usage: {0} <channel> <value>".format(sys.path[0])
    sys.exit(1)

channel = sys.argv[1]
value = sys.argv[2]

api = xively.XivelyAPIClient(API_KEY)
feed = api.feeds.get(FEED_ID)
now = datetime.datetime.utcnow()
feed.datastreams = [
    xively.Datastream(id=channel, current_value=value, at=now)
    ]
feed.update()

Usage:

./xively-update.py sensor1 42

Tutorials

Raspberry Pi - Xively Tutorials - https://xively.com/dev/tutorials/pi/

Xively Python’s documentation — Xively Python 0.1.0-rc2 documentation - http://xively.github.io/xively-python/

keywords