Every repository with this icon (
Every repository with this icon (
Home
Swivel provides a RESTful API interface for charts and data sets.
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
- Chart API
- Data Set API deprecated
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)
- Representational State Transfer (REST), Wikipedia
- Fielding, Roy Thomas. Architectural Styles and the Design of Network-based Software Architectures. Doctoral dissertation, University of California, Irvine, 2000.
- REST for the Rest of Us






