Forum

Thread tagged as: Question

Fetching an item's id by name in the API

Hi, this is probably obvious, but how would you get an item by it's name, or a full list of items in a category, via an API method?

For example, say I have some Categories called 'locations'. I'd like to know how I might get the location 'London' - regardless of it it was properties/london or properties/south-east/london. I'd also like to know, how I can get the full 'properties' set, for example as an associative array, or whatever?

Matt Keehan

Matt Keehan 0 points

  • 3 years ago

Do you need this for your app, or are you just trying to get the raw data, cause that makes a difference.

Thanks Robert. I think the raw data would be best - I'm hooking up my Perch cms with a third party SDK, so when I populate some pages, I'd like to get under the hood as far as possible.

You can still get the raw data if you use skip-template, this will return an array of all categories, unless you also add a “set”. With filtering and a match of “contains” you should be able to get everything your looking for.

perch_categories([
    // put your options here
])

docs

https://docs.grabaperch.com/functions/categories/perch-categories/