API stands for Application Programming Interface. An API is a set of rules that allows programs to communicate with each other, exposing data and functionality across the internet in a consistent format.
REST stands for Representational State Transfer. It is an architectural pattern that defines how distributed systems can provide a standardized interface. When people refer to a REST API, they generally mean an API that is accessed using the HTTP protocol at a predefined set of URLs.
These URLs represent resources —which can be any type of data or content, such as JSON, HTML, audio files, or images. Each resource typically supports one or more HTTP methods that define the actions that can be performed on it:
- GET - Retrieve a resource.
- POST - Create a new resource.
- PUT - Update an existing resource.
- DELETE - Remove a resource.
The distinction between POST and PUT can be confusing, but the general rule is:
- Use POST to create a new resource.
- Use PUT to update an existing resource.