


We use cookies to improve your experience
We use essential cookies to make our site work. With your consent, we may also use non-essential cookies to improve user experience.
Definition
An API (Application Programming Interface) is a set of rules and protocols that allows different software applications to communicate with each other. APIs define the methods and data formats that programs use to request and exchange information.
An API is a contract between two pieces of software. One side (the server or provider) exposes a set of endpoints — URLs that accept requests and return structured data. The other side (the client or consumer) sends HTTP requests to those endpoints and parses the responses. This decoupling lets a mobile app, a web frontend, and a CLI tool all share the same backend logic without duplicating code.
The most common web API style is REST, which uses standard HTTP methods (GET, POST, PUT, DELETE) and returns JSON. GraphQL is an alternative that lets clients request exactly the fields they need. Other styles include gRPC (binary, fast, used in microservices), SOAP (XML-based, legacy enterprise), and WebSocket APIs (real-time, bidirectional). Public APIs power integrations with services like Stripe, Google Maps, and Twitter.
Well-designed APIs use consistent naming, return meaningful HTTP status codes, version their endpoints (v1, v2), and provide clear documentation. Authentication is typically handled via API keys, OAuth tokens, or JWTs. Rate limiting prevents abuse, and CORS headers control which domains can call the API from a browser.