A REST API, or RESTful API, is a type of application programming interface (API) that follows the principles of Representational State Transfer (REST) architectural style. It allows communication between different applications or systems over the internet, typically using HTTP requests and responses. Think of it as a set of instructions for how to interact with a specific piece of software or service.
A URI (Uniform Resource Identifier) is a unique identifier for a resource on the internet, like a web page, image, or API endpoint. It tells the system where to find the specific resource you’re requesting. In REST APIs, URIs often include the resource type and specific identifier (e.g., /users/123).
API methods are specific actions you can perform on a resource using the API. Common methods include GET (retrieve data), POST (create data), PUT (update data), and DELETE (remove data). These methods are typically mapped to HTTP verbs for clear communication.
Resource-based: Treat data and functionality as resources with unique identifiers.
Stateless: Each request-response interaction is independent, and the server doesn’t store state information.
Cachable: Responses can be cached for improved performance.
Uniform interface: Use consistent naming conventions and methods across the API.
Documenting: Provide clear documentation for developers to understand how to use the API effectively.
JSON (JavaScript Object Notation) is a popular data format for exchanging information between applications. It uses a human-readable format with key-value pairs, making it lightweight and easy to parse. APIs often use JSON to send and receive data, making it a crucial element in API communication.
Example JSON File:
{
“name”: “John Doe”,
“age”: 30,
“occupation”: “Software Engineer”,
“interests”: [“coding”, “travel”, “music”],
“address”: {
“street”: “123 Main Street”,
“city”: “Anytown”,
“state”: “CA”,
“zipcode”: “12345”
}
}
This example represents information about a person in JSON format. It uses key-value pairs to store data like name, age, occupation, interests, and address. The address itself is another object nested within the main object.
Key Benefits of JSON:
See a video below on APIs
Published by Active Learning, Dec 2023