Forum Moderators: phranque

Message Too Old, No Replies

API Building

What exactly is one and what is it good for?

         

ocon

1:13 am on Sep 21, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



My site offers an online service that uses a custom script. Anyone can use this service, and this script gets its functionality from reading a database on the site. This script is the core of my site.

I have another section of the website that will allow signed in members to modify some of the content in the database. Right now I plan on using a script that directly modifies the database.

I'm also in the process of creating a Firefox add-on that would interact with this database too, and eventually I want to have an iPhone/iPad application that also interacts with this database.

What I'm thinking about is maybe creating an API for this database. And having the member signed in section of the site use a script that doesn't directly interact with the database, but interacts with the API, and that API interacts with the database. And instead of custom scripts for interacting with the iPhone/iPad application, it could also use the API too. That way the member site, the Firefox add-on, and iPhone/iPad add-on would all be using the same gateway with a standard set of rules. I'm thinking that by having this service, it would also enable others to build custom tools and services that would interact with this API, or make it easier to work with contractors on building other official tools in the future.

But my question is, what exactly is an API? Would this be a fair use of it? I'm comfortable with PHP, but is PHP a good language to build an API in? Are there any tutorials one would recommend for building an API?

Thanks

phranque

11:42 am on Oct 22, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you could write books on a few of the topics you raise.

in your case you might want to consider exploring a "RESTful" architecture.
here are some references on the subject.

REST: Representational State Transfer [PDF]:
http://oreilly.com/catalog/pwebserperl/chapter/ch11.pdf [oreilly.com]

Representational State Transfer (REST):
http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm [ics.uci.edu]

there are even books on RESTful PHP web services.
here's an overview how-to:

Making a REST Request - YDN:
http://developer.yahoo.com/php/tutorials/water_bug_tutorial-making_rest_request.html [developer.yahoo.com]