19

I see how to query an Entry by the ID.

Is there a way to lookup by slug?

cottontail
  • 10,268
  • 18
  • 50
  • 51
metahamza
  • 1,405
  • 10
  • 26

2 Answers2

23

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',
})
maxime1992
  • 22,502
  • 10
  • 80
  • 121
  • this.contentfulClient.getEntries({ content_type: 'YOUR_CONTENT_KEY', 'fields.slug[like]': 'THE_SLUG_YOU_ARE_LOOKING_FOR', }) this is correct? – Prakash Raj Sep 07 '21 at 11:30
15

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

/spaces/[space_id]/entries?fields.slug=[my_slug] 
Won Jun Bae
  • 5,140
  • 6
  • 43
  • 49
Deane
  • 8,269
  • 12
  • 58
  • 108
  • 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 Nov 01 '16 at 01:26