Web API
- What is an web API?
Before focus on web API, First we need to understand API. API is standards for Application Programing Interface. In technical terms an Application Programming Interface (API) is a set of subroutine definitions, protocols, and tools for building software and applications.
To put it in simple terms, API is some kind of interface which has a set of functions that allow programmers to access specific features or data of an application, operating system or other services.
Web API as the name suggests, is an API over the web which can be accessed using HTTP protocol. It is a concept and not a technology. It is a framework that helps you to create and develop HTTP based RESTFUL services. We can build Web API using different technologies such as Java, .NET etc. A Web API is an application programming interface for either a web server or a web browser.
It is limited to Web Application’s client-side and also it does not include a web server or web browser details. If an application is to be used on a distributed system and to provide services on different devices like laptops, mobiles, etc. Then web API services are used. Web API is the enhanced form of the web application.
2. Why we use web APIs?
Nowadays, a web-based application is not enough to reach the customers. People are very smart and they are using smart phones, tablets, laptops etc. These devices also consist a lot of applications for making their life easy. Now, we are moving from the web towards apps world. So, if you like to expose your service data to the browsers and as well as all these modern devices apps in fast and simple way, you should have an API which is compatible with browsers and all these devices.
Web API is the great framework for exposing your data and service to different types of devices. Moreover Web API is open source an ideal platform for building REST-ful services. Unlike WCF Rest service, it use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats) and you don’t need to define any extra config settings for different devices unlike WCF Rest service.
Following are some points of Web APIs
- It Supports convention-based CRUD operations, since it works with HTTP verbs GET,POST,PUT and DELETE.
- Used to build simple, non-SOAP-based HTTP Services on top of existing WCF message pipeline.
- A Web API services are preferable over other services to use with a native application that does not support SOAP but require web services
- Responses have an Accept header and HTTP status code.
- Easy configuration unlike WCF REST service.
- For creating resource-oriented services, the web API services are the best to choose. By using HTTP or restful service, these services are established.
- Supports multiple text formats like XML, JSON etc. or you can use your custom Media Type Formatter.
- Simple service creation with Web API. With WCF REST Services, service creation is difficult.
- If you want good performance and fast development of services, the web API services are very helpful.
- May accepts and generates the content which may not be object oriented like images, PDF files etc.
- Based on HTTP and so easy to define, expose and consume in a REST-ful way.
- For developing light weighted and maintainable web services, web API services are really helpful to develop that service. It supports any text pattern like JSON, XML etc.
- Automatic support for OData. Hence by placing the new [Queryable] attribute on a controller method that returns IQueryable, clients can use the method for OData query composition.
- Supports Self-hosting or IIS Hosting.
- If you need a Web Service and don’t need SOAP, then ASP.NET Web API is best choice.
- Based on light weight RESTful architecture and good for devices which have limited bandwidth like smart phones.
- The devices that have tight bandwidth or having a limitation in bandwidth, then the Web API services are the best for those devices.
- Open Source.
3. Examples for web APIs.
- Google Maps API’s: Google Maps APIs allows developers to use Google Maps on Webpages using a JavaScript or Flash interface.
- YouTube API’s: Google’s API lets developers integrate YouTube and functionality into websites or applications. YouTube APIs include the YouTube analytics API, YouTube Data API, YouTube live streaming API, YouTube Player APIs and others.
- Weather APIs: Access current weather data for any location including over 200,000 cities
- Cricket Score APIs: Cricket Live Scores API provides invaluable data to develop cricket related apps. The API accepts GET calls and returns JSON formatted content. Cricket Live Scores API is able to deliver a list of available matches as well as cricket scores, cricket scorecards, Test scores, ODI scores, T20 scores, BBL scores, IPL scores, World Cup scores.
- The Flickr APIs: It is used by developers to access the Flick photo sharing community data.
- Twitter APIs: Twitter offers two APIs, the REST API allows developers to access core Twitter data and the search API provides methods for developers to interact with twitter search and trends data.
4. Limitations of web APIs.
REST, as a system in itself, is very predictable regarding endpoints and the content of the requests, being just an HTTP request. It is supposed that end-users can easily guess how to fulfill their aim as long as the URL structure of the site is familiar to them, which can be interpreted as a breach within the security system. This is considered one of the first drawbacks/limitations of RESTful APIs, but we will get to this in a minute.
Regarding performance, it is considered that SOAP is more advanced in this regard, making good use of event-based parsing, which adds to the scalability of SOAP stacks that use normal HTTP processing along the XML parsing, while REST uses the HTTP processing method alone.
There are a few limitations when working with APIs in Shortcuts:
- OAuth: OAuth 2, a system of authentication that requires a user to manually enter their username and password on a login page, is currently not supported.
- Various endpoints: APIs often have a variety of endpoints that you can use to request different types of data. Working with some APIs may require a series of API calls, first to retrieve current existing data, and then later to add, update, or delete more data.
- Rate limiting: Many APIs have limitations on how often you can make requests. These restrictions are aimed at limiting abuse of an API service in case someone makes thousands or millions of requests programmatically. API services can be limited by hour, day, or month, or may require you to pay for API access after exceeding these limits.
Hope you now get the basic idea of web APIs. See you in another topic. Bye..!