cURL

How-to use Xively API on the command-line

Introduction

This guide introduces you to the very basics of using the Xively API.

This guide assumes you have: - signed up to Xively - obtained an API key - installed cURL (comes with Mac OS X and most Linux and BSD distributions). - a familiarity with running UNIX shell (Terminal) commands

Create a Feed

First let’s create an empty feed template. We’ll just give it a title and version for now and specify the rest later.

You will need to POST a simple JSON object to /v2/feeds like so:

In the response you should see a status code of 201 (Created) and a Location header containing the URL of the newly created feed. We’ll use this URL in the next steps of this tutorial.

Update your feed

Now let’s update your feed and its datastreams. We’ll set up three datastreams with unique names. For this you need to PUT the payload to the new URL of the Feed you just obtained.

Let’s save this to a file called feed_update_payload.json and run cURL with the arguments as shown:

We can now update the values by editing the JSON file and repeat this request whenever required.

Retrieve your Feed

Let’s take a look at the current state of our feed.

Now we’ll see the current values coming from our feed and its datastreams, similar to this:

Next Steps

This Tutorial has introduced you to a basic way to interact with the Xively API.

Try out some of the more advanced API features after exploring the API Resources