> For the complete documentation index, see [llms.txt](https://rcabeza.gitbook.io/dws/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rcabeza.gitbook.io/dws/web-services/rest.md).

# REST

<http://media.formandome.es/markdownslides/api-rest/export/api-rest-reveal-slides.html>

* La arquitectura REST se ha impuesto para construir web services.
  * Significado: REpresentational State Transfer.
  * Los recursos se representan por nombres en plural.
  * Las rutas tienen un sentido semántico.
  * Las acciones se basan en los verbos http: GET, POST, PUT, DELETE.&#x20;
  * El resultado se refleja en los códigos http: 200 OK, 404 Not found, ...
* El conjunto de servicios ofrecidos por un servicio web constituye un API (Application Programming Interface)
* Un api que sigue los principios REST (nombre) es un API restful(adjetivo).&#x20;

  **Rutas y verbos**
* Los recursos siempre en plural.
* El verbo HTML usado es determinante para saber que queremos hacer:
  * Lista: GET <http://eventos.com/api/eventos/>
  * Detalle de un  elemento: GET <http://eventos.com/api/eventos/2>
  * Alta de elemento: POST <http://eventos.com/api/eventos/>&#x20;
  * Modificar elemento: PUT <http://eventos.com/api/eventos/2>
  * Borrar elemento: DELETE <http://eventos.com/api/eventos/2>
* Las rutas puedes ser más elaboradas:

  * Lista de comentarios de un evento: GET <http://eventos.com/api/eventos/3/comentarios>
  * Añadir comentario al evento: POST <http://eventos.com/api/eventos/3/comentarios>

  **Respuestas**
* Errores:
  * 403: Acceso prohibido
  * 404: No encontrado.
  * 500: Error en el servidor
* Mensajes de éxito:
  * GET: 200
  * POST: 201. Creado con éxito.
  * DELETE: 200. OK
  * PUT: 200, modificado correctamente. 201, objeto creado con éxito.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://rcabeza.gitbook.io/dws/web-services/rest.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.
