I'll first of all briefly explain what an API is and what its main purpose is. An API (Application Programming Interface) is in layman terms a way to gain access to data without having any knowledge of the code or technology behind the generation of that data.
The data is either in JSON or XML format with JSON being the preferable option because it’s more lightweight and puts less stress on resources.
For example the BBC have a few APIs (which you can read about here) through which you can access their radio programmes and other data. As a consumer of their API you have no idea how that data is being generated or how and where it is being stored. That's the beauty of it!
A REST API uses four main HTTP protocols to access/manipulate data: GET, POST, PUT and DELETE.
HTTP Protocol
|
Use
|
Example
|
GET
|
To retrieve data
|
Get list of all radio schedules
|
POST
|
To insert a new data entry
|
Add a new radio schedule to the existing list
|
PUT
|
Update existing data
|
Update a radio schedule entry
|
DELETE
|
Delete data entry
|
Delete a radio schedule entry
|
You can read more about the HTTP protocols here. There is also a directory of APIs you can have access to here.
In my previous post on "How to build an Android or iOS mobile app from scratch using just basic web skills" I explained that to make your app dynamic it has to make ajax requests to an API to get data.
I have built a lightweight sample API using the Slim MVC framework which you can download or pull from this GitHub URL.
Setup instructions can be found in the README.md file.
Good luck and you can comment or ask any questions here.
No comments:
Post a Comment