0% found this document useful (0 votes)
2 views5 pages

Types of APIs ?

The document outlines four types of APIs: REST, SOAP, GraphQL, and WebSocket. REST APIs use standard HTTP methods for resource identification, SOAP APIs exchange structured information using XML, GraphQL allows clients to request specific data, and WebSocket enables real-time communication. Each API type is accompanied by a code example demonstrating its usage.

Uploaded by

spprabhu3803
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Types of APIs ?

The document outlines four types of APIs: REST, SOAP, GraphQL, and WebSocket. REST APIs use standard HTTP methods for resource identification, SOAP APIs exchange structured information using XML, GraphQL allows clients to request specific data, and WebSocket enables real-time communication. Each API type is accompanied by a code example demonstrating its usage.

Uploaded by

spprabhu3803
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
C swine © Types of APIs rn, | Nikhil | FullStack Dev | rem mreere Mine call fa a8 Nd (Representational State Transfer) A widely used web API architecture that operates over HTTP and uses URLs for resource identification. It primarily relies on standard HTTP methods like GET, POST, PUT, and DELETE. Example : Fetching data from a REST API fetch( ‘https: //jsonplaceholder .typicode.com/posts' ) . then(response => response. json()) .then(data => console. log(data)) -catch(error => console.error('Error:', error)); @codewithnikhill 01 2. SOAP API (Simple Object Access Protocol) SOAP is a protocol for exchanging structured information, often used in enterprise applications. It uses XML for messages, and each message has strict structure requirements. Example: using a SOAP client library, as SOAP requires specific XML format const soap = require('soap'); const url = ‘'https://example.com/service?wsdl' ; soap.createClient(url, (err, client) => { client .MyFunction(args, (err, result) => { console. log(result); 4); oi @codewithnikhill 02 3. GraphQL API A query language for APIs that allows clients to request specific data, avoiding over-fetching or under-fetching. Clients specify the structure of the response, making it flexible and efficient. Example: const query = ~ Cina e posts { 5K) foneny eT eT fetch( https: //example.com/graphql', { method: ‘POST", headers: { ‘Content-Type’: ‘application/json’ }, body: JSON.stringify({ query }) 2) .then(response => response. json()) Mes eee unt oe 1 @- CLD De @codewithnikhill 03 4. WebSocket API Enables real-time, two-way communication between the client and server over a persistent connection. Commonly used in chat applications, gaming, and live notifications. Example: eee const socket = new WebSocket('wss://example.com/socket'); Sela cee ee (event) => console. log('Message from server:', socket.onopen = () ete een ees ee EN UTaR CTE @codewithnikhill Ley.

You might also like