21

I see how to query an Entry by the ID.

Is there a way to lookup by slug?

2 Answers 2

26

If you're using the SDK, you might as well do

this.contentfulClient.getEntries({
  content_type: 'YOUR_CONTENT_KEY',
  'fields.slug[in]': 'THE_SLUG_YOU_ARE_LOOKING_FOR',
})
1
  • this.contentfulClient.getEntries({ content_type: 'YOUR_CONTENT_KEY', 'fields.slug[like]': 'THE_SLUG_YOU_ARE_LOOKING_FOR', }) this is correct? Commented Sep 7, 2021 at 11:30
18

Why can't you just do a standard query against the Content Delivery API?

/spaces/[space_id]/entries?fields.slug=[my_slug] 
2
  • Yeah, that's how I'm gonna do it! I figured there might be a method that didn't require a query like that, but I also see that the slug field is not necessarily unique so this solution makes more sense.
    – metahamza
    Commented Nov 1, 2016 at 1:26
  • Is this method more burdensome than getting the data by directly requesting the id, or does it index the id with the slug parameter? In other words, does it cause a change in the response time of the system? @Deane Commented Dec 10, 2023 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.