How do I get entries by content type?

For intsance say I have a books type and then an author type…

when I use client.getEntries(); (JS) how do I search by only books?

1 Like

You can use the content_type parameter. Docs are here: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/content-type

1 Like

So where do specify the content_type URI?

is it client.getEntry(‘URI’) ?

client.getEntires(‘URI’) ?

The docs are sort of confusing :frowning:

getEntry only takes a single id and returns that item while getEntries return multiple items and has many parameters to filter what you get back. If you want to get all items with the content_type id "book" items you would do something like:

client.getEntries({
  content_type: "book"
}).then(response => {
  return response.items;
});
2 Likes