Designing Web APIs with Strapi
eBook - ePub

Designing Web APIs with Strapi

Khalid Elshafie, Mozafar Haider

Share book
  1. 310 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Designing Web APIs with Strapi

Khalid Elshafie, Mozafar Haider

Book details
Book preview
Table of contents
Citations

About This Book

Leverage the power of Strapi to build self-hosted, customizable, and performant content APIsKey Features• Discover how Strapi can help you build APIs quickly and focus on your products and features• Learn how to put Strapi into practice by implementing it in real-world scenarios• Understand how to use Strapi's powerful features to customize your APIsBook DescriptionStrapi is a Node.js-based, flexible, open-source headless CMS with an integrated admin panel that anyone can use and helps save API development time. APIs built with Strapi can be consumed using REST or GraphQL from any client. With this book, you'll take a hands-on approach to exploring the capabilities of the Strapi platform and creating a custom API from scratch.This book will help JavaScript developers to put their knowledge to work by guiding them through building powerful backend APIs. You'll see how to effortlessly create content structures that can be customized according to your needs, and gain insights into how to write, edit, and manage your content seamlessly with Strapi. As you progress through the chapters, you'll discover a wide range of Strapi features, as well as understand how to add complex features to the API such as user authentication, data sorting, and pagination. You'll not only learn how to find and use existing plugins from the open-source community but also build your own plugins with custom functionality with the Strapi plugin API and add them to the admin panel. Finally, you'll learn how to deploy the API to Heroku and AWS.By the end of this book, you'll be able to build powerful, scalable, and secure APIs using Strapi.What you will learn• Explore Strapi and understand how it works• Define content types to build APIs quickly and efficiently• Understand authentication and authorization in Strapi• Create production-ready APIs with Strapi• Deploy the Strapi API to various environments, including Heroku and AWS• Use best practices to run the Strapi API in production• Sync permissions to access the API between multiple environments• Write basic tests for API utilities as well as the endpointWho this book is forThis book is for backend and frontend JavaScript developers. Experienced API developers will learn a new, fast, and flexible way of building APIs, while frontend developers will be able to take a step toward becoming full-stack developers by learning how to leverage Strapi for building APIs quickly. Basic knowledge of JavaScript and REST API concepts is assumed.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Designing Web APIs with Strapi an online PDF/ePUB?
Yes, you can access Designing Web APIs with Strapi by Khalid Elshafie, Mozafar Haider in PDF and/or ePUB format, as well as other popular books in Computer Science & Content Management Systems. We have over one million books available in our catalogue for you to explore.

Information

Year
2022
ISBN
9781800566705
Edition
1

Section 1: Understanding Strapi

Each journey starts with a first step. Our first step will be to understand the concept of headless CMS (short for Content Management System) and why Strapi is one of the most popular headless CMS around. Then, the chapters will move onto how to prepare the development environment and install and set up Strapi to build our first API.
In this section, we will cover the following topics:
  • Chapter 1, An Introduction to Strapi
  • Chapter 2, Building Our First API
  • Chapter 3, Strapi Content-Types
  • Chapter 4, An Overview of the Strapi Admin Panel

Chapter 1: An Introduction to Strapi

This chapter gives an introduction to Strapi. First, we will explain what Strapi is and what are the benefits of using it in developing API (short for application programming interface). Then, we will see how to set up and prepare our development environment to work with Strapi. Afterward, we will create a simple API to help us get started with Strapi. Finally, we will have a quick look at the server scripts offered by Strapi to start and stop the development server.
These are the topics we will cover in this chapter:
  • What is Strapi?
  • Why use Strapi? (The benefits of Strapi)
  • Preparing the development environment
  • Creating a Strapi application
  • Understanding server scripts

What is Strapi?

Strapi is a headless content management system (CMS).
A CMS is a software application used for web development that allows users to create, edit, and publish content.
A traditional CMS, such as WordPress, tightly couples the frontend and the backend—that is, the structure of the content and how it is presented. However, unlike traditional CMSes, a headless CMS is entirely decoupled from the presentation layer. The term headless comes from separating the head (the frontend) from the body (the backend). A headless CMS does not care about how the contents get displayed; instead, it provides a content-first approach with an API to access and display the data in any format desired.
You can see the differences between a traditional CMS and a headless CMS in the following diagram:
Figure 1.1: Traditional CMS versus headless CMS
Figure 1.1: Traditional CMS versus headless CMS
"Strapi" is wordplay for Bootstrap API. As the name suggests, it aims to help developers build (bootstrap) an API quickly. Strapi saves API development time through an integrated easy-to-use admin panel and a solid set of core features out of the box. Whether you are a backend, full stack, or frontend developer, you will find it extremely easy to get started with Strapi and API development without reinventing the wheel and wasting time in building common features such as basic create, read, update, and delete (CRUD) operations or authentication and authorization.
Now that we have familiarized ourselves with Strapi, let's see some of the advantages of using it.

Why use Strapi? (The benefits of Strapi)

There are several advantages to using Strapi, and we will outline some of the major benefits and reasons for using it next.

Open-source Node.js

Strapi is open-source and built on top of a popular Node.js framework: Koa. Its code is accessible and easily extendible. It's supported by a thriving company but also by a large community of contributors. You can find Strapi's code on GitHub at https://github.com/strapi/strapi.

Database-agnostic

Strapi can work with different database systems. It can be set up and configured to work with PostgreSQL, MySQL, MongoDB, and SQLite. We will see in Chapter 9, Production-Ready Applications, how we can configure Strapi to work with PostgreSQL.

Customizable (extendable)

Strapi is highly configurable to suit each project's specific requirements. All of the data types are created from scratch through the admin panel. Additionally, the Strapi plugin system makes it easy to extend its functionality with features such as database documenting, image uploads, and email configuration. We will discuss the Strapi plugin system in a later chapter of this book.

RESTful and GraphQL

Strapi provides a REpresentational State Transfer (REST) API out of the box. The API can be consumed from any web client (React, Angular, Vue.js, and so on), mobile applications, or even internet of things (IoT) applications using REST or GraphQL via a plugin.

Users and permissions

Strapi comes with a users and permissions model out of the box that allows you to define which endpoint is available for which user/role. Additionally, you can use Open Authorization (OAuth) to enable authentication via third-party providers such as GitHub, Facebook, Twitter, Google, and many others.
Now that we have understood what Strapi is all about, let's see how we can prepare our development environ...

Table of contents