This package adds endpoints for sections to SexyField.
Sexy-field-api is very powerful when it comes to retrieving the data that you need. Out of the box you can get all the information of your entities, including parent and child entities.
Here are some examples of how you can build your GET requests.
/v1/section/{sectionHandle}/id/{id}
/v1/section/recipe/id/15?fields=id,title,description,recipeType,created,updated
/v1/section/{sectionHandle}
/v1/section/recipe?fields=id,title,description,recipeType,created,updated
/v1/section/fieldvalue/{sectionHandle}/{fieldHandle}
/v1/section/fieldvalue/recipe/recipeType?value=vegan&fields=id,title,description
/v1/section/{sectionHandle}/slug/{slug}
/v1/section/recipe/slug/recipe-20180325?fields=title
The child entity is indicated by the name of the property in the parent entity.
So in this case the recipe
entity has a property called ingredients
The fields name
, amount
, unit
are properties of the ingredient.
/v1/section/recipe/id/3?fields=id,title,description,recipeType,created,updated,ingredients,name,amount,unit
For creating a new recipe, you would have to use a POST request to:
/v1/section/recipe
Content-Type: application/x-www-form-urlencoded
Form data:
form[title]: Black bean soup
form[description]: A delicious soup
form[recipeType]: vegan
See src/config/routing/api.yml
Nex to ?fields=id,field you can add &depth=3 to control the level of depth in which data is returned.