Product developmentManual web testingAPI

What is API?

6 minutes read

APIs act as a middleman between different applications, letting them share information and perform tasks. They're like a language that lets software systems understand and talk to each other.

What is API?

Application Programming Interface (API) is a set of rules and definitions that lets different software communicate with each other. It's like a common language that helps the parts, like services or programs, work together, no matter how they were made. People use APIs for all kinds of apps: small and big projects, mobile and web apps, and even connecting IoT devices.

Picture this: You live in a house with neighbors from around the world, and you don't share a language. You need to agree with your Chinese neighbor when to play loud music on the patio. You draw a comic that you both get. Each of you thinks in your own language and doesn't understand the other, but the drawings serve as a common language that lets you talk despite your different languages and ways of thinking.

HTTP is the main way to send data between software through an API. What does HTTP do in an API? It's how data is moved.

Think again about the neighbor. You settled on trading drawings on paper, putting them in an envelope with a special symbol so you know it's from your neighbor. So, understanding the drawings is like an API (an interface that translates a shared "language" for everyone into their own data system), and HTTP is how we package our messages (an envelope with a special symbol).

Types of API

APIs can vary in terms of access and purpose of use.

  • Open APIs (public APIs) are available for use by all developers and they usually come with documentation. You can create applications using the functionality these open APIs provide. For example, a restaurant offers an open API for menus, table reservations, and reviews. You can create mobile apps for ordering food or booking tables with it.

  • Private APIs or internal APIs are meant for use inside an organization or a specific project. They are not made public and access is normally limited. For instance, a restaurant might use a private API to swap information internally between the cash register system, inventory management, and table reservation systems.

  • Partner APIs are available to a select group of partners or customers. They are typically used in business situations where companies work together and grant each other restricted access to their services. For example, a restaurant may offer a partner API to connect with a food delivery platform. Partners can access menus and process orders using this API.

  • Composite APIs combine the features of several other APIs to form a new API. They allow you to access multiple services through a single interface. These APIs make it easier to interact with multiple services by providing a layer on top of different APIs. A restaurant might use a composite API that merges the functions of partner APIs for delivery and table booking, allowing you to integrate both functions without dealing with each API separately.

Each of these API types serves a different role and offers various levels of access based on a company's needs and strategy.

URI, URL, and URN

APIs expose endpoints, which are specific URLs or URIs that correspond to different functionalities or resources. Each endpoint represents a specific operation that you can request from the server. You'll often find this in classic architectures like REST.

Let’s start with URI – Uniform Resource Identifier. It's a string of characters used to identify or name a resource on the internet. Think of a URI as an address that helps you find something on the web. For example, https://www.example.com/path/to/resource?param1=value1&param2=value2#section-1

URL (Uniform Resource Locator) is a type of URI that identifies a resource and also helps to locate it. Like directions to a restaurant, a URL guides you to the exact spot on the web where it's found.

The parts of a URL include:

  1. Scheme (https) specifies the protocol for accessing the resource. Examples include http, https, and ftp.

  2. Authority (www.example.com) has the domain name or IP address of the server where the resource is. It might also have a port number (e.g., 66.249.65.236:3003).

  3. Path (path/to/resource) shows the exact place of the resource on the server's system or API endpoints.

  4. Query parameters (?param1=value1&param2=value2) send extra data to the server with your request. These parameters begin with ‘?’ and separate with '&'. They often come in pairs of keys and values.

  5. Fragment identifier (#section-1) points to a specific part within the resource, often used in HTML documents. When you browse, this part helps with navigation, but it's not used when sending requests to the server since it's meant for client-side navigation.

For example, if you're on the web and find a restaurant's site with the URL: https://www.hypotheticalrestaurant.com/menu, then "https://www.hypotheticalrestaurant.com" is the base URL. "/menu" is a path that takes you straight to the restaurant's menu online.

URN or Uniform Resource Name doesn't show where to find a resource. Instead, it gives a unique, lasting name for a resource. It's more like knowing the restaurant's name rather than its address. URNs are not common on the web but are useful for things like digital libraries or archives. An example of a URN is urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66.

The parts of a URN might include:

  1. It's important to track the number of balls and their colors in the urn.

  2. Use arrays or lists to keep the colors of the balls in the urn.

  3. Functions or methods help you add or remove balls, or check how many are in the urn.

Let’s start with URI – Uniform Resource Identifier. It's a string of characters used to identify or name a resource on the internet. See a URI as an address that lets you find something on the web.

URI

Remember, a URL is always a URI, but a URI isn’t always a URL. As the picture shows, the same address can be both a URI and a URL.

Conclusion

API testing requires you to have certain knowledge and skills. You must understand API specifications, request parameters, and data formats; work with authorization and authentication, handle errors; and learn about other aspects of APIs. You should also become familiar with separate documentation maintained for APIs. APIs are key for a smooth switch to automated testing.

4 learners liked this piece of theory. 1 didn't like it. What about you?
Report a typo