Simply copy and paste the following command line in your terminal to create your first Strapi project.
npx create-strapi-app my-project
Today I am writing a short article which I hope will be useful for the Strapi community.
Many users discovering Strapi are beginners in programming or are not familiar enough with certain web concepts. Our product is based on some of them and more precisely one that I am about to explain in this article: REST APIs.
To understand why my answer to this question is 99% of the time a big "Yes", I have to tell you about what a REST API is.
Little hint: It is about asking something to a system and expecting an answer from it.
API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. In case you want to connect a React application with Strapi, we say that React is the client and Strapi the system. Indeed, React will communicate with Strapi, by making HTTP requests to the system API. Strapi will then give a response back to your client, here, your React application.
Let's say your Strapi application contains restaurants and you want to list them in your React application. All you need to do is to make an HTTP request to Strapi which will take care to give you a response in JSON format containing your restaurants.
An API is neither more nor less than a series of routes allowing you to interact with your data. If you create a restaurant collection-type on Strapi, you will have these routes by default:
1 2 3 4 5 6GET /restaurant - Get a list of restaurants GET /restaurants/:id - Get a specific restaurant GET /restaurants/count - Count restaurants POST /restaurants - Create a restaurant DELETE /restaurants/:id - Delete a restaurant PUT /restaurants/:id - Update a restaurant
DELETE are HTTP request methods you can use to inform Strapi of what you want to do with your data.
Let's say you want to list all your restaurants from your React application, then you just need to call this route:
http://localhost:1337/restaurants with the
GET method. If you want to create a restaurant not from your admin but directly from your React application you will need to call the same route:
http://localhost:1337/restaurants but this time with the
POST method as well as the parameters necessary to create a restaurant (name, description, etc...).
I redirect you to the documentation which perfectly lists all the API endpoints for your collection types.
Young developer: So, can I use Strapi with Ruby? Or 11ty?
As long as the technology you are using can make HTTP requests via an HTTP client then yes, you can use Strapi with it. It's that simple. Ruby has for example HTTParty which is an HTTP client allowing to perform HTTP requests, so Ruby is perfectly able to communicate with a Strapi app with for example:
response = HTTParty.get("http://localhost:1337/restaurants")
Your HTTP client will simply receive the response from your Strapi API and you will be able to interact with it from your Ruby application. You can also do the same for Python, PHP and many others programming languages.
Concerning Static site generators, most of them use dedicated plugins to fetch data from external sources like Strapi. In fact when Gatsby, Gridsome or 11ty will build your website, it will execute HTTP requests to your Strapi API in order to fetch your data.
The documentation now has an integration section containing some examples on how to integrate Strapi with your favorite programming language or static site generators. Here is a list of integrations present for now:
Do not hesitate to contribute to this list by making a pull request on our documentation in order to enrich it as much as possible.
I only talked about one way to interact with your data on Strapi which is with the REST API but you can actually use another method which is GraphQL. In fact Strapi has a GraphQL plugin allowing you to directly interact with your data not using the REST API but using this technology instead, but we will see that in a next article...
Maxime started to code in 2015 and quickly joined the Growth team of Strapi. He particularly likes to create useful content for the awesome Strapi community. Send him a meme on Twitter to make his day: @MaxCastres
Get all the latest Strapi updates, news and events.