Crea API che non odierai
Crea API che non odierai
Ormai tutti vogliono utilizzare le API quindi é decisamente una buona idea imparare a costruirle.
Info sul libro
Costruisco API da molto tempo ed é un'attivitá sempre piú comune per gli sviluppatori lato server grazie alla crescita di framework JavaScript per l'interfaccia grafica (front-end), di applicazioni per iPhone e di architetture API-centriche. Se da un lato si sta solo prendendo roba da un'origine dati per spararla in uscita come JSON, dall'altro sopravvivere ai cambiamenti nella business logic, agli aggiornamenti dello schema del database, alle nuove funzionalità o alla obsoloscenza degli endpoint, ecc... diventa molto difficile.
Trovo che la maggior parte delle risorse in cui mi sono imbattuto siano terribilmente carenti o specificamente finalizzate a un unico framework. Molti tutorial e libri usano mele e pere come esempi e quindi non sono abbastanza concreti, o parlano come se /users e /users/1 siano i soli endpoint di cui si abbia bisogno. Ho passato l'ultimo anno di lavoro in una società chiamata Kapture dove la mia funzione principale è stata quello di ereditare, ricostruire, mantenere e sviluppare una vasta API dotata di moltissimi endpoints diversi che espongono un sacco di diversi use-case.
L'API in questione era alla versione 2 quando sono entrato in azienda ed era scritta in FuelPHP, utilizzando un ORM ormai deprecato che era stato pesantemente modificato dallo sviluppatore originale. Kapture era in fase di ricostruzione della propria applicazione iPhone per implementare nuove funzionalità, quindi ho usato questa opportunitá per sistemare un po´ di casino e costruire la versione 3 con Laravel 4, facendo leva sui suoi semplici meccanismi di Routing (inizialmente basati su Symfony ), Migrazione di database, Schema, Seeding, ecc. Ora stiamo facendo la stessa cosa per la versione 4 ma questa volta non è stato necessario riscrivere nulla, anche se ci sono alcune nuove funzionalità, e la versione 3 è stata forcata (forked) in una nuova (v4) ed entrambe sono attivamente sviluppate e vivono fianco a fianco sugli stessi "API" server.
Attraverso buone pratiche ed buoni consigli generali, potrai partire al volo con lo sviluppo di API, anche se sei nuovo in questo ambiente. D'altra parte, leggendo alcune storie dell'orrore che riporto (e come sono state superati/evitati/scongiurati certi errori) puoi sperare di evitare molte delle insidie in cui mi sono imbattuto o in cui ho visto cadere altri. Il libro discuterà la teoria della progettazione e della produzione di API in qualsiasi linguaggio o framework. La teoria verrá descritta attraverso esempi scritti prevalentemente in PHP ma anche in Ruby e Python. Questo libro, comunque, non sará troppo incentrato sul codice perché, diciamolo, leggere codice non é poi cosí divertente.
Al termine di questo libro riuscirai a costruire un'API che sa creare, leggere, aggiornare, eliminare, elencare, cercare e che sa fare quant'altro una buona API RESTful deve saper fare.
Il libro coprirá anche altri argomenti piú avanzati come il testing degli endpoint, il debugging, gli embedded data objects in modo coerente e scalabile, l'impaginazione delle risposte (compresi gli embedded objects) e i collegamenti (links) di tipo HATEOAS.
Se hai dei suggerimenti o dei commenti non esitare a metterti in contatto.
Indice
- Introduzione
- Codice di Esempio
-
1 Popolare proficuamente il database (database seeding)
- 1.1 Introduzione
- 1.2 Il Database seeding
- 1.3 Come costruire i Seeders
- 1.4 Questo è tutto
- 1.5 Dati Secondari
- 1.6 Quando eseguire il seeding?
-
2 Pianificare e Creare Endpoints
- 2.1 Requisiti Funzionali
- 2.2 Teoria degli Endpoint
- 2.3 Pianificare gli endpoint
-
3 Input e Output: Teoria
- 3.1 Introduzione
- 3.2 Richieste (Requests)
- 3.3 Risposte (Responses)
- 3.4 Formati supportati
- 3.5 Struttura del contenuto
-
4 Codici di stato , errori e messaggi
- 4.1 Introduzione
- 4.2 Codici di stato HTTP
- 4.3 Codici di errore e messaggi di errore
- 4.4 Errore o errori
- 4.5 Insidie frequenti
-
5 Test degli Endpoint
- 5.1 Introduzione
- 5.2 Concetti e strumenti
- 5.3 Installazione
- 5.4 Inizializzazione
- 5.5 Caratteristiche
- 5.6 Scenari
- 5.7 Preparare Behat
- 5.8 Esecuzione di Behat
-
6 Output dei dati
- 6.1 Introduzione
- 6.2 Approccio diretto
- 6.3 Trasformazioni con Fractal
- 6.4 Nascondere i cambiamenti di schema
- 6.5 Output degli errori
- 6.6 Test dell’output
- 6.7 Compiti a casa
-
7 Relazioni tra i dati
- 7.1 Introduzione
- 7.2 Sotto-Risorse
- 7.3 Array di chiavi esterne (foreign keys)
- 7.4 Documenti Composti (detto anche Side-Loading)
- 7.5 Embedded Documents (a.k.a Annidamento - Documenti Incorporati)
-
8 Debug
- 8.1 Introduzione
- 8.2 Debug a riga di comando
- 8.3 Debug via browser
- 8.4 Debug di rete
-
9 Autenticazione
- 9.1 Introduzione
- 9.2 Quando é utile l’ autenticazione?
- 9.3 Diversi approcci all’autenticazione
- 9.4 Implementazione di un Server OAuth 2.0
- 9.5 Dove vive un Server OAuth 2.0
-
10 Paginazione
- 10.1 Introduzione
- 10.2 Paginator
- 10.3 Offset e cursori
-
11 Documentazione
- 11.1 Introduzione
- 11.2 Tipologie di documentazione
- 11.3 Scegliere uno strumento
- 11.4 Configurazione di API Blueprint e Aglio
- 11.5 Imparare la sintassi dell’API di Blueprint
- 11.6 Richieste
- 11.7 Risposte
- 11.8 Approfondimenti
-
12 HATEOAS
- 12.1 Introduzione
- 12.2 Negoziazione del contenuto
- 12.3 Controlli hypermedia (ipermediali)
-
13 Versioning dell’API
- 13.1 Introduzione
- 13.2 Diversi approcci al versioning dell’API
- 13.3 Chiedi agli utilizzatori
- Conclusione
- Approfondimenti
Leanpub è garantito dalla formula soddisfatti o rimborsati. Nessun rischio, garanzia di Felicità al 100%
Entro 60 giorni dall'acquisto è possibile ottenere un rimborso completo del 100% del valore su qualsiasi acquisto Leanpub. Vedi completi.
Do Well. Do Good.
Authors have earned$11,608,513writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Cronache di Domain-Driven Design
Francesco Strazzullo, Matteo Baglini, Gianluca Padovani, Emanuele DelBono, Marco Consolaro, Alessandro Colla, Uberto Barbini, Alberto Acerbis, Julie Camosseto, DDD Open, and Alberto BrandoliniCronache di Domain-Driven Design: un libro corale in italiano fatto di storie indipendenti tra loro, che sono il risultato dell’applicazione di Domain-Driven Design su progetti reali.
Jetpack Compose internals
Jorge CastilloJetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.
Machine Learning Engineering
Andriy Burkov"If you intend to use machine learning to solve business problems at scale, I'm delighted you got your hands on this book."
—Cassie Kozyrkov, Chief Decision Scientist at Google
"Foundational work about the reality of building machine learning models in production."
—Karolis Urbonas, Head of Machine Learning and Science at Amazon
CCIE Service Provider Version 4 Written and Lab Exam Comprehensive Guide
Nicholas RussoThe service provider landscape has changed rapidly over the past several years. Networking vendors are continuing to propose new standards, techniques, and procedures for overcoming new challenges while concurrently reducing costs and delivering new services. Cisco has recently updated the CCIE Service Provider track to reflect these changes; this book represents the author's personal journey in achieving that certification.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
CCIE SP v5.0
Łukasz Bromirski, Piotr Jablonski, and Nicholas RussoAre you striving to prepare to and pass CCIE SP lab exam? Take the opportunity and get this workbook! With the attached initial cfg files you will prepare yourself for the CCIE SP exam as well as learn SP technologies applicable to all kinds of today modern networks! This workbook covers blueprint topics and provides challenging examples.
Mastering STM32 - Second Edition
Carmine NovielloWith more than 1200 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the first guide around that introduces the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL and STM32CubeIDE development environment.
Top Bundles
- #1
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
All the Books of The Medical Futurist
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon... - #3
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #4
Modern C++ Collection
3 Books
Get All about Modern C++C++ Standard Library, including C++20Concurrency with Modern C++, including C++20C++20Each book has about 200 complete code examples. Updates are included. When I update one of the books, you immediately get the updated bundle. You can expect significant updates to each new C++ standard (C++23, C++26, .. ) and also... - #5
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #6
Practical FP in Scala + Functional event-driven architecture
2 Books
Practical FP in Scala (A hands-on approach) & Functional event-driven architecture, aka FEDA, (Powered by Scala 3), together as a bundle! The content of PFP in Scala is a requirement to understand FEDA so why not take advantage of this bundle!? - #8
Retromat eBook Bundle for Agile Retrospectives
2 Books
If you facilitate retrospectives this bundle is for you: "Plans for Retrospectives" helps beginners learn the lay of the land with tried-and-true plans. Once you know your way around, "Run great agile retrospectives" contains all 135+ activities in Retromat for you to mix and match. - #10
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité...