Question #160EasyGeneralCloud/Backend

Different types of API and full form of API ?

#api

Answer

Overview

API stands for Application Programming Interface — a set of rules and protocols that allows one software application to communicate with another.


Full Form

text
API = Application Programming Interface

Types of APIs

1. REST API (Representational State Transfer)

Most common type — uses HTTP methods over the web.

dart
// REST API in Flutter
final response = await http.get(
  Uri.parse('https://api.example.com/users'),
  headers: {'Authorization': 'Bearer $token'},
);
MethodOperation
GETRead data
POSTCreate data
PUT/PATCHUpdate data
DELETEDelete data

2. GraphQL API

Query-based API — request exactly the data you need.

graphql
# Single query gets nested data
query {
  user(id: "1") {
    name
    email
    orders { id, total }
  }
}

3. gRPC API (Google Remote Procedure Call)

Binary protocol using Protocol Buffers — high performance.

protobuf
service UserService {
  rpc GetUser (UserRequest) returns (UserResponse);
  rpc ListUsers (Empty) returns (stream UserResponse);
}

4. WebSocket API

Persistent bidirectional real-time communication.

dart
final channel = WebSocketChannel.connect(Uri.parse('wss://api.example.com/ws'));
channel.stream.listen((message) => print(message));
channel.sink.add('Hello');

5. SOAP API (Simple Object Access Protocol)

XML-based, enterprise legacy systems.

xml
<soap:Envelope>
  <soap:Body>
    <GetUser><userId>1</userId></GetUser>
  </soap:Body>
</soap:Envelope>

6. Webhook API

HTTP callback — server pushes data to your endpoint.

text
Payment complete → Stripe POSTs to your /webhook endpoint

7. Library/SDK API

APIs within a programming language (not over network).

dart
// Flutter's own API
Text('Hello') // Using Flutter widget API
SharedPreferences.getInstance() // Plugin API

API Comparison

TypeProtocolFormatUse Case
RESTHTTPJSONGeneral web APIs
GraphQLHTTPJSONFlexible data fetching
gRPCHTTP/2ProtobufMicroservices, high perf
WebSocketTCPAnyReal-time (chat, games)
SOAPHTTPXMLLegacy enterprise
WebhookHTTPJSONEvent notifications

Summary: API is the contract between two systems. REST is the most common for mobile apps. gRPC for performance-critical services. WebSocket for real-time. GraphQL for flexible queries.