Tuesday, August 12, 2025

What is a Web API?

A Web API (Application Programming Interface) is a set of endpoints exposed over the web that allow clients (like web apps, mobile apps, or other services) to interact with data or functionality.

Different API Styles

  1. REST (Representational State Transfer)

    • Uses HTTP methods (GET, POST, PUT, DELETE).

    • Data is usually returned in JSON or XML.

    • Example:

      GET /api/products
    • Best for: Simple, stateless CRUD operations.

  2. SOAP (Simple Object Access Protocol)

    • Uses XML-based messaging.

    • Strict standards, more secure for enterprise needs.

    • Example request: <soapenv:Envelope>

          <soapenv:Body>

              <getProductDetails>

                  <productId>123</productId>

              </getProductDetails>

          </soapenv:Body>

      </soapenv:Envelope>

  3. GraphQL

    • Allows clients to request exactly the data they need.

    • Single endpoint for all queries/mutations.

    • Example:

      graphql
      { product(id: "123") { name price } }


No comments:

Post a Comment

Importance of Program.cs

 Example: var builder = WebApplication.CreateBuilder(args); // Add services builder.Services.AddControllers(); builder.Services.AddEndpoints...