# REST APIs

### HTTP

**CRUD** (Create, Read, Update, Delete) refers to the operations performed using REST APIs. **Create** operations are used to create new variables and set their initial values. **Read** operations are used to retrieve the value of a variable. **Update** operations are used to change the value of a variable. **Delete** operations are used to delete variables.

**HTTP** (HyperText Transfer Protocol) uses verbs (methods) that map to these CRUD operations. REST APIs typically use HTTP.

<figure><img src="/files/QkakqEJCE0v2QnBd6McL" alt="HTTP verbs" width="563"><figcaption></figcaption></figure>

When an HTTP client sends a request to an HTTP server, the HTTP header includes an HTTP verb and a **URI** (Uniform Resource Identifier) indicating the resource it is trying to access.

<figure><img src="/files/BEa3mp8tObBcOe7kAWob" alt="URI example" width="563"><figcaption></figcaption></figure>

The HTTP request can include additional headers which pass additional information to the server, e.g. an `Accept` header informs the server about the type of data that can be sent to the client.

The server's response includes a status code indicating the request succeeded or failed and some other details. The first digit indicates the class of the response:

* 1 (information) - the request was received, continuing the process
* 2 (successful) - the request was successfully received, understood, and accepted
* 3 (redirection) - further action needs to be taken to complete the request
* 4 (client error) - the request contains bad syntax or cannot be fulfilled
* 5 (server error) - the server failed to fulfil a valid request

### REST

**REST** (Representation State Transfer) APIs are also known as **REST-based API**s or **RESTful API**s. REST is not a specific API. Instead, it describes a set of rules about how the API should work. The six constraints of RESTful architecture:

* uniform interface
* client-server - they can both change and evolve independently of each other. When the client or the server application changes, the interface between them must not break.&#x20;
* stateless - each API exchange is a separate event, independent of all past exchanges between the client and server. The server doesn't store information about previous requests from the client to determine how it should respond to new requests. If authentication is required, the client must authenticate with the server for each request it makes.
* cacheable or non-cacheable - REST APIs must support caching of data but not all resources have to be cacheable. **Caching** refers to storing data for future use.&#x20;
* layered system
* code-on-demand (optional)

{% file src="/files/JGByM3otxzmQGOivRfJv" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://citizenseven.gitbook.io/ccna-prep/rest-apis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
