REST: Representational State Transfer: http://en.wikipedia.org/wiki/Representational_State_Transfer
Without getting into too many details, what I love is how easily I was able to create a REST API that interfaces with Apache Cassandra. I have an API that fully supports PUT / POST / GET / DELETE / SEARCH without having to write all that much code. Admittedly, I did it with phpcassa which may not be the best, most efficient, or whatever .. but I have to say. It works and I rarely touch the code.
Some simple concepts I implemented:
- A resource is a 1:1 mapping to a Cassandra column family. For example:
- http://api.example.com/user/ is a reference to the "user" column family
- The element that follows the resource is a 1:1 mapping to a key in a Cassandra column family
- http://api.example.com/user/sdolgy is a reference to the key "sdolgy" in the column family "user"
What is great here is that as the design changes or new information is added to Cassandra, I am making no changes to the REST API code. New column families, new keys ... it's all good. Simple.
The only issues I continue to have are the ones around security. This is always an epic or regal battle / debate on the best way to approach and tackle this problem. Some people are big into OAuth. There are still security concerns over OAuth and even some references to that, despite the big boys (facebook / google / twitter / etc. ) are using it ... it doesn't mean it's more secure or the best way to secure a REST API. For now, I have implemented my own variation and will have to revisit in the future before we launch the online CHIA PET....
Here is a good tutorial on creating a PHP REST API if you are keen to get started: