Getting started overview

Getting started with Strapi involves either deploying a self-hosted instance or subscribing to Strapi Cloud. Both options lead to setting up content types and exposing them via a RESTful API. The following steps provide a quick reference for the initial setup:

Step What to Do Where
1. Choose Deployment Decide between self-hosting (Community/Enterprise) or Strapi Cloud. Strapi Cloud pricing page or Strapi installation documentation
2. Install/Subscribe Follow installation instructions for self-host or subscribe to Strapi Cloud. Strapi CLI installation guide or Strapi Cloud subscription
3. Initial Setup Create your first administrator account after installation or cloud setup. Local installation prompt or Strapi Cloud dashboard
4. Create Content Type Define a content type (e.g., 'Article', 'Product') with fields. Strapi Admin Panel: Content-Type Builder
5. Add Content Entry Create an entry for your new content type. Strapi Admin Panel: Content Manager
6. Configure Permissions Set public read permissions for the content type. Strapi Admin Panel: Settings > Users & Permissions Plugin > Roles > Public
7. Make API Call Send a GET request to retrieve your content. Any HTTP client (e.g., cURL, Postman, browser)

Create an account and get keys

There are two primary ways to set up Strapi: self-hosting or using Strapi Cloud.

Self-hosting Strapi Community Edition

The Strapi Community Edition is open-source and can be self-hosted, providing full control over the environment. This typically involves using the Strapi CLI to create a new project:

npx create-strapi-app@latest my-project --quickstart

This command initializes a new Strapi project and starts the server. Upon successful startup, Strapi automatically opens a browser window to http://localhost:1337/admin, where you will be prompted to create your first administrator account. This account is used to access the Strapi Admin Panel, manage content types, and configure API settings. No separate API keys are generated at this stage; API access is managed through user roles and permissions which are configured within the admin panel. For detailed installation instructions, refer to the Strapi CLI installation guide.

Using Strapi Cloud

Strapi Cloud offers a managed environment, abstracting away infrastructure concerns. To get started with Strapi Cloud, you would:

  1. Navigate to the Strapi Cloud pricing page and choose a plan.
  2. Sign up for an account. This process typically involves providing an email address and creating a password.
  3. Once signed up, you will be guided through the process of creating your first Strapi Cloud project.
  4. During the project creation, you will set up your administrator account for that specific cloud instance.

Similar to self-hosting, API keys for specific content access are not generated at the account creation stage but are configured within the Strapi Admin Panel after your project is set up. Strapi Cloud handles the underlying infrastructure, allowing users to focus on content modeling and API consumption.

Your first request

After setting up your Strapi instance and creating your administrator account, the next step is to define content and expose it via the API. This involves creating a content type, adding an entry, and configuring permissions.

1. Create a Content Type

From the Strapi Admin Panel (e.g., http://localhost:1337/admin for self-hosted or your cloud instance URL for Strapi Cloud):

  • Navigate to Content-Type Builder in the left sidebar.
  • Click Create new collection type.
  • Give your content type a singular name (e.g., product) and a plural name (e.g., products).
  • Click Continue.
  • Add at least one field, such as a Text field named name.
  • Click Finish and then Save. Strapi will restart to apply the changes.

2. Add Content Entries

Once the content type is created:

  • Go to Content Manager in the left sidebar.
  • Select your newly created content type (e.g., Products).
  • Click Create new entry.
  • Fill in the fields you defined (e.g., a name for your product).
  • Click Save and then Publish.

3. Configure Permissions

By default, content types are not publicly accessible via the API. You need to enable read permissions:

  • Navigate to Settings in the left sidebar.
  • Under Users & Permissions Plugin, click on Roles.
  • Click on the Public role.
  • Find your content type (e.g., Product) in the list of permissions.
  • Check the find and findOne checkboxes for your content type.
  • Click Save.

4. Make the API Request

Now you can make a GET request to retrieve your content. The API endpoint will follow the pattern /api/[plural-content-type-name]. For example, if your content type is product, the endpoint would be /api/products.

Example using cURL:

curl -X GET 'http://localhost:1337/api/products'

Replace http://localhost:1337 with your Strapi Cloud instance URL if applicable. The response will be a JSON array containing your content entries.

Common next steps

After successfully making your first API call, consider these common next steps to further develop your application with Strapi:

  • Advanced Content Modeling: Explore more complex fields, relationships between content types, and components to structure your content effectively. The Strapi content modeling guide provides detailed information on these features.
  • User Authentication and Authorization: Implement user registration, login, and secure authenticated API endpoints. Strapi has a built-in Users & Permissions plugin that facilitates this. For information on securing API endpoints, refer to the Strapi API user roles and permissions documentation.
  • Custom Controllers and Services: Extend Strapi's default API behavior by writing custom controllers and services to implement specific business logic or integrate with external services. This allows for tailored API responses and data manipulation. The Strapi backend development documentation for controllers offers guidance.
  • Webhooks: Set up webhooks to trigger external actions when content changes in Strapi. This is useful for cache invalidation, external search indexing, or publishing content to other platforms. Learn more about Strapi webhook configuration. Using webhooks securely often involves validating the sender, similar to how Twilio's webhook security guide recommends signature verification.
  • Plugin Development: For highly specific functionality not covered by existing features, develop custom plugins. Strapi's plugin architecture allows for deep customization and integration into the admin panel and API. Information on creating plugins is available in the Strapi quick start guide for plugin development.
  • Deployment to Production: Plan your production deployment strategy. This includes considerations for database setup, environment variables, server configuration (e.g., Nginx or Apache), and continuous integration/continuous deployment (CI/CD) pipelines. Strapi offers deployment guides for various platforms.

Troubleshooting the first call

If your first API call to Strapi does not return the expected results, consider the following common issues and troubleshooting steps:

  • Server Not Running: Ensure your Strapi instance is actively running. For self-hosted instances, check the terminal where you started Strapi for any error messages. If using Strapi Cloud, verify your project's status in the cloud dashboard.
  • Incorrect URL: Double-check the base URL (http://localhost:1337 or your Strapi Cloud domain) and the API endpoint path (e.g., /api/products). Typos are common.
  • Content Type Not Found: The API endpoint must match the plural name of your content type exactly. If your content type is singular 'Product', the API endpoint is typically 'products'.
  • No Content Entries: Ensure you have published at least one entry for the content type you are trying to retrieve. Unpublished content will not appear in public API responses.
  • Permissions Issue: This is a frequent cause of empty or unauthorized responses. Verify that the 'Public' role has find and findOne permissions enabled for your specific content type in Settings > Users & Permissions Plugin > Roles > Public.
  • Firewall or Network Issues: If you are trying to access a self-hosted Strapi instance from a different machine, ensure that your firewall allows traffic on port 1337 (or whichever port Strapi is configured to use).
  • CORS Policy: If you are making requests from a web browser and encountering Cross-Origin Resource Sharing (CORS) errors, you may need to configure Strapi's CORS settings. Strapi has a configuration file (e.g., config/middlewares.js) where you can adjust allowed origins. More information on Strapi API requests and configurations can be found in the official documentation.
  • Strapi Restart Required: After making changes in the Content-Type Builder or to certain configuration files, Strapi may require a restart to apply the changes. For self-hosted instances, stop and restart the server.
  • Check Server Logs: Review the server logs for your Strapi instance for more detailed error messages. These logs can provide specific insights into why a request failed.