API
Application Programming Interface allowing two applications to communicate with each other.
API (Application Programming Interface) is a software interface that allows two applications to communicate with each other in a standardized way.
How does it work?
An API defines:
- Possible requests (GET, POST, PUT, DELETE...)
- Data formats exchanged (JSON, XML...)
- Authentication rules
Types of APIs
REST API
REST APIs (Representational State Transfer) are the most common standard. They use the HTTP protocol and typically return data in JSON format.
GraphQL API
GraphQL allows clients to specify exactly the data they need, avoiding over-fetching.
WebSocket API
For real-time bidirectional communications.
Usage examples
- E-commerce: payment integration (Stripe, PayPal)
- Mapping: displaying maps (Google Maps, Mapbox)
- Social: authentication via social networks
Best practices
- Clearly document endpoints
- Version the API
- Handle errors explicitly
- Implement rate limiting