APIs are accessed by programmatically calling a URL and downloading the results given back. Generally the returned content of an API is XML or JSON. RSS and Atom feeds are in XML. This allows you, as a developer, to easily parse the content and do what you want with it. Depending on your application, there are a few ways in which you can access and work with this structured content.
One common method is to access and parse the content on the fly as the result of a user action. For example, let's say you provide a feature that allows your users to search for hotels in a specific city. When the user provides the city and dates of interest, your code would access the APIs of one' or more hotel sites"passing the city and dates, to get availability, parse the returned results, and display them to the user immediately. This approach is most useful when you need very fresh data and when you cannot anticipate the values your users are going to search for. The downsides to this method are that there is latency associated with accessing the API (ie, your user must wait) and your site causes a lot of traffic on the API of the remote website. Also, if the remote site goes down, your users will not have access to this feature.
To address the downsides of the on the-fly method, as well as to allow greater flexibility with how you filter, sort, and modify the returned data, your code can access the content from an API 'offline.' This means that you have some process that runs regularly (not as a result of some user's action) to download the data from a website's API or feed and then store it for access later. The most common place to store such data is in a database (like MySQL) or a search engine (like Lucene/Solr), but you could even store the XML files directly on disk and access them locally.




Reply With Quote
Copyright Techfuels
Bookmarks