kids encyclopedia robot

REST facts for kids

Kids Encyclopedia Facts

REST (which stands for REpresentational State Transfer) is like a set of rules or a blueprint for how the World Wide Web should be built. It helps make sure that different parts of the internet can talk to each other smoothly and efficiently. Think of it as a guide for designing how computers and websites share information.

These rules help make the internet work well. They focus on things like making sure all parts of a system can work on their own, that it can handle lots of users (scalability), and that information can be stored temporarily (caching) to make things faster for you. When a website or app follows these rules, it's often called RESTful. This means it's designed to be reliable and easy to use across the internet.

What is REST?

The idea of "representational state transfer" was first explained in 2000 by a computer scientist named Roy Fielding. It means that when you ask a server for information, it sends you a "representation" of that information. This could be a web page (HTML), a data file (XML), or a simple data format (JSON).

This representation often includes links. When you click a link, you're telling the system to change its "state" by moving to a new piece of information. Each time you make a request, you get another representation with more links.

A cool thing about this is that you only need to know the first link to start. All other links are found as you go. This means that if the links change on the server's side, your computer doesn't need to know beforehand. It makes the connection between your computer and the server very flexible.

How REST Started

Roy Fielding at OSCON 2008
Roy Fielding speaking at a conference in 2008. He helped create the idea of REST.

The internet started becoming popular around 1993-1994. Back then, there wasn't a clear plan for how the Web's different parts should work together. People in the computer world wanted a standard way for internet programs to communicate.

Roy Fielding was involved in creating important internet standards like URI (which are like web addresses) and HTTP (the rules for how web pages are sent). Over six years, he developed the REST architectural style. He used it to test how well the internet's rules worked and to find ways to make them better. He wrote about REST in his PhD paper in 2000.

To create REST, Fielding looked at what was needed for a worldwide network application. He wanted to make it easy for anyone to use and build on the internet. He also studied other ways of building network apps. He found common features like caching (saving temporary copies of data) and client-server setups. He also found unique ideas for REST, like the concept of "resources" (any piece of information on the web).

REST is a set of ideas, not a specific program. While the internet uses many of REST's ideas, it doesn't follow every single rule perfectly. But having the REST style helps people see when things might not be working as well as they could. For example, putting session information (like your login status) directly into web addresses can slow things down. Also, HTTP cookies (small data files websites save on your computer) can sometimes cause problems if they don't match what the browser expects.

Why REST is Important

The REST style is made for applications that work over networks, especially those where one computer (the client) asks another (the server) for information. It's designed for the huge scale of the internet. This means the client and server should be as independent as possible. This helps the internet grow and change easily.

When the client and server are separate, and they use simple text to share information with a standard address system, it helps the Web in many ways:

  • It can grow very big without breaking.
  • Different parts can be updated without affecting others.
  • It's easy for people to read, write, and develop content.
  • It allows for large amounts of data to be transferred.
REST information model
An image showing how different parts of a REST system are connected.

The rules of REST help improve several important things:

  • Speed: How fast different parts of the system talk to each other, which affects how quickly you see things on your screen.
  • Scalability: The ability to handle many users and interactions without slowing down.
  • Simplicity: Making the way things connect easy to understand and use.
  • Flexibility: Being able to change parts of the system even while it's running.
  • Visibility: Making it easy to see how different parts are communicating.
  • Portability: Being able to move parts of the system easily.
  • Reliability: Making the system strong and able to keep working even if some parts have problems.

Key Rules of REST

The REST architectural style has six main rules. When these rules are followed, the system becomes better in terms of speed, scalability, simplicity, flexibility, visibility, portability, and reliability.

Here are the main rules:

  • Client/Server: The client (like your web browser) and the server (where the website lives) are separate. They talk to each other through a clear set of rules.
  • Stateless: The server doesn't remember anything specific about your past requests. Each request you send is treated as brand new. This helps the server handle many users at once.
  • Cacheable: The server tells your computer if the information it sends can be saved temporarily (cached). This means your computer doesn't have to ask for the same information again, making things faster.
  • Uniform Interface: There's a standard way for clients and servers to interact. This makes it easier for different systems to work together.
  • Layered System: Your computer might not be talking directly to the main server. There might be other servers in between (like proxy servers or security systems). Your computer usually doesn't need to know this.
  • Code on Demand (optional): Sometimes, the server can send small pieces of code to your computer. This code can temporarily add new features or change how your computer works with the website.

Uniform Interface

The "uniform interface" rule is super important for any RESTful system. It makes the system simpler and allows different parts to grow and change independently. Here are its four parts:

  • Identifying Resources: Every piece of information (called a "resource") on the web has a unique address, like a URI. The actual information is separate from how it's shown to you. For example, a server might send you data as HTML (for web pages), XML, or JSON (for data exchange), but none of these are the server's internal way of storing that data.
  • Changing Resources: When your computer gets a "representation" of a resource (like a web page), it has enough information to change or delete that resource if it has permission.
  • Self-Descriptive Messages: Each message sent between the client and server contains all the information needed to understand it. For example, it tells your computer what kind of data it is (like an image or text) so your computer knows how to open it.
  • Hypermedia as the Engine of Application State (HATEOAS): This is a fancy way of saying that once you start on a REST website (like visiting its home page), the server will give you links to everything else you can do or see. You don't need to know the website's structure beforehand. The server guides you by providing links to other available resources.

See also

kids search engine
REST Facts for Kids. Kiddle Encyclopedia.