How can I get to a category via the category slug using the ElementAPI
I think (well, I know) I am confused by where "regular" php is and where the ElementAPI takes over. This is returning me data, but I'm not sure if it's just dumb luck or I've actually got something working...

$slug = craft()-&gt;request-&gt;getRequiredPost('location');  // chicago

$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Category);
$criteria-&gt;group = 'Locations';
$criteria-&gt;slug = $slug;

$locations = $category = $criteria-&gt;find();

return [
    'endpoints' =&gt; [
        'myfile.json' =&gt; [
            'elementType' =&gt; 'Entry',
            'criteria' =&gt; [
                'section' =&gt; 'mysection',
                'relatedTo' =&gt; ['targetElement' =&gt; $locations],
            ],
            'transformer' =&gt; function (EntryModel $entry) {
                return [
                    'title' =&gt; $entry-&gt;title
                ];
            },
        ]
    ]
];