An application programming interface (API) is a contract that defines how software components communicate with each other.
An API answers these key questions:
POST /login
POST /orders
GET /users/{id}
Representational State Transfer (REST) is a software architectural style for providing standards between computer systems on the web. REST requests are stateless, meaning that each request sent by the client to the server must contain all the information needed for processing, and will not save any client data between requests.
A REST API is an API that adheres to REST architectural constraints. Clients use HTTP requests to interact with resources on a REST API and provide a Uniform Resource Identifier (URI).
GraphQL is an API query language and runtime that enables clients to request only the data they need. Unlike REST, GraphQL allows clients to specify their data requirements. It operates over a single end point and uses a type system to define the capabilities of the API.
type Query {
# A simple query for a user
me: User
# Another example of a query
getMostPopularCourse(input: GetMostPopularCourseInput): Course
}
# A query will follow the pattern:
type User {
id: String!
name: String!
}
type Course {
id: String!
name: String!
majorId: String!
creditHours: Int!
tuitionCost: Float!
deviationFromMeanGPA: Float
rawDifferenceFromMeanGPA: Float
}
input StudentInput {
id: String!
}
input GetMostPopularCourseInput {
startDate: String!
endDate: String!
}
WebSockets are a communication protocol that provides full-duplex (two-way) communication over a single, persistent TCP connection, enabling real-time, low-latency data exchange between client (browser or application) and server, unlike HTTP's request-response cycle. They are crucial for dynamic applications like live chat, gaming, and collaborative editing, allowing servers to push data to clients instantly without constant polling, using an initial HTTP handshake for upgrade. This creates an open channel for continuous data streams, significantly reducing overhead compared to repeated HTTP requests.