Skip to content
This repository

Swivel provides a RESTful API interface for charts and data sets.

Libraries

Swivel’s API is designed to be simple enough that you do not need to use a 3rd party library to access it. However, here are links to a handful of 3rd party libraries that you may choose to use: Java, Ruby, PHP, shell command

Quick Start

Note: it may be necessary to replace the UPPERCASE SECTIONS with appropriate text.

Create a chart in Swivel with the following command.

curl -X POST \
    -u "YOUR_EMAIL_ADDRESS:YOUR_PASSWORD" \
    -F "name=API Chart" \
    -F "data=date,visits
Jan-09,50
Feb-09,100
Mar-09,200
Apr-09,400
May-09,800
Jun-09,1600" \
    -k https://api.swivel.com/v1/charts.xml

Examples

Create a chart from a file.

curl -X POST \
    -u "YOUR_EMAIL_ADDRESS:YOUR_PASSWORD" \
    -F "data=<myfile.csv" \
    -k https://api.swivel.com/v1/charts.xml

Create a chart from STDIN.

cat myfile.csv | curl -X POST \
    -u "YOUR_EMAIL_ADDRESS:YOUR_PASSWORD" \
    -F "data=<-" \
    -k https://api.swivel.com/v1/charts.xml

Replace chart data.

curl -X PUT \
    -u "YOUR_EMAIL_ADDRESS:YOUR_PASSWORD" \
    -F "data=<myfile.csv" \
    -k https://api.swivel.com/v1/charts/123456789.xml

Note: 123456789 is the id of the chart that you want to update.

Add data to the chart.

curl -X PUT \
    -u "YOUR_EMAIL_ADDRESS:YOUR_PASSWORD" \
    -F "data=<myfile.csv" \
    -F "mode=append" \
    -k https://api.swivel.com/v1/charts/123456789.xml

Read the chart data.

curl -X GET \
    -u "YOUR_EMAIL_ADDRESS:YOUR_PASSWORD" \
    -k https://api.swivel.com/v1/charts/123456789.csv

Read the chart meta-data (name, title, formatting information).

curl -X GET \
    -u "YOUR_EMAIL_ADDRESS:YOUR_PASSWORD" \
    -k https://api.swivel.com/v1/charts/123456789.xml

Delete the chart.

curl -X DELETE \
    -u "YOUR_EMAIL_ADDRESS:YOUR_PASSWORD" \
    -k https://api.swivel.com/v1/charts/123456789.xml

Details

  1. Chart API

Additional information

The Swivel API is REST based, and supports output in XML, JSON and sometimes CSV.

General guidelines for API calls

All parameters must be sent in UTF-8 and url encoded.

API calls that access private data must be authenticated with your username and password using HTTP basic authentication.

Resource URLs

Every item in Swivel has a unique URL. You can find this URL by going to the item in your web browser and looking at the URL in the address bar. Replace “business.swivel.com” in the URL with “api.swivel.com/v1” and append .xml or .json to the string.

The curl utility

This documentation uses curl in examples because it is freely available and widely installed, but any similar utility or language library can be used.

The examples use curl with the -k switch because many installations of the curl utility use an outdated list of security certificates. Swivel is secured by Comodo.

cron and crontab

Almost every system includes a scheduling tool such as cron or Windows Task Scheduler.

Once you have a script or tool that updates your data sets, you will probably want to set it to execute on a regular schedule so you and people in your group can concentrate on your numbers.

On many systems, you can edit your crontab file with the command crontab -e and add a line for the script you would like to run.

This example shows a crontab entry that would execute an update script daily at 14:45.

45 14 *  *  * /scripts/update.sh

Implementation and policies will vary. Consult the documentation for cron or Task Scheduler for your system.

Rate Limits

Swivel reserves the right to limit API requests should bandwidth exceed a reasonable amount (e.g. 10,000 requests per day).

If you are concerned about volume of API requests that your application may make, please contact Swivel support and we will work to accommodate your requirements.

Resources

Swivel

Representational State Transfer (REST)

Utilities and formats

Something went wrong with that request. Please try again.