{"id":68775,"date":"2024-12-10T13:17:11","date_gmt":"2024-12-10T07:47:11","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=68775"},"modified":"2025-12-04T11:12:49","modified_gmt":"2025-12-04T05:42:49","slug":"getting-started-with-strapi-cms-a-comprehensive-guide-for-developers","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/getting-started-with-strapi-cms-a-comprehensive-guide-for-developers\/","title":{"rendered":"Getting Started with Strapi CMS: A Comprehensive Guide for Developers"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p><a href=\"https:\/\/www.tothenew.com\/blog\/creating-a-simple-dynamic-form-using-data-from-strapi-cms\/\">Strapi CMS<\/a> is a headless, <a href=\"https:\/\/www.tothenew.com\/cx\">open-source content management system<\/a> designed for modern <a href=\"https:\/\/www.tothenew.com\/digital-engineering\/web-development\">web<\/a> and <a href=\"https:\/\/www.tothenew.com\/digital-engineering\/mobility\">mobile applications<\/a>. Unlike traditional CMS platforms, <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> is a modern tool where the part that manages content (backend) is separated from the part users see (frontend). This lets developers choose any design or technology for their website or app while <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> takes care of managing the content. It provides a robust API-first architecture that supports REST and GraphQL, allowing seamless integration with various tools and frameworks.<\/p>\n<p><a href=\"https:\/\/strapi.io\/\">Strapi<\/a>\u2019s flexibility lies in its customizable nature you can easily create and manage content types, extend its functionality with plugins, and even connect it to any database of your choice. With a user-friendly admin panel, content creators can manage content efficiently, while developers enjoy full control over the project structure and codebase. Whether you\u2019re building a website, a<a href=\"https:\/\/www.tothenew.com\/digital-engineering\/mobility\"> mobile app<\/a>, or an <a href=\"https:\/\/www.tothenew.com\/industries\/ecommerce\">eCommerce<\/a> platform, <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> empowers you to deliver scalable and flexible solutions.<\/p>\n<h3>Key Features &amp; Why Do We Need Strapi CMS<\/h3>\n<p><a href=\"https:\/\/www.tothenew.com\/blog\/creating-a-simple-dynamic-form-using-data-from-strapi-cms\/\">Strapi<\/a> simplifies content management in modern web development with its headless architecture. Here\u2019s why developers love it:<\/p>\n<ul>\n<li><strong>Customization:<\/strong> Fully customizable through plugins and extensions.<\/li>\n<li><strong>API-first:<\/strong> Automatically generates RESTful or GraphQL APIs.<\/li>\n<li><strong>Headless Architecture:<\/strong> Decouples backend and frontend for flexibility.<\/li>\n<li><strong>Ease of Use:<\/strong> Simple admin panel for managing content.<\/li>\n<li><strong>Flexibility:<\/strong> Allows you to use any frontend framework or library.<\/li>\n<li><strong>Scalability:<\/strong> Ideal for large-scale applications with diverse content needs.<\/li>\n<li><strong>Open-Source:<\/strong> Free to use with a growing community.<\/li>\n<\/ul>\n<h3>Easy Content Management with Strapi<\/h3>\n<p><a href=\"https:\/\/strapi.io\/\">Strapi<\/a> makes managing website or app content simple, even for non-technical users. Its user-friendly admin panel allows content managers, marketers, and business owners to update and organize content without writing any code.<\/p>\n<ul>\n<li><strong>Easy Updates:<\/strong> Add, edit, or delete content quickly through an intuitive dashboard.<\/li>\n<li><strong>Content Organization:<\/strong> Keep everything structured and accessible without technical know-how.<\/li>\n<li><strong>Collaboration Tools:<\/strong> Assign roles and permissions to team members for smooth teamwork.<\/li>\n<li><strong>Quick Publishing:<\/strong> Publish, unpublish, or schedule content with a few clicks.<\/li>\n<\/ul>\n<h3>How to Set Up and Install Strapi CMS<\/h3>\n<p><strong>Prerequisites:<\/strong><\/p>\n<p>Before you install <a href=\"https:\/\/strapi.io\/\">Strapi<\/a>, ensure the following tools and technologies are installed on your system:<\/p>\n<p><strong>1. Node.js:<\/strong> <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> requires a minimum Node.js version to operate. At the time of writing, Node.js version 14 or higher is supported. for future release and support always check the official document (<a href=\"https:\/\/docs.strapi.io\/dev-docs\/deployment\">Strapi General Requirement<\/a>) for the latest version requirement.<\/p>\n<pre>node -v # To check Node.js version<\/pre>\n<p><strong>2. npm or yarn:<\/strong> Installed alongside Node.js. Use either for package management.<\/p>\n<pre>npm -v # To check npm version\r\nyarn -v # To check yarn version (if installed)<\/pre>\n<p><strong>3. Database:<\/strong> <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> uses SQLite as the default database its a lightweight, file-based database. <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> supports multiple databases, such as SQLite, MongoDB, MySQL, and PostgreSQL. It simplifies the setup process and is ideal for quick development.<\/p>\n<p><strong>Why Use an External Database:<\/strong><\/p>\n<ul>\n<li><strong>Scalability:<\/strong> External databases handle large volumes of data and concurrent requests more efficiently.<\/li>\n<li><strong>Performance:<\/strong> Optimized for high-read and high-write operations in demanding environments.<\/li>\n<li><strong>Features:<\/strong> Support for advanced features like replication, clustering, and advanced querying.<\/li>\n<\/ul>\n<p><strong>Step 1:<\/strong> <strong>Install Strapi CMS<\/strong><br \/>\nYou can install <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> using the npx command or manually through npm\/yarn.<\/p>\n<pre>npx create-strapi-app my-project<\/pre>\n<p><strong>create-strapi-app:<\/strong> The official tool to generate a new <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> project.<br \/>\n<strong>my-project:<\/strong> The folder name for your project.<\/p>\n<p><strong>Installation Reference Link:<\/strong> &#8211;\u00a0<a href=\"https:\/\/docs.strapi.io\/dev-docs\/installation\/cli\">Official Documentation<\/a><\/p>\n<h3>Understanding the Project Structure<\/h3>\n<p>Here\u2019s a breakdown of the folder structure created by <a href=\"https:\/\/strapi.io\/\">Strapi<\/a>:<\/p>\n<ul>\n<li><strong>src\/:<\/strong> Contains all the source code for APIs, components, and configurations.<br \/>\n<strong>&#8211; api\/:<\/strong> Stores auto-generated and custom APIs.<br \/>\n<strong>&#8211; components\/:<\/strong> Defines reusable components for content types.<br \/>\n<strong>&#8211; extensions\/:<\/strong> Contains plugins or customizations.<\/li>\n<li><strong>config\/:<\/strong> Stores environment-specific configurations.<\/li>\n<li><strong>node_modules\/:<\/strong> Contains installed dependencies.<\/li>\n<li><strong>package.json:<\/strong> Lists project dependencies and scripts.<\/li>\n<\/ul>\n<p><strong>Note:<\/strong> <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> uses a <strong>cache<\/strong> folder to store temporary data that helps improve performance by reducing the need to re-fetch or recompute certain information. Caching mechanisms can include things like database query results, API responses, or content data that doesn&#8217;t change frequently.<\/p>\n<div id=\"attachment_68898\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68898\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68898 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-02-1024x396.png\" alt=\"Strapi Folder Structure\" width=\"625\" height=\"242\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-02-1024x396.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-02-300x116.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-02-768x297.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-02-1536x594.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-02-624x241.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-02.png 1586w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68898\" class=\"wp-caption-text\">Strapi Folder Structure<\/p><\/div>\n<div id=\"attachment_68897\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68897\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68897 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-19-1024x392.png\" alt=\"Src Folder Structure\" width=\"625\" height=\"239\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-19-1024x392.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-19-300x115.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-19-768x294.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-19-1536x587.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-19-624x239.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Screenshot-from-2024-12-02-14-18-19.png 1587w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68897\" class=\"wp-caption-text\">Src Folder Structure<\/p><\/div>\n<p><strong>Step 2:<\/strong> <strong>Start the Development Server<\/strong><br \/>\nOnce the installation is complete, start the <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> development server:<\/p>\n<pre>cd my-project\r\nnpm run develop # This command runs Strapi in development mode, which allows live reloading of changes.<\/pre>\n<p>By Default The admin panel is accessible at <strong>localhost:1337\/admin<\/strong><\/p>\n<p><strong>Step 3:<\/strong> <strong>Create an Admin Account<\/strong><br \/>\nAfter launching, <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> will prompt you to create an admin account to access the dashboard.<br \/>\nFill in all the details and click <strong>Let&#8217;s Start<\/strong><\/p>\n<div id=\"attachment_68806\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68806\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68806 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-56-27-1024x583.png\" alt=\"Account Creation\" width=\"625\" height=\"356\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-56-27-1024x583.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-56-27-300x171.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-56-27-768x437.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-56-27-1536x875.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-56-27-624x355.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-56-27.png 1593w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68806\" class=\"wp-caption-text\">Account Creation<\/p><\/div>\n<p>After creating an admin account you will be redirected to the <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> dashboard &#8211;<\/p>\n<div id=\"attachment_68807\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68807\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68807 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Dashboard-1024x483.png\" alt=\"Strapi Dashboard\" width=\"625\" height=\"295\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Dashboard-1024x483.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Dashboard-300x142.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Dashboard-768x362.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Dashboard-1536x725.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Dashboard-624x294.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Dashboard.png 1850w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68807\" class=\"wp-caption-text\">Strapi Dashboard<\/p><\/div>\n<h2>What is Collection Types and How to Create It:<\/h2>\n<p><strong>Collection Types<\/strong> in <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> define the structure of your content, similar to tables in a database.<\/p>\n<ul>\n<li><strong>Content-Type Builder:<\/strong> This is where you define the structure of your content, such as creating new content types (e.g., blog, events) and adding fields (e.g., text, rich text, date). It provides a flexible interface to design the data model for your application<\/li>\n<li><strong>Content Manager:<\/strong> Once content types are defined, the Content Manager allows you to handle the actual data. You can add new entries, edit existing ones, and delete data directly from an intuitive interface designed for non-technical users.<\/li>\n<li><strong>Components:<\/strong> Components are reusable groups of fields that can be shared across multiple content types. For instance, a &#8220;Banner&#8221; component with image and video fields can be added to various content types.<\/li>\n<\/ul>\n<div id=\"attachment_68794\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68794\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68794 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/collection-types-1024x421.png\" alt=\"collection type\" width=\"625\" height=\"257\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/collection-types-1024x421.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/collection-types-300x123.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/collection-types-768x316.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/collection-types-1536x632.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/collection-types-624x257.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/collection-types.png 1833w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68794\" class=\"wp-caption-text\">collection types<\/p><\/div>\n<p><strong>Steps to Create Collection Type:<\/strong><\/p>\n<p><strong>1. Go to the Admin Panel:<\/strong> Navigate to the admin panel and click on &#8220;<strong>Content-Types Builder<\/strong>&#8220;.<br \/>\n<strong>2. Add a New Collection Type:<\/strong><br \/>\n&#8211; Click Create new collection type.<br \/>\n&#8211; Name the collection (e.g., Event).<br \/>\n<strong>3. Add Fields: <\/strong><a href=\"https:\/\/strapi.io\/\">Strapi<\/a> provides many fields like the below image<\/p>\n<div id=\"attachment_68809\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68809\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68809 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-20-10-02-1024x474.png\" alt=\"Strapi Fields\" width=\"625\" height=\"289\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-20-10-02-1024x474.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-20-10-02-300x139.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-20-10-02-768x355.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-20-10-02-1536x710.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-20-10-02-624x289.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-20-10-02.png 1849w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68809\" class=\"wp-caption-text\">Strapi Fields<\/p><\/div>\n<p>Here I have added 2 fields for the Event collection-type :<br \/>\n&#8211; EventName (Text)<br \/>\n&#8211; Details (Rich Text)<\/p>\n<div id=\"attachment_68801\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68801\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68801 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Field-Save-1024x356.png\" alt=\"Adding Field\" width=\"625\" height=\"217\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Field-Save-1024x356.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Field-Save-300x104.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Field-Save-768x267.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Field-Save-1536x533.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Field-Save-624x217.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Field-Save.png 1840w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68801\" class=\"wp-caption-text\">Adding Field<\/p><\/div>\n<p><strong>4. Save:<\/strong> Save the collection, and <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> will automatically create the API endpoints.<\/p>\n<h3>How to Create Page Using Content Manager:<\/h3>\n<ul>\n<li><strong>Go to the Admin Panel:<\/strong> Navigate to the admin panel and click on &#8220;<strong>Content Manager<\/strong>&#8220;.<\/li>\n<li><strong>Choose Content Type:<\/strong> Select the content type (e.g., \u201c<strong>Event<\/strong>\u201d) where you want to add a new entry.<\/li>\n<li><strong>Create New Entry:<\/strong> Click Create <strong>New Entry<\/strong> to open the form.<\/li>\n<li><strong>Fill Details:<\/strong> Add content in the required fields (e.g., EventName, Detail, Banner).<\/li>\n<li><strong>Save &amp; Publish:<\/strong> Save the entry and publish it to make it accessible via the API.<\/li>\n<\/ul>\n<div id=\"attachment_68911\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68911\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68911 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/12\/Strapi-Banner-1024x759.png\" alt=\"Event Page\" width=\"625\" height=\"463\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/12\/Strapi-Banner-1024x759.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Strapi-Banner-300x222.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Strapi-Banner-768x570.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Strapi-Banner-1536x1139.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Strapi-Banner-624x463.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/12\/Strapi-Banner.png 1858w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68911\" class=\"wp-caption-text\">Event Page<\/p><\/div>\n<h3>Authorize Collection To Access The API&#8217;s<\/h3>\n<p><a href=\"https:\/\/strapi.io\/\">Strapi<\/a> provides built-in authentication and authorization features to secure APIs.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Features<\/span>:<\/strong><br \/>\n<strong>JWT (JSON Web Token):<\/strong> Used for secure API interactions.<br \/>\n<strong>Role-Based Access Control (RBAC):<\/strong> Define roles (e.g., public, authenticated) for accessing resources.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Example<\/span>:<br \/>\n<\/strong><strong>1. Enable Authentication for an API:<\/strong><br \/>\nIn the admin panel, navigate to <strong>Settings &gt; Roles<\/strong>.<br \/>\nConfigure the permissions for public or authenticated roles.<\/p>\n<div id=\"attachment_68796\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68796\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68796 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Authentication-Image-1024x513.png\" alt=\"Authentication-Image\" width=\"625\" height=\"313\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Authentication-Image-1024x513.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Authentication-Image-300x150.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Authentication-Image-768x385.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Authentication-Image-1536x770.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Authentication-Image-624x313.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Authentication-Image.png 1853w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68796\" class=\"wp-caption-text\">Authentication-Image<\/p><\/div>\n<div id=\"attachment_68797\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68797\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68797 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Api-Permission-image-1024x514.png\" alt=\"Api-Permission\" width=\"625\" height=\"314\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Api-Permission-image-1024x514.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Api-Permission-image-300x150.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Api-Permission-image-768x385.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Api-Permission-image-1536x770.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Api-Permission-image-624x313.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Api-Permission-image.png 1852w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68797\" class=\"wp-caption-text\">Api-Permission<\/p><\/div>\n<p>An Event collection will generate the following API endpoints as shown in the above image:<\/p>\n<pre><strong>create<\/strong> =&gt; [POST] \/api\/events\r\n<strong>find<\/strong> =&gt; [GET] \/api\/events\r\n<strong>update<\/strong> =&gt; [PUT] \/api\/events\/:id\r\n<strong>delete<\/strong> =&gt; [DELETE] \/api\/events\/:id\r\n<strong>findOne<\/strong> =&gt; [GET] \/api\/events\/:id<\/pre>\n<p><strong>2. Generate JWT:<\/strong><br \/>\nUse the \/auth\/local endpoint to authenticate users:<\/p>\n<div id=\"attachment_68798\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68798\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68798 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Postman-Auth-Local-Image-1024x593.png\" alt=\"JWT Token\" width=\"625\" height=\"362\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Postman-Auth-Local-Image-1024x593.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Postman-Auth-Local-Image-300x174.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Postman-Auth-Local-Image-768x445.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Postman-Auth-Local-Image-624x361.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Postman-Auth-Local-Image.png 1408w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68798\" class=\"wp-caption-text\">JWT Token<\/p><\/div>\n<pre>POST localhost:1337\/api\/auth\/local\r\n{\r\n\"identifier\": \"&lt;username&gt;\",\r\n\"password\": \"&lt;password&gt;\"\r\n}<\/pre>\n<p>The response will include a JWT token like the above image.<\/p>\n<p><strong>3. Use JWT for API Requests:<\/strong> Include the token in the Authorization header:<\/p>\n<pre>GET localhost:1337\/api\/event\r\nAuthorization: Bearer &lt;JWT_TOKEN&gt;<\/pre>\n<h3>How to Fetch Strapi Data as an API<\/h3>\n<p>Once you\u2019ve created your Event collection type and added data, you can use Postman to test and fetch the data via <a href=\"https:\/\/strapi.io\/\">Strapi<\/a>\u2019s API. Follow these steps:<\/p>\n<ul>\n<li>Open Postman<\/li>\n<li>Set the request method to <strong>GET<\/strong>.<\/li>\n<li>Enter the API endpoint <strong>localhost:1337\/api\/events<\/strong> in the URL field.<\/li>\n<li>Click <strong>Send<\/strong> to make the request.<\/li>\n<\/ul>\n<div id=\"attachment_68803\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68803\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68803 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-32-30-1024x626.png\" alt=\"API Response\" width=\"625\" height=\"382\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-32-30-1024x626.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-32-30-300x183.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-32-30-768x469.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-32-30-624x381.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-32-30.png 1425w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68803\" class=\"wp-caption-text\">API Response<\/p><\/div>\n<p>As you can see in the above image we have all the event data in json.<br \/>\nif you want to fetch only a single entry then we have to pass it by the end of the endpoint like the below &#8211;<\/p>\n<p><strong>[GET] \/api\/events\/:id (localhost:1340\/api\/events\/2)<\/strong><\/p>\n<div id=\"attachment_68804\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-68804\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-68804 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-40-13-1024x626.png\" alt=\"API Result By ID\" width=\"625\" height=\"382\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-40-13-1024x626.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-40-13-300x183.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-40-13-768x469.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-40-13-624x381.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/11\/Screenshot-from-2024-11-26-19-40-13.png 1425w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-68804\" class=\"wp-caption-text\">API Result By ID<\/p><\/div>\n<h2><\/h2>\n<h3>Conclusion<\/h3>\n<p><a href=\"https:\/\/strapi.io\/\">Strapi<\/a> CMS stands out as a powerful, flexible, and modern solution for building content-rich applications. Its headless architecture, coupled with an intuitive admin interface, makes it ideal for both developers and content managers. With support for REST and GraphQL APIs, customizable content types, and multi-database compatibility, <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> offers unparalleled scalability and versatility. Whether you\u2019re developing a web app, mobile app, or API-driven platform, <a href=\"https:\/\/strapi.io\/\">Strapi<\/a> streamlines your workflow and accelerates development.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Strapi CMS is a headless, open-source content management system designed for modern web and mobile applications. Unlike traditional CMS platforms, Strapi is a modern tool where the part that manages content (backend) is separated from the part users see (frontend). This lets developers choose any design or technology for their website or app while [&hellip;]<\/p>\n","protected":false},"author":1708,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":156},"categories":[5876],"tags":[5084,5439,6901],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/68775"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1708"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=68775"}],"version-history":[{"count":23,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/68775\/revisions"}],"predecessor-version":[{"id":76975,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/68775\/revisions\/76975"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=68775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=68775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=68775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}