supabase-rb-rb
Storage

List all buckets

List every bucket the caller can see.

List every bucket the caller can see. Returns an Array<Supabase::Storage::Types::Bucket> — empty when there are no buckets, never nil.

storage-api returns every bucket in the project; there's no server-side filter on the wire. To filter by name / public-flag, do it in Ruby on the returned array.

Service-role key required

Bucket admin endpoints reject the publishable / anon key with 401 Unauthorized. Construct the client with the service-role JWT.

Signature

supabase.storage.list_buckets

Parameters

This method has no parameters.

Returns

Returns
Array<Supabase::Storage::Types::Bucket>

Every bucket the caller can see. Empty array if the project has no buckets. See the bucket type table for field descriptions.

Example — list every bucket

buckets = supabase.storage.list_buckets

buckets.map(&:id)
# => ["avatars", "marketing-assets", "private-uploads"]

Example — find the public buckets

public_buckets = supabase.storage.list_buckets.select(&:public)

public_buckets.each do |b|
  puts "#{b.id} (created #{b.created_at})"
end

Example — guard against an empty project

buckets = supabase.storage.list_buckets

if buckets.empty?
  supabase.storage.create_bucket("avatars", public: true)
end

The Array(...) wrapper around the parsed body means an unexpected nil body parses as [] rather than raising.

On this page