mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-03 19:36:20 +00:00 
			
		
		
		
	Change examples
This commit is contained in:
		
							parent
							
								
									6b57d15b4e
								
							
						
					
					
						commit
						087cd34636
					
				@ -1,8 +1,12 @@
 | 
			
		||||
# API Endpoints
 | 
			
		||||
 | 
			
		||||
When you create a `Content Type` you will have a certain number of REST API endpoints available to interact with it.
 | 
			
		||||
When you create a `Content Type` you will have a certain number of **REST API endpoints** available to interact with it.
 | 
			
		||||
 | 
			
		||||
As an example let's consider the `Restaurant` Content Type for the next steps.
 | 
			
		||||
As an **example** let's consider the `Restaurant` as a **Content Type** and `Openning_hours` as a **Group** for the next steps.
 | 
			
		||||
 | 
			
		||||
:::: tabs cache-lifetime="10" :options="{ useUrlFragment: false }"
 | 
			
		||||
 | 
			
		||||
::: tab "Content Type" id="content-type"
 | 
			
		||||
 | 
			
		||||
### `Restaurant` Content Type
 | 
			
		||||
 | 
			
		||||
@ -12,6 +16,10 @@ As an example let's consider the `Restaurant` Content Type for the next steps.
 | 
			
		||||
| cover         | media  | Restaurant's cover image         |              |
 | 
			
		||||
| opening_hours | group  | Restaurant's opening hours group | `repeatable` |
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::: tab "Group" id="group"
 | 
			
		||||
 | 
			
		||||
### `Opening_hours` Group
 | 
			
		||||
 | 
			
		||||
| Fields       | Type   | Description         |
 | 
			
		||||
@ -20,10 +28,14 @@ As an example let's consider the `Restaurant` Content Type for the next steps.
 | 
			
		||||
| opening_hour | string | Meta's opening hour |
 | 
			
		||||
| closing_hour | string | Meta's closing hour |
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::::
 | 
			
		||||
 | 
			
		||||
## Endpoints
 | 
			
		||||
 | 
			
		||||
Here is the list of endpoints generated for each of your **Content Types**
 | 
			
		||||
 | 
			
		||||
<style lang="stylus">
 | 
			
		||||
#endpoint-table
 | 
			
		||||
  table
 | 
			
		||||
@ -51,20 +63,121 @@ As an example let's consider the `Restaurant` Content Type for the next steps.
 | 
			
		||||
 | 
			
		||||
<div id="endpoint-table">
 | 
			
		||||
 | 
			
		||||
| Method | Path                                         | Description                |
 | 
			
		||||
| :----- | :------------------------------------------- | :------------------------- |
 | 
			
		||||
| GET    | [/restaurants](#get-restaurants)             | Get a list of restaurants  |
 | 
			
		||||
| GET    | [/restaurants/count](#get-restaurants-count) | Count restaurants          |
 | 
			
		||||
| POST   | [/restaurants](#post-restaurants)            | Create a restaurant        |
 | 
			
		||||
| GET    | [/restaurants/:id](#get-restaurants-id)      | Get a specific restraurant |
 | 
			
		||||
| DELETE | [/restaurants/:id](#delete-restaurants-id)   | Delete a restaurant        |
 | 
			
		||||
| PUT    | [/restaurants/:id](#put-restaurants-id)      | Update a restaurant        |
 | 
			
		||||
| Method | Path                                            | Description                          |
 | 
			
		||||
| :----- | :---------------------------------------------- | :----------------------------------- |
 | 
			
		||||
| GET    | [/{content-type}](#get-restaurants)             | Get a list of {content-type} entries |
 | 
			
		||||
| GET    | [/{content-type}/count](#get-restaurants-count) | Count {content-type} entries         |
 | 
			
		||||
| POST   | [/{content-type}](#post-restaurants)            | Create a {content-type} entry        |
 | 
			
		||||
| GET    | [/{content-type}/:id](#get-restaurants-id)      | Get a specific {content-type} entry  |
 | 
			
		||||
| DELETE | [/{content-type}/:id](#delete-restaurants-id)   | Delete a {content-type} entry        |
 | 
			
		||||
| PUT    | [/{content-type}/:id](#put-restaurants-id)      | Update a {content-type} entry        |
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
## GET `/restaurants`
 | 
			
		||||
### Here some Content Type examples
 | 
			
		||||
 | 
			
		||||
Returns the restaurants matching the query filters. You can read more about parameters [here](./parameters.md).
 | 
			
		||||
:::: tabs cache-lifetime="10" :options="{ useUrlFragment: false }"
 | 
			
		||||
 | 
			
		||||
::: tab "Restaurant" id="restaurant"
 | 
			
		||||
 | 
			
		||||
`Restaurant` **Content Type**
 | 
			
		||||
 | 
			
		||||
<div id="endpoint-table">
 | 
			
		||||
 | 
			
		||||
| Method | Path               | Description               |
 | 
			
		||||
| :----- | :----------------- | :------------------------ |
 | 
			
		||||
| GET    | /restaurants       | Get a list of restaurants |
 | 
			
		||||
| GET    | /restaurants/count | Count restaurants         |
 | 
			
		||||
| POST   | /restaurants       | Create a restaurant       |
 | 
			
		||||
| GET    | /restaurants/:id   | Get a specific restaurant |
 | 
			
		||||
| DELETE | /restaurants/:id   | Delete a restaurant       |
 | 
			
		||||
| PUT    | /restaurants/:id   | Update a restaurant       |
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::: tab "Article" id="article"
 | 
			
		||||
 | 
			
		||||
`Article` **Content Type**
 | 
			
		||||
 | 
			
		||||
<div id="endpoint-table">
 | 
			
		||||
 | 
			
		||||
| Method | Path            | Description            |
 | 
			
		||||
| :----- | :-------------- | :--------------------- |
 | 
			
		||||
| GET    | /articles       | Get a list of articles |
 | 
			
		||||
| GET    | /articles/count | Count articles         |
 | 
			
		||||
| POST   | /articles       | Create a article       |
 | 
			
		||||
| GET    | /articles/:id   | Get a specific article |
 | 
			
		||||
| DELETE | /articles/:id   | Delete a article       |
 | 
			
		||||
| PUT    | /articles/:id   | Update a article       |
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::: tab "Product" id="product"
 | 
			
		||||
 | 
			
		||||
`Product` **Content Type**
 | 
			
		||||
 | 
			
		||||
<div id="endpoint-table">
 | 
			
		||||
 | 
			
		||||
| Method | Path            | Description            |
 | 
			
		||||
| :----- | :-------------- | :--------------------- |
 | 
			
		||||
| GET    | /products       | Get a list of products |
 | 
			
		||||
| GET    | /products/count | Count products         |
 | 
			
		||||
| POST   | /products       | Create a product       |
 | 
			
		||||
| GET    | /products/:id   | Get a specific product |
 | 
			
		||||
| DELETE | /products/:id   | Delete a product       |
 | 
			
		||||
| PUT    | /products/:id   | Update a product       |
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::: tab "Category" id="category"
 | 
			
		||||
 | 
			
		||||
`Category` **Content Type**
 | 
			
		||||
 | 
			
		||||
<div id="endpoint-table">
 | 
			
		||||
 | 
			
		||||
| Method | Path              | Description              |
 | 
			
		||||
| :----- | :---------------- | :----------------------- |
 | 
			
		||||
| GET    | /categories       | Get a list of categories |
 | 
			
		||||
| GET    | /categories/count | Count categories         |
 | 
			
		||||
| POST   | /categories       | Create a category        |
 | 
			
		||||
| GET    | /categories/:id   | Get a specific category  |
 | 
			
		||||
| DELETE | /categories/:id   | Delete a category        |
 | 
			
		||||
| PUT    | /categories/:id   | Update a category        |
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::: tab "Tag" id="tag"
 | 
			
		||||
 | 
			
		||||
`Tag` **Content Type**
 | 
			
		||||
 | 
			
		||||
<div id="endpoint-table">
 | 
			
		||||
 | 
			
		||||
| Method | Path        | Description        |
 | 
			
		||||
| :----- | :---------- | :----------------- |
 | 
			
		||||
| GET    | /tags       | Get a list of tags |
 | 
			
		||||
| GET    | /tags/count | Count tags         |
 | 
			
		||||
| POST   | /tags       | Create a tag       |
 | 
			
		||||
| GET    | /tags/:id   | Get a specific tag |
 | 
			
		||||
| DELETE | /tags/:id   | Delete a tag       |
 | 
			
		||||
| PUT    | /tags/:id   | Update a tag       |
 | 
			
		||||
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
:::
 | 
			
		||||
 | 
			
		||||
::::
 | 
			
		||||
 | 
			
		||||
## Get entries
 | 
			
		||||
 | 
			
		||||
Returns entries matching the query filters. You can read more about parameters [here](./parameters.md).
 | 
			
		||||
 | 
			
		||||
**Example request**
 | 
			
		||||
 | 
			
		||||
@ -97,9 +210,9 @@ GET http://localhost:1337/restaurants
 | 
			
		||||
]
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## GET `/restaurants/count`
 | 
			
		||||
## Count entries
 | 
			
		||||
 | 
			
		||||
Returns the count of restaurants matching the query filters. You can read more about parameters [here](./parameters.md).
 | 
			
		||||
Returns the count of entries matching the query filters. You can read more about parameters [here](./parameters.md).
 | 
			
		||||
 | 
			
		||||
**Example response**
 | 
			
		||||
 | 
			
		||||
@ -107,9 +220,9 @@ Returns the count of restaurants matching the query filters. You can read more a
 | 
			
		||||
1
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## POST `/restaurants`
 | 
			
		||||
## Create an entry
 | 
			
		||||
 | 
			
		||||
Creates a restaurant and returns its value.
 | 
			
		||||
Creates an entry and returns its value.
 | 
			
		||||
 | 
			
		||||
**Example request**
 | 
			
		||||
 | 
			
		||||
@ -153,9 +266,9 @@ POST http://localhost:1337/restaurants
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## GET `/restaurants/:id`
 | 
			
		||||
## Get an entry
 | 
			
		||||
 | 
			
		||||
Returns a restaurant by id.
 | 
			
		||||
Returns an entry by id.
 | 
			
		||||
 | 
			
		||||
**Example request**
 | 
			
		||||
 | 
			
		||||
@ -185,9 +298,9 @@ GET http://localhost:1337/restaurants/1
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## PUT `/restaurants/:id`
 | 
			
		||||
## Update an entry
 | 
			
		||||
 | 
			
		||||
Partially updates a restaurant by id and returns its value.
 | 
			
		||||
Partially updates an entry by id and returns its value.
 | 
			
		||||
Fields that aren't sent in the query are not changed in the db. Send a `null` value if you want to clear them.
 | 
			
		||||
 | 
			
		||||
**Example request**
 | 
			
		||||
@ -245,9 +358,9 @@ PUT http://localhost:1337/restaurants/1
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## DELETE `/restaurants/:id`
 | 
			
		||||
## Delete an entry
 | 
			
		||||
 | 
			
		||||
Deletes a restaurant by id and returns its value.
 | 
			
		||||
Deletes an entry by id and returns its value.
 | 
			
		||||
 | 
			
		||||
**Example request**
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user