Site

Site#

The @site endpoint provides general site-wide information, such as the site title, logo, and other information. It uses the zope2.View permission, which requires appropriate authorization.

Send a GET request to the @site endpoint:

http

GET /plone/@site HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0

curl

curl -i -X GET http://nohost/plone/@site -H "Accept: application/json" --user admin:secret

httpie

http http://nohost/plone/@site Accept:application/json -a admin:secret

python-requests

requests.get('http://nohost/plone/@site', headers={'Accept': 'application/json'}, auth=('admin', 'secret'))

The response will contain the site information:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "@id": "http://localhost:55001/plone/@site",
    "features": {
        "filter_aliases_by_date": true,
        "multilingual": false
    },
    "plone.allowed_sizes": [
        "huge 1600:65536",
        "great 1200:65536",
        "larger 1000:65536",
        "large 800:65536",
        "teaser 600:65536",
        "preview 400:65536",
        "mini 200:65536",
        "thumb 128:128",
        "tile 64:64",
        "icon 32:32",
        "listing 16:16"
    ],
    "plone.available_languages": [
        "en",
        "de",
        "es",
        "fr"
    ],
    "plone.default_language": "en",
    "plone.portal_timezone": "UTC",
    "plone.robots_txt": "Sitemap: {portal_url}/sitemap.xml.gz\n\n# Define access-restrictions for robots/spiders\n# http://www.robotstxt.org/wc/norobots.html\n\n\n\n# By default we allow robots to access all areas of our site\n# already accessible to anonymous users\n\nUser-agent: *\nDisallow:\n\n\n\n# Add Googlebot-specific syntax extension to exclude forms\n# that are repeated for each piece of content in the site\n# the wildcard is only supported by Googlebot\n# http://www.google.com/support/webmasters/bin/answer.py?answer=40367&ctx=sibling\n\nUser-Agent: Googlebot\nDisallow: /*?\nDisallow: /*atct_album_view$\nDisallow: /*folder_factories$\nDisallow: /*folder_summary_view$\nDisallow: /*login_form$\nDisallow: /*mail_password_form$\nDisallow: /@@search\nDisallow: /*search_rss$\nDisallow: /*sendto_form$\nDisallow: /*summary_view$\nDisallow: /*thumbnail_view$\nDisallow: /*view$\n",
    "plone.site_logo": null,
    "plone.site_title": "Plone site"
}

Site endpoint expanders#

Added in version plone.restapi: 9.14.0

An add-on can add additional information to the @site endpoint by registering an ISiteEndpointExpander adapter.

For example, this adapter adds a key with a custom setting:

from plone.restapi.interfaces import ISiteEndpointExpander
from zope.component import adapter
from zope.interface import implementer
from zope.interface import Interface
from myaddon.interfaces import IBrowserLayer

@adapter(Interface, IBrowserLayer)
@implementer(ISiteEndpointExpander)
class MyAddonExpander:

    def __init__(self, context, request):
        self.context = context
        self.request = request

    def __call__(self, data):
        data["myaddon.setting"] = True

Tip

Use this for data that is needed to render any page, but that does not change depending on the context. If the data is context-dependent, use a custom API expander instead.