百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

airtable-ruby

> 编程语言
开源

使用 ruby 便捷地访问 Airtable 数据表

170 stars0 点赞4 次浏览
访问官网GitHub

工具介绍

使用 ruby 便捷地访问 Airtable 数据表

Airtable Ruby Client

Easily connect to airtable data using ruby with access to all of the airtable features.

Note on library status

We are currently transitioning this gem to be supported by Airtable. We will maintain it moving forward, but until we fully support it, it will stay in the status of "community libraries". At that time we will remove this notice and add a "ruby" section to the API docs.

Installation

Add this line to your application's Gemfile:

gem 'airtable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install airtable

Usage

Creating a Client

First, be sure to register for an airtable account, create a data worksheet and get an api key. Now, setup your Airtable client:

ruby
# Pass in api key to client
@client = Airtable::Client.new("keyPCx5W")

Your API key carries the same privileges as your user account, so be sure to keep it secret!

Accessing a Table

Now we can access any table in our Airsheet account by referencing the API docs:

ruby
# Pass in the app key and table name
@table = @client.table("appPo84QuCy2BPgLk", "Table Name")

Querying Records

Once you have access to a table from above, we can query a set of records in the table with:

ruby
@records = @table.records

We can specify a sort order, limit, and offset as part of our query:

ruby
@records = @table.records(:sort => ["Name", :asc], :limit => 50)
@records # => [#"Bill Lowry", :email=>"billery@gmail.com">, ...]
@records.offset #=> "itrEN2TCbrcSN2BMs"

This will return the records based on the query as well as an offset for the next round of records. We can then access the contents of any record:

ruby
@bill = @record.first
# => #"Bill Lowry", :email=>"billery@gmail.com", :id=>"rec02sKGVIzU65eV1">
@bill[:id] # => "rec02sKGVIzU65eV2"
@bill[:name] # => "Bill Lowry"
@bill[:email] # => "billery@gmail.com"

Note that you can only request a maximimum of 100 records in a single query. To retrieve more records, use the "batch" feature below.

Batch Querying All Records

We can also query all records in the table through a series of batch requests with:

ruby
@records = @table.all(:sort => ["Name", :asc])

This executes a variable number of network requests (100 records per batch) to retrieve all records in a sheet.

We can also use select method to query based on specific conditions using formula parameter

ruby
@records = @table.select(sort: ["Order", "asc"], formula: "Active = 1")

This will return all the records that has Active column value as true from table.

Finding a Record

Records can be queried by id using the find method on a table:

ruby
@record = @table.find("rec02sKGVIzU65eV2")
# => #"Bill Lowry", :email=>"billery@gmail.com", :id=>"rec02sKGVIzU65eV1">

Inserting Records

Records can be inserted using the create method on a table:

ruby
@record = Airtable::Record.new(:name => "Sarah Jaine", :email => "[email protected]")
@table.create(@record)
# => #"Sarah Jaine", :email=>"sarah@jaine.com", :id=>"rec03sKOVIzU65eV4">

Updating Records

Records can be updated using the update method on a table:

ruby
@record[:email] = "[email protected]"
@table.update(record)
# => #"Sarah Jaine", :email=>"sarahjaine@updated.com", :id=>"rec03sKOVIzU65eV4">

Deleting Records

Records can be destroyed using the destroy method on a table:

ruby
@table.destroy(record)

Contributing

  1. Fork it ( https://github.com/nesquena/airtable-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Issues· 23 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言