Subscribe by Email


Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Friday, June 6, 2025

Risks with Using External APIs: A Tech Guide to Staying Safe

External APIs (Application Programming Interfaces) are a powerful tool for developers, letting apps talk to each other and share data or services seamlessly. Whether you’re building a weather app that pulls data from a weather API or an e-commerce site using a payment API like Stripe, external APIs can save you time and effort. But they come with risks that can impact your project if you’re not careful. With the growing reliance on APIs in cloud-based and microservices architectures, understanding these risks is more important than ever. In this article, we’ll explore the main risks of using external APIs, how they can affect your tech projects, and tips to mitigate them. Let’s dive in and uncover the potential pitfalls of external APIs!

What Are External APIs and Why Use Them?

An external API is a set of rules and tools that lets your app communicate with a third-party service over the internet. For example, if you’re building a travel app, you might use the Google Maps API to show locations or the Skyscanner API to fetch flight prices. These APIs let you access features or data that you don’t have to build yourself, saving you time and resources. They’re widely used in software development because they allow you to add complex functionality—like payment processing, geolocation, or social media integration—without starting from scratch.

But while external APIs are convenient, they introduce risks because you’re relying on a service you don’t control. If the API provider changes their service, goes down, or has security issues, your app could suffer. Understanding these risks can help you plan better and protect your project from unexpected problems. Let’s break down the main risks of using external APIs and how they might affect your work.

Risk 1: Downtime and Reliability Issues

One of the biggest risks with external APIs is downtime. Since you’re relying on a third-party service, if their servers go down, your app might stop working properly. For example, if your e-commerce app uses a payment API like PayPal, and PayPal’s servers are down, your customers won’t be able to check out. This can lead to lost sales and frustrated users.

Downtime can happen for many reasons—server outages, maintenance, or even cyberattacks on the API provider. In 2023, a major outage at Twilio, a popular communication API provider, disrupted thousands of apps that relied on its SMS and voice services. If your app depends heavily on an external API, you’re at the mercy of their reliability. Even APIs from big companies like Google or AWS can experience outages, though they’re usually rare.

To mitigate this risk, check the API provider’s uptime history—many publish their service-level agreements (SLAs) promising a certain percentage of uptime, like 99.9%. You can also build fallback options into your app. For instance, if a weather API fails, you might show cached data or a message explaining the issue to users. Planning for downtime ensures your app stays functional even when the API doesn’t.

Risk 2: Security and Privacy Concerns

Security is a major concern when using external APIs, as you’re sharing data with a third-party service. If the API provider has weak security practices, your app—and your users—could be at risk. For example, if you’re using an API to process user logins, and the API gets hacked, attackers might steal sensitive data like email addresses or passwords. In 2024, a data breach at a popular marketing API exposed user data for thousands of apps, highlighting how API vulnerabilities can ripple outward.

Another issue is privacy compliance. If your app handles user data, you need to follow laws like GDPR (in Europe) or CCPA (in California). But if the API provider doesn’t comply with these regulations, you could be held responsible for any violations. For instance, if a third-party analytics API collects user data without proper consent, your app might face fines or legal trouble.

To reduce security risks, choose API providers with strong security practices—look for HTTPS encryption, regular security audits, and compliance certifications like ISO 27001. Also, limit the data you share with the API to only what’s necessary. For example, if you’re using a mapping API, don’t send user info that isn’t needed for the map feature. Finally, use API keys or OAuth for authentication to ensure only authorized requests are made, and monitor your API usage for unusual activity.

Risk 3: Unexpected Changes or Deprecation

External APIs can change without warning, which can break your app. API providers might update their endpoints, change how data is formatted, or even shut down the API entirely—a process called deprecation. For example, in 2022, Google deprecated its older Hangouts API, forcing developers to migrate to a new version or find alternatives. If your app isn’t prepared for these changes, it could stop working overnight.

Even small changes can cause big problems. If a weather API you’re using changes its response format from JSON to XML, your app might not be able to parse the data correctly, leading to errors. These updates often come with little notice, especially from smaller providers who may not prioritize developer communication.

To manage this risk, keep an eye on the API provider’s changelog or developer blog for updates. Many providers, like Stripe or Twitter, have email notifications for API changes. You can also version your API calls—most providers offer versioned endpoints (e.g., /v1/endpoint) to ensure stability. Finally, have a backup plan, like switching to a different API or building a workaround, in case the API gets deprecated.

Risk 4: Performance and Latency Issues

Using an external API can slow down your app if the API’s performance isn’t up to par. Every API call involves sending a request over the internet, waiting for a response, and processing the data. If the API is slow, your app will be too. For example, if you’re using a geolocation API to show a user’s location on a map, and the API takes 5 seconds to respond, your users will have to wait, which can hurt their experience.

Latency can also vary depending on the API provider’s server location. If your app’s users are in Europe, but the API’s servers are in the US, the distance can add delays. High traffic on the API provider’s end can also cause slowdowns—think of a payment API struggling during a Black Friday sale.

To minimize performance risks, test the API’s speed during development using tools like Postman or curl to measure response times. Choose providers with servers close to your user base, or use a content delivery network (CDN) to cache API responses. You can also implement caching on your end—store frequently used API data locally so you don’t need to call the API every time. For example, if your app shows weather data, cache the data for an hour to reduce API calls.

Risk 5: Cost Overruns and Rate Limits

Many external APIs aren’t free, and costs can add up quickly if you’re not careful. Most APIs use a pricing model based on usage, like charging per API call or offering a tiered subscription. For instance, the Google Maps API charges based on the number of map loads or geocoding requests. If your app suddenly gets more users, your API usage—and your bill—could spike unexpectedly.

Rate limits are another issue. APIs often cap how many requests you can make in a given time—like 1,000 calls per hour. If you exceed this limit, the API will block your requests, causing your app to fail. For example, if you’re using a social media API to pull tweets, and your app goes viral, you might hit the rate limit and lose access to the API temporarily.

To avoid cost overruns, monitor your API usage closely using dashboards provided by the API provider, like AWS’s billing console or Stripe’s usage tracker. Set budget alerts to warn you if costs get too high, and optimize your app to make fewer API calls—caching and batching requests can help. For rate limits, design your app to handle them gracefully, like showing an error message to users or queuing requests to stay within the limit.

Risk 6: Dependency and Vendor Lock-In

When you use an external API, you become dependent on the provider, which can lead to vendor lock-in. This means your app is tied to their service, making it hard to switch to another provider if needed. For example, if you build your app around the Twilio API for SMS, and Twilio raises prices or shuts down, you’ll need to rewrite parts of your app to use a different API, which takes time and effort.

Vendor lock-in can also limit your flexibility. If the API provider doesn’t support a new feature you need, you’re stuck until they add it—or you’ll have to find a new provider and migrate. This dependency can slow down your development and make your app less adaptable to changes.

To reduce dependency, design your app with flexibility in mind. Use abstraction layers—like a custom wrapper around the API—so you can swap out providers without rewriting everything. For example, if you’re using a payment API, create a generic payment module in your app that can work with Stripe, PayPal, or another provider with minimal changes. Also, choose APIs with open standards or wide adoption, as they’re less likely to disappear suddenly.

Tips to Mitigate Risks When Using External APIs

Here are some practical tips to stay safe when using external APIs in your projects:

  • Research the Provider: Before choosing an API, check their reputation, uptime history, and security practices. Look for reviews from other developers on forums like Stack Overflow or Reddit to see if they’ve had issues.
  • Test Thoroughly: Test the API during development to understand its performance, reliability, and error handling. Use tools like Postman to simulate API calls and see how the API behaves under different conditions.
  • Monitor Usage: Keep an eye on your API usage with tools like the provider’s dashboard or third-party monitoring services. Set alerts for rate limits, costs, and unusual activity to catch problems early.
  • Plan for Failures: Build fallbacks into your app, like caching data or showing error messages, so it can handle API downtime or rate limits without crashing.
  • Document Everything: Keep detailed documentation of how you’re using the API, including endpoints, authentication methods, and fallback plans. This makes it easier to troubleshoot issues or switch providers later.
  • Stay Updated: Follow the API provider’s updates via their blog, changelog, or email notifications. This helps you prepare for changes or deprecations before they affect your app.

By following these tips, you can use external APIs confidently, knowing you’ve planned for potential risks and can handle them if they arise.

A Real-World Example of API Risks

Let’s look at an example to see these risks in action. Imagine you’re building a fitness app that uses the Fitbit API to pull users’ step counts. One day, Fitbit’s servers go down (downtime risk), and your app can’t show step data, frustrating users. Later, Fitbit gets hacked (security risk), exposing user data and putting your app at risk of legal issues. Then, Fitbit updates its API, changing the data format (change risk), and your app breaks because it can’t parse the new format. Meanwhile, your app’s user base grows, hitting Fitbit’s rate limit (cost/rate limit risk), and you’re charged extra fees. Finally, Fitbit raises prices, but you’re locked into their service (dependency risk), forcing you to either pay more or rewrite your app for another API. This scenario shows how API risks can pile up, but with proper planning—like caching data, monitoring usage, and using abstraction layers—you can avoid these pitfalls. (Fitbit was just an example - I don't imply that this happens to Fitbit).

Final Thoughts on Using External APIs Safely

External APIs are a game-changer for developers, letting you add powerful features to your app without building everything from scratch. But they come with risks like downtime, security issues, unexpected changes, performance problems, cost overruns, and dependency. By understanding these risks and taking steps to mitigate them—researching providers, testing thoroughly, monitoring usage, and planning for failures—you can use APIs safely and effectively. Whether you’re building a small app or a large-scale system, being aware of these risks will help you create more reliable, secure, and cost-effective applications. So, the next time you integrate an external API, take a moment to plan ahead—it’ll save you a lot of headaches down the road!

Resources for Further Learning

Want to learn more about using external APIs safely and managing their risks? Check out these helpful resources:

Books on Amazon:

APIs: A Strategy Guide by Daniel Jacobson, Greg Brail, and Dan Woods (Buy book - Affiliate link) – A great book on API design and management, including risk mitigation.

Designing Web APIs by Brenda Jin, Saurabh Sahni, and Amir Shevat (Buy book - Affiliate link) – Covers best practices for working with APIs, with a focus on security and reliability.

RESTful API Design by Matthias Biehl (Buy book - Affiliate link) – Explores API design principles and how to handle risks like changes and deprecation.

YouTube Videos:

Top 12 Tips For API Security



Understanding The Fundamentals of API Security | How APIs are Attacked and How to Secure Them



Unmanaged APIs are hurting your productivity and security. Start managing your sprawl with API Hub



Thursday, June 5, 2025

Understanding API Specifications: A Practical Guide for Developers

APIs, or Application Programming Interfaces, have become essential tools in modern software development. They enable different applications and systems to communicate with each other effectively. But behind every robust API lies a well-defined API specification. If you're new to development or just brushing up on the fundamentals, understanding API specifications is a crucial skill. This guide will try and take you through the core concepts, structure, types, benefits, and real-world examples of API specifications.


What Are API Specifications?

API specifications are structured, formal descriptions that define how an API behaves. They serve as a blueprint, detailing available endpoints, data types, request methods, responses, authentication, error messages, and more.

In simpler terms, if an API is a restaurant, the API specification is the menu. It tells you what you can order (endpoints), how to ask for it (methods and parameters), and what you'll get in return (response format).


Why Are API Specifications Important?

  1. Consistency: They ensure all developers interacting with the API do so in a standardized way.

  2. Automation: Enable tools for auto-generating documentation, SDKs, and client libraries.

  3. Testing & Validation: Provide structure for creating automated tests.

  4. Improved Collaboration: Help frontend, backend, and QA teams align better.

  5. Clear Contracts: Define expectations between producers and consumers of the API.


Key Components of an API Specification

  • Base URL: The root address of the API (e.g., https://api.example.com)

  • Endpoints: Specific paths to access resources (e.g., /users, /orders)

  • HTTP Methods: Actions like GET, POST, PUT, DELETE

  • Request Parameters: Query strings, path variables, headers, and bodies

  • Response Codes: Status indicators like 200 (OK), 404 (Not Found), 500 (Server Error)

  • Request/Response Body: Defines structure of data sent or received, often in JSON or XML

  • Authentication: Details of OAuth, API keys, tokens, etc.

  • Error Messages: Descriptions of why something went wrong and how to fix it


Popular API Specification Standards

1. OpenAPI (formerly Swagger)

  • JSON/YAML format

  • Human and machine-readable

  • Can be used to auto-generate documentation and code

  • Widely adopted in RESTful APIs

2. RAML (RESTful API Modeling Language)

  • YAML-based

  • Encourages design-first approach

  • Good for reuse of components

3. API Blueprint

  • Markdown-based

  • Easy to write and understand

  • Ideal for API-first development

4. GraphQL Schema Definitions

  • For GraphQL APIs

  • Focuses on defining types, queries, mutations, and subscriptions


Writing Your First API Specification (OpenAPI Example)

openapi: 3.0.0
info:
  title: User Management API
  version: 1.0.0
paths:
  /users:
    get:
      summary: List all users
      responses:
        '200':
          description: A list of users
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                    name:
                      type: string

This snippet outlines an API that fetches a list of users with ID and name properties.


Tools for API Specification and Development

  • Swagger Editor: Live editor for writing OpenAPI specifications

  • Postman: API testing and collaboration platform

  • Stoplight Studio: Visual editor for OpenAPI

  • Redoc: Tool to generate documentation from OpenAPI

  • Insomnia: REST and GraphQL API client


Best Practices

  • Use consistent naming conventions (camelCase, snake_case)

  • Group related endpoints logically

  • Always include status codes and error messages

  • Version your APIs (e.g., /v1/users)

  • Keep documentation up to date


Real-World Use Cases

  • E-commerce: APIs for handling products, orders, and payments.

  • Fintech: Secure APIs for transactions, accounts, and KYC checks.

  • Healthcare: Interoperable APIs for patient records (FHIR standard).

  • Travel: Booking, itinerary, and fare APIs.


Challenges in API Specification

  • Balancing simplicity and completeness

  • Keeping documentation and spec in sync

  • Backward compatibility

  • Handling versioning and deprecation


Final Thoughts

API specifications aren't just documentation – they're the foundation of reliable, scalable, and maintainable systems. Whether you're building a REST or GraphQL API, taking time to define a clear and structured API specification will save countless hours of confusion, debugging, and miscommunication.

Recommended Reading on Amazon

Designing Web APIs by Brenda Jin (Buy book - Affiliate link)

API Design Patterns by JJ Geewax (Buy book - Affiliate link


Wednesday, May 29, 2013

Explain the various File Access methods?

One of the most important functions of the mainframe operating system is the access methods that make it possible for you to access the data from external devices such as the tape or disk. 

What are access methods?

- Access methods are very useful in providing an API for transferring the data from one device to another.
- Another best thing about this API was that it worked as the device driver for the operating systems on non-mainframe computers. 
- There have been a lot of reasons behind the introduction of the access methods. 
- A special program had to be written for the I/O channel and there has to be a processor entirely dedicated to controlling the access to the peripheral storage device as well as data transfer from and to the physical memory. 
- Special instructions constitute these channel programs and are known as the CCWs or the channel command words.
- To write such programs, very detailed knowledge is required regarding the characteristics of the hardware. 

Benefits of File Access Methods

There are 3 major benefits of the file access methods:
Ø  Ease of programming: The programmer does not have to deal with the procedures of the specific devices, recovery tactics and error detection. A program designed to process a particular thing will do it no matter where the data has been stored.
Ø  Ease of hardware replacement: A program cannot be altered by the programmer during the migration of data from older to newer model of the storage device provided the same access methods are supported by the new model.
Ø  Ease in sharing the data set access: The access methods can be trusted for managing the multiple accesses to the same file. At the same it ensures the security of the system and data integrity.

Some File/Storage Access Methods

Ø  Basic direct access method (BDAM)
Ø  Basic sequential access method (BSAM)
Ø  Queued sequential access method (QSAM)
Ø  Basic partitioned access method (BPAM)
Ø  Indexed sequential access method (ISAM)
Ø  Virtual storage access method (VSAM)
Ø  OAM (object access method)

- For dealing with the records of a data set both the types of access i.e., the queued and the basic are suitable. 
- The queued access methods are an improvement of the basic file access methods. 
- Read ahead scheme and internal blocking of data is well supported by these methods. 
- This allowed combining the multiple records in to one unit, thus increasing the performance. 
- In sequential methods, it is assumed that there’s only a sequential way for processing the records which is just the opposite of the direct access methods. 
There are devices like the magnetic tape that only enforce the sequential access 
- Sequential access can be used for writing a data set and then later the direct manner can be used for processing it.

Today we have access methods that are network-oriented such as the following:
Ø  Basic telecommunications access method or BTAM
Ø  Queued tele – processing access method or QTAM
Ø  Telecommunications access method or TCAM
Ø  Virtual telecommunications access method or VTAM

The term access method was used by the IMS or the IBM information management system for referring to the methods for manipulation of the database records. 
- The access methods used by them are:
Ø  GSAM or generalized sequential access method
Ø  HDAM or hierarchical direct access method
Ø  HIDAM or hierarchical indexed direct access method
Ø  HISAM or hierarchical indexed sequential access method
Ø  HSAM or hierarchical sequential access method
Ø  PHDAM or partitioned hierarchical direct access method
Ø  PHIDAM or partitioned hierarchical indexed direct access



Saturday, February 2, 2013

Explain Robot Framework?


The Robot Framework was developed as generic test automation framework for two major tasks namely:
  1. Acceptance testing and
  2. ATDD or acceptance test driven development
- It makes use of the keyword driven testing approach for achieving the above mentioned two tasks. 
- It has got a very simple and unique tabular test data syntax that is quite easy to follow and this is what that makes robot framework so easy to be used. 
- All this makes the robot framework popular among the testers.
- Test libraries that can be implemented through either java or python can be used for extending the capabilities of the frame work. 
- The users have the choice of creating new keywords from the existing ones. 
This can be done using the same syntax that is available for the creation of the test cases. 
- Robot framework is actually an open source software. 
- The license it possesses is the Apache license 2.0.
- The Nokia Siemens Networks supports the development of this framework and also owns its copyrights. 

Features of Robot Framework

The robot test automation framework is abundant of features. Its features are:
  1. Its tabular syntax is easy to use and can be used for the creation of the test cases in a way that is uniform.
  2. Robot framework can work up on three approaches namely:
- Keyword driven testing approach
- Behavior driven development approach or BDD
- Data driven testing approach or DDT.
  1. It provides the facility for the creation of higher level keywords that are reusable for the already existing keywords.
  2. The reports and logs it generates are quite easy to follow and are based up on HTML.
  3. This test automation framework does not depend up on any platform or application.
  4. The architecture of the frame work is quite modular in nature that helps in supporting the creation of the tests for even the software systems and applications that possess a number of interfaces all different from one another.
  5. It comes with a library API that is quite simple and can be further used for the creation of other test libraries that can be customized.
  6. The XML based outputs that the framework provides allow for integrating itself in to the build infrastructure that already exists. These are called continuous integration systems.
  7. It also provides a command line interface for the same purpose as that of the XML based outputs.
  8. It supports selenium tool for the following things:
Ø  Web testing
Ø  Java GUI testing
Ø  telnet
Ø  running processes
Ø  SSH and so on.
  1. The framework comes with a remote library interface, thus enabling the implementation of the test libraries in any desired programming language and distributed testing.
  2. The tagging feature provides helps in categorizing the tests and selecting them accordingly for the execution.
  3. For variables, it comes with a special built – in support for regulating testing in different environments.
- Test cases can be written either in HTML or in plain text.
- Also, any editor can be used for editing the test cases. 
- The robot test automation framework comes with a graphical development tool called the RIDE or robot IDE. 
- The tool has got a number of features specific to the framework such as syntax highlighting, code completion and so on. 
- Selenium library is an extension to the robot test automation frame work and similarly there are a number of others. 
- However, there are some other languages that can be used for implementing the libraries such as perl, PHP, java script and so on. 
- However, these languages can be used only through a remote library interface.


Thursday, October 18, 2012

What is the Document Object Model (DOM) browser extension?


In this article we shall talk about the DOM browser extension of the silk test. But before coming to this topic we shall discuss a little about the DOM or the document object model. 

What is Document Object Model (DOM)?

- There was a need for a language and cross platform independent convention for the representation and interaction with the objects consisted in XHTML, HTML, XML etc documents. 
- Out of this need, only document object model was born. 
- Certain object methods are used for addressing as well as manipulating the objects present in the DOM tree.
- It is in the API or application programming interface where the public interface of the document object model is specified. 
- For rendering any of the documents mentioned above, an internal model quite similar to the document object model is used by most of the web browsers. 
- The nodes of all the documents are organized in a tree like structure which is commonly known as the DOM tree. 
- The top most node of this tree is termed as the document object.
- The HTML is downloaded in to the local memory and is parsed whenever a document is rendered in a browser. 
- Parsing is done using the DOM for the construction of the internal data structures that are employed for displaying the page in the browser window. 
DOM’s application programming interface is also used by the java script for the inspection and modification of a web page. 

Use of DOM Browser Extension in SilkTest

- It acts as an add – on component that helps a big deal in the testing of the web applications. 
- A direct communication with the web browser is established by the DOM browser extension so that the recognition, categorization and manipulation of the objects on a web page can be made possible. 
- This direct communication with the web browser is established by the DOM browser extension.
- It is done by actually working with the HTML code rather than making use of the visual pattern recognition as relied on by the other such extensions or add ins. 
- The technique of visual pattern recognition is usually used by the virtual object browser extension. 
- The DOM browser extension identifies an object in a web application through the following steps:
  1. The web browser window in which the application is current executing is identified.
  2. Then the web UI object is identified that is based up on the HTML element representing the UI object.
- The whole identification of a UI web application object is possible only with the concatenation of the HTML element identification and the browser window identification.
- This document object model of the silk test makes use of the DOM standard stated by the W#C or World Wide Web consortium. 
- However, this DOM standard is currently supported by two web browsers namely Netscape 6 and internet explorer 5+ versions. 
- These two web browsers allow the external applications such as the silk test for making direct queries to the browser for obtaining information regarding the web page that is currently being displayed. 
- When the DOM browser extension is enabled on the host machine, an extension file is included so that the extension classes are made available to the user. 
- The silk test always makes sure that the extension classes are always visible in the library browser. 
- This is done so by addition of the of the help file of the extension (browser.ht) to the help files. 
- The properties defined for the DOM browser extension are merged with the default property sets which include the following:
  1. Color
  2. Font
  3. Values and
  4. Location


Saturday, December 31, 2011

What is application programming interface testing?

An application programming interface or API as it is known by its abbreviated form can be defined as a specification based on source code. Typically application programming interface is intended to be used as an interface in the software components in order to communicate with each other. An application programming interface includes specifications and requirements basically for required data structures, routines, variables, and object classes.

The requirements and specifications of application programming interface can take many forms such as POSIX which is an international standard or Microsoft windows API which is vendor documentation or standard template library or STL (in java AP or C++) which is the library of the programming languages.

Application programming interface and application binary interface are in great contrast to each other. The basic difference is that the application programming interface is based on source whereas the application binary interface is a binary interface. The best example is given by POSIX and Linux standard base. The POSIX is an application programming interface, whereas the Linux standard base in an application binary interface.

An application programming interface has got any features.
- It is language dependent. It means that the application programming interfaces is only available by using the elements and syntax of a particular programming language. This feature makes the application programming interface more easy and convenient to use.

- An application programming interface can also be independent of language. This feature helps in calling the application programming interface from several programming languages. This is the most desirable feature for an application programming interface that is service oriented. Such an API is not bound to specific system or process. It may be provided as a web service or remote procedure calls.

- Sometimes the term “application programming interface” is used to refer to a complete programming interface, a set of APIs that have been provided by an organization or a single function. Therefore, the scope of the meaning of an API is usually determined according to its usage.

- In some cases an application programming testing may describe the way in which a task is performed. An action is usually meditated by a function call in procedural programming languages like C. hence; here API usually describes all the functions and routines provided.

- Other times the application programming interface can be interpreted as a collection of the files included by the C language and its readable descriptions.

- There are various programs development environments that provide the documentations associated with an application programming interface in digital format. Example of such language is Perl which comes with a tool perldoc.

When it comes to object oriented languages, application programming interface provides a description of definitions and behaviors associated with a set of class.

- An application programming interface generally prescribes the methods using which one can interact or handle the class derived objects.
- An application programming interface is closely related to a software library.
- Library is the actual implementation of the rules that are set by the application programming interface.
- Like other this API factor also needs to be tested. For this, API testing is employed.
- API testing is somewhat different from other types testing since GUI is rarely involved in it. for API testing, one needs to set up the testing environment and invoke the API with its respective parameters and then analyze the result.
- The problems come while setting up the environment as the GUI is not involved. For cases that don’t return anything one needs to have some mechanism to check the API’s behavior.

There are 3 main challenges faced by API testing:
- Parameter combination
- Parameter selection
- Call sequence


Tuesday, November 30, 2010

What are different kind of application programming interface testing tools?

There are many testing tools available. Depending on the level of testing required, different tools could be used. Some of the API testing tools available are:

- JVerify: This is from Man Machine Systems. JVerify is a java class/API testing tool that supports a unique invasive testing model. The invasive model allows access to the internals of any Java object from within a test script. The ability to invade class internals facilitates more effective testing at class level, since controllability and observability are enhanced. This can be very valuable when a class has not been designed for testability.

- JavaSpec: JavaSpec is a SunTest's API testing tool. It can be used to test java applications and libraries through their API. JavaSpec guides the users through the entire test creation process and lets them focus on the most critical aspects of testing. Once the user has entered the test data and assertions, JavaSpec automatically generates self-checking tests, HTML, test documentation, and detailed test reports.

To automate API testing, the assumptions are as follows:
- Test engineer is supposed to test some API.
- The APIs are available in form of library(.lib).
- Test engineer has the API document.

There are mainly two things to test in API testing:
Black box testing of the APIs :
In this, we have to test the API for outputs. When we give a known input then we also know the ideal output. So, we have to check for the actual output against the idle output.
A simple program in C can be written as:
- Take the parameters from text file.
- Call the API with these parameters.
- Match the actual and idle output and also check the parameters for good values that are passed with reference.
- Log the result.

Interaction/ integration testing of the APIs.
Suppose there are teo APIs say
Handle h = handle createcontext(void);
When the handle to the device is to be closed then the corresponding function
Bool bishandledeleted = bool deletecontext(handle &h);

Here, we have to call the two APIs and check if they are handled by the created createcontext() and are deleted by the deletecontext().
This will ensure that these two APIs are working fine.For this we can write a simple C program that will do the following:
- Call the two APIs in the same order.
- Pass the output parameter of the first as the input of the second.
- Check for the output parameter of the second API.
- Log the result.


Monday, November 29, 2010

Step 4 To test API : Call Sequencing, Step 5 To Test API : Observe the output

Step 4: Call Sequencing
When combinations of possible arguments to each individual call are unmanageable, the number of possible call sequences is infinite. Parameter selection and combination issues further complicate the problem call-sequencing problem. Faults caused by improper call sequences tend to give rise to some of the most dangerous problems in software. Most security vulnerabilities are caused by the execution of some such seemingly improbable sequences.

Step 5: Observe the output
The outcome of an execution of an API depends upon the behavior of that API, the test condition and the environment. The outcome of an API can be at different ways i.e. some could generally return certain data or status but for some of the APIs. It might not return or shall be just waiting for a period of time, triggering another event, modifying certain resource and so on.

The tester should be aware of the output that needs to be expected for the API under test. The outputs returned for various input values like valid/invalid, boundary values etc needs to be observed and analyzed to validate if they are as per the functionality. All the error codes returned and exceptions returned for all the input combinations should be evaluated.


Friday, November 26, 2010

Step 3 To test API : Identify the combination of parameters

Identify the combination of parameters
Parameter combinations are extremely important for exercising stored data and computation. In API calls, two independently valid values might cause a fault when used together which might not have occurred with the other combinational values. Therefore, a routine called with two parameters requires selection of values for one based on the value chosen for the other. Often the response of a routine to certain data combinations is incorrectly programmed due to the underlying complex logic.

The API needs to be tested taking into consideration the combination of different parameter. The number of possible combinations of parameters for each call is typically large. For a given set of parameters, if only the boundary values have been selected, the number of combinations, while relatively diminished, may still be prohibitively large. For example, consider an API which takes three parameters as input. The various combinations of different values for the input values and their combinations needs to be identified.

Parameter combination is further complicated by the function overloading capabilities of many modern programming languages. It is important to isolate the differences between such functions and take into account that their use is context driven. The APIs can also be tested to check that there are no memory leaks after they are called. this can be verified by continuously calling the API and observing the memory utilization.


Thursday, November 25, 2010

Step 1 and Step 2 To test API : Identify the initial condition and Input/Parameter Selection

STEP 1: Identify the initial condition
The testing of an application programming interface (API) would depend largely on the environment in which it is to be tested. Hence, initial condition plays a very vital role in understanding and verifying the behavior of the API under test. the initial conditions for testing APIs can be classified as:

- Mandatory Pre-setters
The execution of an API would require some minimal state, environment. These type of initial conditions are classified under the mandatory initialization for the API. For example, a non-static member function API requires an object to be created before it could be called. This is an essential activity required for invoking the API.

- Behavioral Pre-setters
To test the specific behavior of the API, some additional environmental state is required. These types of initial conditions are called the behavioral pre-setters category of initial condition. These are optional conditions required by the API and need to be set before invoking the API under test thus influencing its behavior. Since these influence the behavior of the API under test, they are considered as additional inputs other than the parameters.

Thus, to test any application programming interface, the environment required should also be clearly understood and set up. Without these criteria, API under test might not function as required and leave the tester's job undone.

STEP 2: Input/Parameter Selection
the list of valid input parameters need to be identified to verify that the interface actually performs the tasks that it was designed for. While there is no method that ensures this behavior will be tested completely, using inputs that return quantifiable and verifiable results is the next big thing. The techniques like boundary value analysis and equivalence partitioning need to be used while trying to consider the input parameter values. The boundary values or limits that would lead to errors or exceptions needs to be identified.

It would also be helpful if the data structures and other components that use these data structures apart from the API are analyzed. The data structure can be loaded by using the other components and the API can be tested while the other component is accessing these data structures.

The availability of the source code to the testers would help in analyzing the various input values that could be possible for testing the API. It would also help in understanding the various paths which could be tested. Therefore, not only are testers required to understand the calls, but also all the constants and data types used by the interface.


Wednesday, November 24, 2010

What is the strategy that is needed to test an API?

By analyzing the problems faced by the testers, a strategy needs to be formulated for testing the application programming interface.
- The API to be tested would require some environment for it to work. Hence, it is required that all the conditions and prerequisites understood by the tester.
- The next step would be to identify and study its points of entry. The graphical user interfaces would have items like menus, buttons, check boxes, and combo lists that would trigger the event or action to be taken.
- Similarly, for APIs, the input parameters, the events that trigger the API would act as the point of entry. Subsequently, a chief task is to analyse the points of entry as well as significant output items. The input parameters should be tested with the valid and invalid values using strategies like the boundary value analysis and equivalence partitioning.
- The fourth step is to understand the purpose of the routines, the contexts in which they are to be used. Once all this parameter selections and combinations are designed, different call sequences need to be explored.

The steps can be summarized as follows:
- Identify the initial conditions required for testing.
- Identify the parameters i.e. choosing the values of individual parameters.
- Identify the combination of parameters i.e. pick out the possible and applicable parameter combination with multiple parameters.
- Identify the order to make the calls i.e. deciding the order in which to make the calls to force the API to exhibit its functionality.
- Observe the output.


How can the testing of API calls be done?

Testing of API calls can be done in isolation or in sequence to vary the order in which the functionality is exercised and to make the API produce some useful results from these tests. Designing tests is essentially designing sequences of API calls that have a potential of satisfying the test objectives.This in turn boils down to designing each call with specific parameters and to building a mechanism for handling and evaluating return values.
Designing of test cases depends on the following criteria:
- What value should a parameter take?
- What values together make sense?
- What combination of parameters will make APIs work in a desired manner?
- What combination will cause a failure, a bad return value, or an anomaly in the operating environment?
- Which sequences are the best candidates for selection?

Some of the interesting problems for testers are:
- Ensuring that the test harness varies parameters of the API calls in ways that verify functionality and expose failures. This includes assigning common parameter values as well as exploring boundary conditions.
- Generating interesting parameter value combinations for calls with two or more parameters.
- Determining the content under which an API call is made. This might include setting external environment conditions like files, peripheral devices and also the internal stored data that affect the API.
- Sequencing API calls to vary the order in which the functionality is exercised and to make the API produce useful results from successive calls.


Tuesday, November 23, 2010

Understanding Application Programming Interfaces(APIs)

Application Programmable Interfaces (APIs) are collections of software functions or procedures that can be used by other applications to fulfill their functionality. APIs provide an interface to the software component.These form the critical elements for the developing the applications and are used in varied applications from graph drawing packages, to speech engines, to web-based airline reservations systems, to computer security components.

Each API is supposed to behave the way it is coded i.e. it is functionality specific. These APIs may offer different results for different type of the input provided. The errors or the exceptions returned may also vary. However, once integrated within a product, the common functionality testing/integration testing may cover only those paths. By considering each API as a black box, a generalized approach of testing can be applied. But, there may be some paths which are not tested and lead to bugs in the application. Applications can be viewed and treated as APIs from a testing perspective.

The distinctive attributes that make testing of APIs slightly different from testing other common software interfaces like GUI testing.
- Testing APIs requires a thorough knowledge of its inner workings: Some APIs may interact with the operating system kernel, other APIs, with other software to offer their functionality. Thus, an understanding of the inner workings of the interface would help in analyzing the call sequences and detecting the failures caused.
- Adequate programming skills: API tests are in form of sequences of calls, namely, programs.Each tester must possess expertise in the programming language that are targeted by the API.
- Lack of domain knowledge: Involve the testers from the initial stage of development. This would help the testers to have some understanding on the interface and avoid exploring while testing.
- No documentation: Without the documentation, it is difficult for the test designer to understand the purpose of calls, the parameter types and possible valid/invalid values, their return values, the calls it makes to other functions and usage scenarios. Hence, proper documentation would help test designer design the tests faster.
- Access to source code: The availability of the source code would help tester to understand and analyze the implementation mechanism used; and can identify the loops or vulnerabilities that may cause errors.
- Time constraints: Thorough testing of APIs is time consuming, requires a learning overhead and resources to develop tools and design tests.


Facebook activity