Build APIs You Won't Hate
Build APIs You Won't Hate
Everyone and their dog wants an API, so you should probably learn how to build them.
About the Book
After finding many of the existing resources for API development to be lacking, Phil learned a lot of things the hard way through years of trial and error. This book aims to condense that experience, taking examples and explanations further than the trivial apples and pears nonsense tutorials often provide.
Phil worked primarily as an API developer for the last three years. One horror was managing an API built in FuelPHP by a freelancer at the million dollar startup he joined. It was utilizing a then deprecated ORM which had been hacked to death by the previous developer, so took the time to delete that mess and build the next version in Laravel, leveraging it's simple routing, database migrations, schema, seeding, etc. When the following major version of the API was built no rewrite was required, and both managed to live side-by-side on the same "API" servers.
By passing on some best practices and general good advice you can hit the ground running with API development, combined with some horror stories and how they were overcome/avoided/averted. This book will discuss the theory of designing and building APIs in any language or framework, with this theory applied in PHP-based examples.
Some of the more advanced topics covered here are endpoint testing, embedding data objects in a consistent and scalable manner, paginating responses (including embedded objects) and hypermedia "HATEOAS" controls.
- Sample Code
1. Useful Database Seeding
- 1.1 Introduction
- 1.2 Introduction to Database Seeding
- 1.3 Building Seeders
- 1.4 That is about it
- 1.5 Secondary Data
- 1.6 When to run this?
2. Planning and Creating Endpoints
- 2.1 Functional Requirements
- 2.2 Endpoint Theory
- 2.3 Planning Endpoints
3. Input and Output Theory
- 3.1 Introduction
- 3.2 Requests
- 3.3 Responses
- 3.4 Supporting Formats
- 3.5 Content Structure
4. Status Codes, Errors and Messages
- 4.1 Introduction
- 4.2 HTTP Status Codes
- 4.3 Error Codes and Error Messages
- 4.4 Error or Errors
- 4.5 Standards for Error Responses
- 4.6 Common Pitfalls
5. Endpoint Testing
- 5.1 Introduction
- 5.2 Concepts & Tools
- 5.3 Setup
- 5.4 Initialise
- 5.5 Features
- 5.6 Scenarios
- 5.7 Prepping Behat
- 5.8 Running Behat
6. Outputting Data
- 6.1 Introduction
- 6.2 The Direct Approach
- 6.3 Transformations with Fractal
- 6.4 Hiding Schema Updates
- 6.5 Outputting Errors
- 6.6 Testing this Output
- 6.7 Homework
7. Data Relationships
- 7.1 Introduction
- 7.2 Subresources
- 7.3 Foreign Key Arrays
- 7.4 Compound Documents (aka Sideloading)
- 7.5 Embedded Documents (aka Nesting)
- 7.6 Summary
- 8.1 Introduction
- 8.2 Command-line Debugging
- 8.3 Browser Debugging
- 8.4 Network Debugging
- 9.1 Introduction
- 9.2 When is Authentication Useful?
- 9.3 Different Approaches to Authentication
- 9.4 Implementing an OAuth 2.0 Server
- 9.5 Where the OAuth 2.0 Server Lives
- 9.6 Understanding OAuth 2.0 Grant Types
- 10.1 Introduction
- 10.2 Paginators
- 10.3 Offsets and Cursors
- 11.1 Introduction
- 11.2 Types of Documentation
- 11.3 Picking a Tool
- 11.4 Setting up API Blueprint and Aglio
- 11.5 Learning API Blueprint Syntax
- 11.6 Further Reading
- 12.1 Introduction
- 12.2 Content Negotiation
- 12.3 Hypermedia Controls
13. API Versioning
- 13.1 Introduction
- 13.2 Different Approaches to API Versioning
- 13.3 Ask Your Users
14. Bonus Chapter: File Uploads & Downloads
- 14.1 Introduction
- 14.2 Downloads
- 14.3 Uploads
- 14.4 Why Multipart is Fairly Awful
- 14.5 Method A: Direct File Upload
- 14.6 Method B: Upload from URL
- 14.7 What about Meta Data?
- 14.8 Summary
- API Web Resources
- Non-API Books
A nationwide network of volunteer-led after school coding clubs for children aged 9-11.
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
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.
Algebra-Driven DesignSandy Maguire
A how-to field guide on building leak-free abstractions and algebraically designing real-world applications.
Production HaskellMatt Parsons
Are you excited about Haskell, but don't know where to begin? Are you thrilled by the technical advantages, but worried about the unknown pitfalls? This book has you covered.
The Hundred-Page Machine Learning BookAndriy Burkov
Everything you really need to know in Machine Learning in a hundred pages.
Ansible for DevOpsJeff Geerling
Ansible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Machine Learning EngineeringAndriy 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
Cloud StrategyGregor Hohpe
“Strategy is the difference between making a wish and making it come true.” A successful migration to the cloud shouldn’t be driven by wishes, but guided by a sound strategy, frameworks, and decision models. This book tells you how—without becoming superficial nor getting lost in technology and product details.
CCIE Service Provider Version 4 Written and Lab Exam Comprehensive GuideNicholas Russo
The 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.
CCIE SP v4.1 - WorkbookŁukasz Bromirski, Piotr Jablonski, and Nicholas Russo
Are 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.
C++ Best PracticesJason Turner
Level up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
Introducing EventStormingAlberto Brandolini
The deepest tutorial and explanation about EventStorming, straight from the inventor.
The Node.js Bundle
3 BooksThis bundle combines three bestselling Leanpub Node.js books into a package that gives you everything you need to get started with developing Node.js applications at an unbeatable price.
The Tester's Library
8 BooksThe Tester's Library consists of eight five-star books that every software tester should read and re-read. As bound books, this collection would cost over $200. Even as e-books, their price would exceed $80, but in this bundle, their cost is only $49.99. Here are the books, and why they should be in your library: Perfect Software and Other...
11 BooksIn this bundle, you will find 10 different agile books. They are about different aspects of being agile. - finding a job - doing coding dojo's - Retrospectives - Personal kanban - a non-typical coaching book and even a book that gives you an insight in the lives of some agile people.
WTFlop 6M + HU - Beta Bundle
Fifty Quick Ideas
3 BooksGet all three books for the price of two! Fifty Quick Ideas books are full of practical, real-world techniques that you can use to improve teamwork, build better products and build them in a better way.
Growing Agile: Coach's Guide Series
4 BooksThis bundle provides a collection of training and workshop plans for a variety of agile topics. The series is aimed at agile coaches, trainers and ScrumMasters who often find themselves needing to help teams understand agile concepts. Each book in the series provides the plans, slides, handouts and activity instructions to run a number of...
Marionette.js A to Z
Complete Scala Bundle
3 BooksScala is a general-purpose programming language and it's getting extremely popular these days. Some say that learning Scala could be a challenging task. My experience, however, suggests that this is actually a myth that has very little to do with reality. With the right approach, learning Scala can be easy, fun and rewarding.The first book from...
Build A Better Backbone App
3 BooksThe best way to learn new development skills is through experience, but that takes time you don't have.Get the best of both worlds with this bundle: you'll learn how to produce modern web applications by learning from experienced developers like Derick Bailey and David Sulc. BackboneJS is one of the favorite tools on the web today, but it...