All you need to know about API's

All you need to know about API's

If you are just starting off with API's and using it in your projects, this article is well worth your time to read and bookmark.

What is an APIs

Application Programming Interfaces (APIs) are constructs made available in programming languages to allow developers to create complex functionality more easily. They abstract more complex code away from you, providing some easier syntax to use in its place. As a real-world example, think about the electricity supply in your house, apartment or other dwellings. If you want to use an appliance in your home, you plug it into an outlet and it works. You're not trying to plug it directly into a power source — that would be really inefficient and, unless you're an electrician, difficult and dangerous.

How does an API work

APIs unlock the door to software in a way that is programmatically controlled and secure. Code can then be entered to send requests to the receiving software and the data can be returned.

A clear example of this in action is the Google Maps API. Users must first register to receive an API key - once obtained, websites can retrieve information from Google Maps.

There is a predefined list of requests that the user can enter. In the Google Maps example below, the origin is listed on the left and entered in the URL on the right. Once you enter this on a web page (or type it into a web browser), Google can process the request and return the desired values ​​- in this case, driving directions from Vancouver to San Francisco.

Types of API's

  1. Private APIs These APIs are designed for improving solutions and services within an organization. These APIs are accessible only by the developers who work in the organization. These developers may use these APIs to integrate an organization’s IT systems or applications or create a new system using existing resources. The use of private APIs enables an organization to have total control over how the API is used.

  2. Partner APIs These APIs are used by business partners who have reached an agreement with the publisher. Software integration between two parties is a common use case. A company offers its partners access to data or functions to accomplish their tasks.

  3. Public APIs These are external APIs. They are available for third-party developers. These Public APIs can be Free and Commercial. Commercial API users must pay an amount to use the APIs.

Types of Web API Architectures and Protocols

•REST(Representational State Transfer): is a sought after web API architecture.To be a REST API,an API must adhere to certain architectural constraints,like Client-Server Architecture,Statelessness,Cacheability,Layered System,etc. These are primarily used to access and work with data,and require minimum bandwidth.It supports multiple formats such as JSON,XML,HTML,YAML and plain text.

•SOAP(simple object access protocol):isawell established web API protocol,which uses XML as the message format to transfer data.Its main function is to define the structure of the messages and methods of communication.These are driven by functionality rather than data and require more bandwidth than REST architecture.It supports only one message format-XML.

•JSON and XML RPC:An RPC is a remote procedural call protocol.They are the simplest and oldest types of APIs.The RPC was developed for the client to execute code ona server.JSON-RPC used JSON to encode its calls,while XML-RPC used XML for the encoding.

Needs & Uses of API

  1. Weather Snippets: One common API usage example we come across on a daily basis is weather data. Rich weather snippets seem to be commonplace, found on all platforms, like Google Search, Apple’s Weather app, or even from your smart home device. For example, if you search “weather + [your city’s name]” on Google, you’ll see a dedicated box at the top of the search results (called a rich snippet) with the current weather conditions and forecast.
  2. Log-in Using XYZ: Another prominent example of API usage is the “log-in using Facebook/Twitter/Google/Github” functionality you see on so many websites. It’s incredibly convenient, but have you ever wondered how it works? Instead of actually logging-in to users’ social media accounts (which would pose a serious security concern), applications with this functionality leverage these platforms’ APIs to authenticate the user with each login.
  3. Twitter Bots: Another example of APIs at work is the huge range of bots on Twitter. Twitter bots are accounts that automatically tweet (or retweet), follow, and send direct messages based on software instructions.
  4. Travel Booking: Ever wondered how travel booking sites are able to aggregate thousands of flights and destinations and showcase the cheapest option? Often, the answer is by using third-party APIs to collect flight and hotel availabilities from providers. Likewise, if you make a booking through one of these services, they’ll use APIs to confirm the trip with the provider they sourced it from.

What is API testing?

API testing is a software testing practice that tests the APIs directly — from their functionality, reliability, performance, to security. Part of integration testing, API testing effectively validates the logic of the build architecture within a short amount of time.

Benefits of API testing

- Language-independent Data is exchanged via XML and JSON formats, so any language can be used for test automation. XML and JSON are typically structured data, making the verification fast and stable. There are also built-in libraries to support comparing data using these data formats.

- GUI-independent API testing can be performed in the app prior to GUI testing. Early testing means early feedback and better team productivity. The app's core functionalities can be tested to expose small errors and to evaluate the build's strengths.

- Improved test coverage Most API/web services have specifications, allowing you to create automated tests with high coverage — including functional testing and non-functional testing.

- Faster releases It is common that executing API testing saves up to eight hours compared to UI testing, allowing software development teams to release products faster.

These are some API Testing tools where you can test your API:

  1. Postman
  2. Katalon Platform
  3. Tricentis
  4. REST-assured
  5. Apache JMeter
  6. Assertible
  7. Karate DSL
  8. Swagger
  9. ACCELQ
  10. Keploy

You can read more about in this thread: Link

Why Keploy ?

Keploy provides a simple and intuitive way for developers to test their APIs quickly and effectively. Test cases can be generated quickly with just a few lines of code and without any programming knowledge required, which means you can get started right away without a complicated setup process or extensive training. In addition, you can automate the process of generating test cases and running automated tests across multiple devices.

How does Keploy work?

Keploy is a no-code testing platform that generates tests from API calls. It converts API calls into test cases, and mocks are automatically generated with the actual request/responses. The system captures all the API calls and subsequent network traffic served by the application. You can use any existing API management tools to generate test-case.

Keploy automatically mocks network/external dependencies for all CRUD operations with correct responses; you don't need to manually create mocks for these services anymore. Now you'll not require data dumps or mocks for dependencies like DBs, internal services, or third-party services; everything just works out of the box! With Keploy you can safely replay writes or mutations by capturing them from local or other environments. Multiple Reads after write operations can be replicated automatically too!

Conclusion

APIs are everywhere, and it only takes picking up your smartphone to see them in action. Whether it’s searching for the weather on Google, logging-in with Facebook, paying with PayPal, or interacting with a Twitter bot, all of these things are powered by APIs. To boot, there’s a lot more going on with APIs behind the scenes. We may not see them as much, but they’re integral to our daily digital lives.

Yay🎉! You have reached the end of this blog. I hope you learned something from this Blog. Thank you for sticking till the last. I am glad to be a part of your learning journey✨.