Web API - An Introduction

Web API - An Introduction

In this issue of newsletter we will explore the APIs. I will provide an introduction to API. By the end of this article you will be able to understand the following topics:

  1. What are web APIs?
  2. What is its use?
  3. Features of good API?

What are web APIs?

API stands for application Programming Interface. An API defines a way in which two systems interact with each other. APIs are almost everywhere examples can be Twitter bots, Google Maps, Travel Booking and many more. APIs are special types of interface that defines how two computer systems interact. APIs can be categorized into downloadable APIs and web APIs.

  1. Web API:A Web API is an API that is accessible over the internet using standard web protocols such as HTTP. It is typically hosted on a server and allows communication between different software applications, either within the same organization or across the internet. Web APIs are commonly used in web development to enable communication between the front-end (client-side) and back-end (server-side) of web applications. RESTful APIs and SOAP (Simple Object Access Protocol) APIs are examples of web APIs. RESTful APIs, in particular, have gained widespread popularity due to their simplicity and scalability. Web APIs have no copies and the source code is not available to the client. That's why if a web API changes those changes are forced on the users/client. The user/client has no control over the web API they use. For example there is an web API that allows to encrypt data. Today the encryption API may use public key encryption tomorrow they may change it to private key encryption and later they decide to shut down this API. So, at this point the client application will suddenly stop working and nothing could be done about it. Probably this is the most important benefit of web API the developers building the API have full control of it.
  2. Downloadable API:A downloadable API refers to an API or SDK (Software Development Kit) that developers can download and integrate into their local development environment or application. These APIs are often provided by software vendors, service providers, or open-source projects to facilitate the integration of their services or functionalities into custom applications. Downloadable APIs can include libraries, software components, documentation, and tools that developers need to interact with a specific service, hardware device, or software functionality. Examples of downloadable APIs include libraries for accessing database systems, SDKs for integrating with hardware devices, or software packages that provide specific functionalities like image processing or machine learning.

What is its use?

Given below are some common uses of APIs.

  1. Data Access and Integration: APIs enable applications to access and integrate data from external sources or services. For example, a weather application may use a weather API to retrieve real-time weather data.
  2. Service Integration: APIs facilitate the integration of various services and applications. For instance, a payment processing service may provide an API that allows e-commerce websites to securely process payments.
  3. Automation: APIs enable automation by allowing different software components to communicate and perform actions programmatically. This is particularly useful in scenarios where manual intervention is not efficient or practical.
  4. Third-Party Integrations: Many applications provide APIs to allow third-party developers to extend and enhance their functionality. Social media platforms, for example, often offer APIs that developers can use to integrate social features into their own applications.
  5. Mobile App Development: APIs are essential in mobile app development, allowing mobile applications to interact with server-side databases, services, and other resources.
  6. Cloud Computing: Cloud service providers offer APIs to enable users to manage and interact with their cloud resources programmatically. This includes services like storage, computing power, and databases.
  7. Web Development: APIs are commonly used in web development to enable the interaction between the front-end and back-end of web applications. Web APIs (often RESTful APIs) are used to send and receive data between the client and server.
  8. IoT (Internet of Things): In IoT applications, APIs play a role in allowing devices to communicate with each other and with cloud-based services. This is crucial for the exchange of data and control commands.
  9. Machine Learning and AI: APIs are used to integrate machine learning models and AI services into applications, allowing developers to leverage advanced capabilities without having to build these models from scratch.

In summary, APIs serve as bridges between different software systems, allowing them to communicate and share functionality, data, and services. They are fundamental to the modern software development landscape, enabling interoperability and fostering innovation.

Features of good API?

  1. Operational - The API should actually do function as user intends. No matter what the final interface looks like the system as a whole should be operational. If the system intends to translate text from one language to another then it must be able to do so. Apart from this there might be some non operational requirements like latency (time taken to translate the text in 5 milliseconds) or accuracy (e.g. More than 95% accurate). So, these aspects also constitute to the operational aspect of a system.
  2. Expressive - When we say that an API should be expressive, we mean that it should allow developers to achieve a wide range of functionalities in a clear and intuitive manner. An expressive API refers to how well the API can convey its capabilities, features, and usage patterns to developers. An expressive API is one that is easy to understand, flexible and provides a natural way for developers to interact with it. For example : Suppose there is an API that translates the input text. The design of the API should have a method TranslateText(). It should detect the input text language and then return the translated text otherwise return an error stating that the language of input text is not supported. APIs that are expressive provide the ability for users to clearly dictate exactly what they want (e.g., translate text) and even how they want it done (e.g., “within 150 milliseconds, with 95% accuracy”).
  3. Simple - The principle that an API should be simple emphasizes the importance of clarity, ease of use, and a straightforward design in the creation of API. While simplicity is essential, it's important to strike a balance. An API should be simple without sacrificing necessary features, flexibility, or the ability to handle diverse use cases. The goal is to make the API as straightforward as possible while still providing the functionality and versatility required by developers. If we take the example of text translation. Suppose in future we have another consumer that needs some advanced functionality to get the model_Id. Because of this we shouldn't break the existing functionality we should use the same translateText(string inputText, string tagetLanguage, string? modelId) and then return the translated text with model_Id if it exists. Defining modelId nullable will solve all the cases.
  4. Predictable - APIs that rely on repeated, predictable patterns (e.g., naming fields consistently) are easier and faster to learn and therefore better. APIs built using well-known, well-defined, clear, and (hopefully) simple patterns will lead to APIs that are predictable and easy to learn, which should lead to overall better APIs.

Summary

APIs are special type of interface to define how two systems interact with each other. Web APIs are special as they expose functionality over a network, hiding the specific implementation or computational requirements needed for that functionality. A good API should be operational, expressive, simple and predictable.



要查看或添加评论,请登录

Megha Sahay的更多文章

  • A gentle introduction to Java Script

    A gentle introduction to Java Script

    JavaScript is a versatile, high-level programming language that's widely used in web development. It can be used to add…

  • Stack vs Heap - Understanding memory in C#

    Stack vs Heap - Understanding memory in C#

    Managing memory in important for any programming language. This impacts both reliability and performance of a…

    1 条评论
  • Performance improvement for React based apps

    Performance improvement for React based apps

    Hello everyone welcome to this weeks post. In this week we will discuss few points that will improve the performance of…

  • Understanding Ransomware

    Understanding Ransomware

    In this issue of newsletter we will explore ransomware. I will provide an introduction to ransomware.

    1 条评论
  • Docker - A beginners guide

    Docker - A beginners guide

    Docker is an open-source platform that allows developers to build, package, and deploy applications as lightweight…

  • C# Extension Methods

    C# Extension Methods

    In this week's newsletter we will take a closer look at extension methods in C#. By the end of this article you should…

    1 条评论
  • A Developer’s Dilemma: Selecting the Perfect Protocol - GraphQL, REST, gRPC or WebSockets?

    A Developer’s Dilemma: Selecting the Perfect Protocol - GraphQL, REST, gRPC or WebSockets?

    Selecting the ideal protocol for your unique Project Introduction Many software architects face problems to choose…

  • CQRS in C#

    CQRS in C#

    In this edition of newsletter we will understand what is CQRS pattern with a sample clean architecture example. By the…

  • Implementing ORM with .Net

    Implementing ORM with .Net

    We will look at implementing Object–relational mapping with Entity core framework. We will cover the following topics.

  • Using GraphQL with C#

    Using GraphQL with C#

    An application demonstrating use of Graphql with C#. In todays newsletter we will look into how can we use GraphQL with…

社区洞察

其他会员也浏览了