Table of Contents....4
Introduction....9
Why APIs....9
Django REST Framework....10
Prerequisites....11
Why this book....11
Conclusion....12
Chapter 1: Initial Set Up....13
The Command Line....13
Shell Commands....15
Install Python 3 on Windows....18
Install Python 3 on Mac....19
Python Interactive Mode....20
Virtual Environments....21
Install Django and Django REST Framework....23
Text Editors....25
Install Git....26
Conclusion....28
Chapter 2: Web APIs....29
World Wide Web....29
URLs....30
Internet Protocol Suite....31
HTTP Verbs....32
Endpoints....32
HTTP....33
Status Codes....35
Statelessness....36
REST....36
Conclusion....37
Chapter 3: Library Website....38
Traditional Django....38
First app....41
Models....43
Admin....44
Views....47
URLs....48
Templates....49
Tests....51
Git....53
Conclusion....54
Chapter 4: Library API....55
Django REST Framework....55
URLs....57
Views....58
Serializers....59
Browsable API....60
Tests....62
Deployment....64
Static Files....66
Deployment Checklist....68
GitHub....70
Heroku....70
Conclusion....72
Chapter 5: Todo API....74
Single Page Apps (SPAs)....74
Initial Set Up....75
.gitignore....76
Models....77
Tests....80
Django REST Framework....82
URLs....83
Serializers....84
Views....86
Browsable API....87
API Tests....88
CORS....90
CSRF....92
Back-End API Deployment....92
Conclusion....97
Chapter 6: Blog API....98
Initial Set Up....98
.gitignore....99
Custom User Model....100
Posts App....105
Post Model....106
Tests....109
Django REST Framework....111
URLs....112
Serializers....114
Views....115
Browsable API....116
CORS....120
Conclusion....122
Chapter 7: Permissions....123
Project-Level Permissions....123
Create New Users....125
Add Log In and Log Out....128
View-Level Permissions....131
Custom Permissions....133
Conclusion....138
Chapter 8: User Authentication....139
Basic Authentication....139
Session Authentication....141
Token Authentication....142
Default Authentication....144
Implementing token authentication....145
Endpoints....148
dj-rest-auth....148
User Registration....154
Tokens....157
Conclusion....163
Chapter 9: Viewsets and Routers....164
User endpoints....164
Viewsets....169
Routers....170
Permissions....172
Conclusion....174
Chapter 10: Schemas and Documentation....176
Schema....177
Dynamic Schema....179
Documentation....180
Conclusion....183
Chapter 11: Production Deployment....185
Environment Variables....185
DEBUG & SECRET_KEY....187
ALLOWED HOSTS....189
DATABASES....190
Static Files....191
Pyscopg and Gunicorn....192
requirements.txt....193
Procfile and runtime.txt....194
Deployment Checklist....195
Heroku Deployment....195
Conclusion....199
Advanced Topics....199
Next Steps....200
Giving Thanks....200
Django for APIs is a project-based guide to building modern web APIs with Django & Django REST Framework. It is suitable for beginners who have never built an API before as well as professional programmers looking for a fast-paced introduction to Django fundamentals and best practices.Over the course of 200+ pages you'll learn how to set up a new project properly, how web APIs work under the hood, and advanced testing and deployment techniques. Three separate projects are built from scratch with progressively more advanced features including a Library API, Todo API, and Blog API. User authentication, permissions, documentation, viewsets, and routers are all covered thoroughly.Django for APIs is a best-practices guide to building powerful Python-based web APIs with a minimal amount of code.