Ga naar hoofdinhoud

Menus API

De Menus API biedt endpoints voor het beheren van menu's en menu-items in Joomla.

Base URL

/api/index.php/v1/menus

Endpoints Overzicht

MethodeEndpointBeschrijving
GET/menus/siteAlle site menu's ophalen
GET/menus/site/{id}Specifiek menu ophalen
POST/menus/siteNieuw menu aanmaken
PATCH/menus/site/{id}Menu bijwerken
DELETE/menus/site/{id}Menu verwijderen
MethodeEndpointBeschrijving
GET/menus/site/itemsAlle menu-items ophalen
GET/menus/site/items/{id}Specifiek menu-item ophalen
POST/menus/site/itemsNieuw menu-item aanmaken
PATCH/menus/site/items/{id}Menu-item bijwerken
DELETE/menus/site/items/{id}Menu-item verwijderen

Alle menu's ophalen

GET /api/index.php/v1/menus/site

Response

{
"data": [
{
"type": "menus",
"id": "1",
"attributes": {
"menutype": "mainmenu",
"title": "Hoofdmenu",
"description": "Het hoofdmenu van de site"
}
}
]
}
POST /api/index.php/v1/menus/site

Request Body

{
"menutype": "footermenu",
"title": "Footer Menu",
"description": "Menu items in de footer"
}

Verplichte velden

VeldTypeBeschrijving
menutypestringUnieke identifier voor het menu
titlestringTitel van het menu

Voorbeeld

curl -X POST "https://jouwesite.nl/api/index.php/v1/menus/site" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"menutype": "footermenu",
"title": "Footer Menu"
}'

Alle menu-items ophalen

GET /api/index.php/v1/menus/site/items

Response

{
"data": [
{
"type": "menu-items",
"id": "101",
"attributes": {
"title": "Home",
"alias": "home",
"menutype": "mainmenu",
"type": "component",
"link": "index.php?option=com_content&view=featured",
"published": 1,
"parent_id": 1,
"level": 1,
"component_id": 22,
"language": "*"
}
}
]
}
POST /api/index.php/v1/menus/site/items
{
"title": "Over Ons",
"alias": "over-ons",
"menutype": "mainmenu",
"type": "component",
"link": "index.php?option=com_content&view=article&id=1",
"parent_id": 1,
"published": 1,
"access": 1,
"language": "*"
}

Request Body voor externe URL

{
"title": "Externe Link",
"alias": "externe-link",
"menutype": "mainmenu",
"type": "url",
"link": "https://example.com",
"parent_id": 1,
"published": 1
}

Request Body voor separator

{
"title": "---",
"menutype": "mainmenu",
"type": "separator",
"parent_id": 1
}

Verplichte velden

VeldTypeBeschrijving
titlestringTitel van het menu-item
menutypestringMenu waar item bij hoort
typestringType (component/url/separator)
linkstringLink URL (behalve separator)

Optionele velden

VeldTypeStandaardBeschrijving
aliasstringautoURL-vriendelijke naam
parent_idint1Parent menu-item ID
publishedint1Publicatiestatus
accessint1Toegangsniveau
languagestring"*"Taalcode
browserNavint0Open in: 0=zelfde, 1=nieuw

Voorbeeld

curl -X POST "https://jouwesite.nl/api/index.php/v1/menus/site/items" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Contact",
"alias": "contact",
"menutype": "mainmenu",
"type": "component",
"link": "index.php?option=com_contact&view=contact&id=1",
"published": 1
}'
PATCH /api/index.php/v1/menus/site/items/{id}

Voorbeeld

curl -X PATCH "https://jouwesite.nl/api/index.php/v1/menus/site/items/101" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Nieuwe Titel",
"published": 0
}'
DELETE /api/index.php/v1/menus/site/items/{id}
TypeBeschrijving
componentLink naar Joomla component
urlExterne of interne URL
aliasAlias naar ander menu-item
separatorScheidingslijn
headingKoptekst (niet klikbaar)

Artikel

index.php?option=com_content&view=article&id={article_id}

Categorie blog

index.php?option=com_content&view=category&layout=blog&id={category_id}

Categorie lijst

index.php?option=com_content&view=category&id={category_id}

Contact

index.php?option=com_contact&view=contact&id={contact_id}

Alle contacten

index.php?option=com_contact&view=categories

Filtering

Op menu type

GET /api/index.php/v1/menus/site/items?filter[menutype]=mainmenu

Op publicatiestatus

GET /api/index.php/v1/menus/site/items?filter[published]=1

Op parent

GET /api/index.php/v1/menus/site/items?filter[parent_id]=1

Gebruik parent_id om submenu's te maken.

Voorbeeld: Submenu item

curl -X POST "https://jouwesite.nl/api/index.php/v1/menus/site/items" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Sub Item",
"menutype": "mainmenu",
"type": "url",
"link": "/sub-pagina",
"parent_id": 101
}'