Contentful logo

Contentful Community

Get more than 100 content types

Hi.
I get the content types as follows:
client = ::Contentful::Client.new(
access_token: access_token,
space: site.config[‘contentful’][‘space’],
api_url: api_url,
dynamic_entries: :manual,
)
But I get only 100 content of the taipes and their 102.
How to bypass the limit?
Thank you!

Hey @nik_neman,

In order to fetch more than 100 entries, you need to send the parameter limit: n with n being the number of entries you want to have per request.

To learn more about this, you can read how to do pagination here: https://www.contentful.com/developers/docs/references/content-delivery-api/#/introduction/collection-resources-and-pagination

As an aside, I recommend you using dynamic_entries: :auto as it creates methods to directly access entry fields as methods and simplifies usage quite a bit.

Cheers

Thanks for the answer but it did not help
I’m using a plugin on Ruby - Plugin

In the ‘Client Configuration Options’ section, I did not find the ‘limit’ parameter, so I wrote it here.

Hey @nik_neman,

I’m aware that you’re using the Ruby SDK, the way to properly send the parameter I’m saying is:

require 'contentful'

client = Contenful::Client.new(
  space: 'SPACE_ID',
  access_token: 'DELIVERY_TOKEN',
  dynamic_entries: :auto,
  raise_errors: true
)

more_than_100_entries = client.entries(limit: 1000) # This is where you put the limit parameter.

Cheers

I need to increase the limit for ‘Content Model’ - https://www.dropbox.com/s/kpnsgak9uahdngz/Screenshot%202018-05-10%2018.42.05.png?dl=0

I have 1160 entries - https://www.dropbox.com/s/wmo1l3wzyhmclb4/Screenshot%202018-05-10%2018.43.35.png?dl=0

Hey @nik_neman,

Then you need to paginate, the usual way is like follows:

all_entries = []
query = {order: 'sys.createdAt'}
num_entries = client.entries(limit: 1).total

((num_entries / 1000) + 1).times do |i|
  query[:limit] = 1000
  query[:skip] = i * 1000
  page = client.entries(query)
  page.each { |entry| all_entries << entry }
end 

all_entries # here you have all your entries

Cheers

Thank you
try to explain by example

so I get all the templates
templates = {}
Dir [File.join (site.source, '_contentful_pages',' /*.html')].each do | x |
templates [File.basename (x, ".html")] = true
end

so I get all the Content Model (https://www.dropbox.com/s/kpnsgak9uahdngz/Screenshot%202018-05-10%2018.42.05.png?dl=0)
client = :: Contentful :: Client.new (
access_token: access_token,
space: site.config ['contentful'] ['space'],
api_url: api_url,
dynamic_entries:: manual,
)

here check if there is a template for the Content Model
content_types = {}
client.content_types (). each do | x |
unless templates [x.id] .nil?
content_types [x.id] = x
end
end

in client.content_types () I got only 100 Content Model and the template I have 102

therefore in content_types [x.id] do not get 2 Content Model

in the content there is a permissible content model ‘About’ and ‘Contact’
in the client.content_types () loop. each do | x | ... end

entries I get like this
while (response = client.entries (: skip => skip,: limit => 100,: order => 'sys.id',: include => 3)). length> 0
code
end

I think you are looking for this snippet:

content_types = client.content_types(limit:1000)

That will fetch up to 1000 content types. By default, each api call will get 100 entries/assets/content types, but 1000 is the maximum allowed.

Does that help?

Everything is working!
Thank you!