Skip to content

Instantly share code, notes, and snippets.

@manojnaidu619
Created October 2, 2019 00:47
Show Gist options
  • Save manojnaidu619/8c4ef1108fd774c3097239072fb199d7 to your computer and use it in GitHub Desktop.
Save manojnaidu619/8c4ef1108fd774c3097239072fb199d7 to your computer and use it in GitHub Desktop.
Contentful Ruby SDK usage
require 'contentful'
client = Contentful::Client.new(
space: '<spacd_id>',
access_token: '<access-token>',
dynamic_entries: :auto
)
entries = client.entries # For grabbing entries
entries.each do |entry|
if entry.fields[:FieldName]
puts entry.fields[:FieldName]
end
end
assets = client.assets # For grabbing image data
assets.each do |asset|
puts asset.image_url
end
#Format of image_url : https://<asset.image_url>
# As a curl query parameter:
# curl -v https://cdn.contentful.com/spaces/<space_id>/entries?access_token=<access_token>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment