example rest api
Here is an example of a REST API that allows users to perform CRUD (create, read, update, delete) operations on a collection of books:
GET /books - Returns a list of all books GET /books/{id} - Retrieves a specific book by ID POST /books - Creates a new book PUT /books/{id} - Updates a specific book by ID DELETE /books/{id} - Deletes a specific book by ID
For each of these endpoints, the server would return a JSON response containing the relevant data. For example, a GET request to /books might return:
[ { "id": 1, "title": "To Kill a Mockingbird", "author": "Harper Lee", "published": "1960-07-11", "publisher": "J. B. Lippincott & Co.", "isbn": "978-0-06-112008-4" }, { "id": 2, "title": "1984", "author": "George Orwell", "published": "1949-06-08", "publisher": "Secker & Warburg", "isbn": "978-0-14-103614-4" }, // ... more books ...
原文地址: https://www.cveoy.top/t/topic/huhx 著作权归作者所有。请勿转载和采集!