Using Curl to Access the Rackspace Cloud API

I've been playing around w/ the Rackspace Cloud API quite a bit. Then, today I got an email from a reader of this blog asking me how it works more or less. So, I thought I'd post a couple of the examples I've been using. In the absense of a fancy GUI to control cloud servers I've simply been using Curl and writing little shell scripts to get the job done.

Authentication Request

curl -D - \
  -H "X-Auth-Key: youneedtoputyourownauthkeyhere" \
  -H "X-Auth-User: acctusr" \

Authentication Response

HTTP/1.1 204 No Content

Date: Sat, 25 Jul 2009 15:44:07 GMT
Server: Apache/2.2.3 (Mosso Engineering)
X-Storage-Token: 8gc00ld-a77r-6548-eq58-5nb5hsrv9876
X-Auth-Token: aq9beanS-d75c-9135-ed78-4bs3chse9135
Content-Length: 0
Connection: close
Content-Type: application/octet-stream

These aren't real tokens so you can't use them yourself of course. You need to get your own, which is exactly the point. Once you have successfully received your own response then you can move on to actually using other API calls to do things with the API. Here is a cloud servers API example using curl again.

Listing Your Account Limits

curl -D - \
  -H "X-Auth-Token: aq9beanS-d75c-9135-ed78-4bs3chse9135" \

That will output something that looks like this:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
vary: Accept, Accept-Encoding
Set-Cookie: JSESSIONID=D6DBBE0BE05C4559BC71E6F851501575; Path=/v1.0
Cache-Control: s-maxage=1800
Last-Modified: Sat, 25 Jul 2009 15:51:26 GMT
Content-Type: application/json
Content-Length: 657
Date: Sat, 25 Jul 2009 15:51:26 GMT
X-Varnish: 1753447558
Age: 0
Via: 1.1 varnish
Connection: keep-alive


Here is a very simple bash shell script you could use for the Authentication example above:


curl -D - \
  -H "X-Auth-Key: 5115a48a9ca852bc266ea3e7bc8805e7" \
  -H "X-Auth-User: nscaled" \

I know that there are at least a couple of companies with growing support via their cloud management platforms quickly adding Rackspace Cloud functionalities.  So, while I have to hack around with curl today I suspect that in short order it might get easier.