RESTful Web API+howto

 

Basic API

 

GET /
# index.  if given name as CGI variable, acts just like GET /name

GET /name # read if exists, "new" form if not GET /name?view=edit # read in specified view if exists, "new" form if not. GET /?view=new # new card form POST / POST /name # create new card PUT / PUT /name # update card DELETE / DELETE /name # delete card (move to trash)

 

Variants

Names

Cards can be identified in three ways:

 

  1. name - default
  2. codename - begins with ":"
  3. id - begins with "~"

 

Names can be given in CGI params or in path.  Error if 2 different names are given.  Note that if a nonexistent codename or id is given in a normal GET request, response is 404 (not "new")

 

Formats

You can add ".<format extension>" to the end of any requests to specify the response file formats.

 

CGI Variables

Including:

 

  1. view args - eg layout, view, item, size, keyword
  2. action args - (not sure what those are yet)
  3. model args for PUTS and POSTS - eg name, type, content

 

Currently those model args come as card[name], card[type], etc.  We need to decide if that is still valuable (for example, in separating them from view/action args and how to specify nested cards, which will probably be some variant on that pseudo-hash structure.

 

GET Variants

 

POST /name -> GET /create/name
PUT /name -> GET /update/name
DELETE /name -> GET /delete/name
# and, for consistency...
GET /name -> GET /read/name