Can I output custom or specific data (Not related to an elementType) on Element API? For example, an endpoint to retrieve all the languages available on the website

'endpoints' =&gt; [   
   'languages' =&gt; function () {

            $sites = Craft::$app-&gt;getSites()-&gt;getAllGroups();

            $languages = Craft::$app-&gt;getSites()-&gt;getSitesByGroupId($sites[array_search('Languages', $sites)]['id']);

            Craft::dd($languages); // output this in a nice json

            return $languages;
        },
    ]


Or an endpoint to retrieve all the available sections

    'sections' =&gt; function () {

            $sections = Craft::$app-&gt;getSections()-&gt;getAllSections();

            Craft::dd($sections); // output this in a nice json
    },
Indeed as @robin pointed out, I couldn't figure out a nice way to making custom data outputs with Element API (Not related to a ElementType, like available Sites/Languages or available sections). What I did was:

I created a custom module, in this module I was able to register routes like:

        Event::on(
            UrlManager::class,
            UrlManager::EVENT_REGISTER_SITE_URL_RULES,
            function (RegisterUrlRulesEvent $event) {

                $event-&gt;rules['api/languages'] = '/endpoints/endpoints/languages';
            }
        );


And in the action of the module. (Still is a rough version, also needs to handle possible errors and that kind of stuff)

public function actionLanguages()
{
    $sites = Craft::$app-&gt;getSites()-&gt;getAllGroups();

    $languages = Craft::$app-&gt;getSites()-&gt;getSitesByGroupId($sites[array_search('Languages', $sites)]['id']);

    return $this-&gt;asJson($this-&gt;formatApiResponse($languages));
}


I don't know if it's the nicest way (Still open to suggestions) but this gave me the freedom I needed to enhance my Element API end-points.