airtable v0.3.1 Airtable
Documentation for Airtable.
Link to this section Summary
Functions
Creates a new row by performing a POST request to Airtable. Parameters are sent via the fields option. Upload fields just need to be given one or more downloadable URLs.
Deletes a certain row from a table. Returns {:ok, "DELETED_ID"} on success.
Retrieves a certain row from a table.
Retrieves all entries.
Perfoms the call cycle for :get, :delete, :update, :replace calls.
Replaces an existing row with a new one. If you just want to update certain fields, use update/5 instead. Returns the replaces item.
Update given fields for a row. Fields not set in this call will be kapt as-is. If you want to replace the whole entry/row, use replace/5 instead. Returns the updated item.
Link to this section Functions
create(api_key, table_key, table_name, options)
Creates a new row by performing a POST request to Airtable. Parameters are sent via the fields option. Upload fields just need to be given one or more downloadable URLs.
Airtable.create( "AIRTABLE_API_KEY", "TABLE_KEY", "persons", fields: %{
"Name" => "Martin Gutsch",
"Notes" => "formerly knows as gutschilla",
"Attachments" => [%{"url" => "https://dummyimage.com/600x400/000/fff"}]
} )
delete(api_key, table_key, table_name, item_id)
Deletes a certain row from a table. Returns {:ok, "DELETED_ID"} on success.
get(api_key, table_key, table_name, item_id)
Retrieves a certain row from a table.
handle_response(type, response)
list(api_key, table_key, table_name, options \\ [])
Retrieves all entries.
options
fields:
list of strings for fields to retrieve only. Remember, that id will always be there.
Airtable.list("API_KEY", "app_BASE", "Filme", fields: ["Titel", "Jahr"])
{:ok,
%Airtable.Result.List{
offset: nil,
records: [
%Airtable.Result.Item{
fields: %{"Jahr" => "2004", "Titel" => "Kill Bill Volume 2"},
id: "rec15b3sYhdEStY1e"
},
%Airtable.Result.Item{
fields: %{"Titel" => "Ein blonder Traum"},
id: "rec3KUcL7R3AHD3rY"
},
...
]
}
}
- filterByFormula
- maxRecords
- maxRecords
- sort
- view
- cellFormat
- timeZone
- userLocale
Examples
iex> Airtable.list("AIRTABLE_API_KEY", "TABLE_KEY", "films", max_records: 1000)
%Airtable.Result.List%{records: [%Airtable.Result.Item{id: "someid", fields: %{"foo": "bar"}}], offset: "…"}
make_request(atom, api_key, table_key, table_name, options)
make_request(type, api_key, table_key, table_name, item_id, options)
perform(action, api_key, table_key, table_name, item_id, options \\ [])
Perfoms the call cycle for :get, :delete, :update, :replace calls.
- create request struct
- make actual HTTP request
- handle JSON response
replace(api_key, table_key, table_name, id, options)
Replaces an existing row with a new one. If you just want to update certain fields, use update/5 instead. Returns the replaces item.
create
{:ok, %Airtable.Result.Item{id: id , fields: %{"name": "Frank", age: 55}} = Airtable.create("API_KEY", "TABLE_KEY", "persons", "rec_SOME_ID", fields: %{"name": "Frank", age: 55})
overwrite
{:ok, %Airtable.Result.Item{id: ^id, fields: %{"name": "Martin", age: 39}} = Airtable.replace("API_KEY", "TABLE_KEY", "persons", id, fields: %{"name": "Martin", age: 39})
update(api_key, table_key, table_name, id, options)
Update given fields for a row. Fields not set in this call will be kapt as-is. If you want to replace the whole entry/row, use replace/5 instead. Returns the updated item.
create
{:ok, %Airtable.Result.Item{id: id , fields: %{"name": "Frank", age: 55}} = Airtable.create("API_KEY", "TABLE_KEY", "persons", "rec_SOME_ID", fields: %{"name": "Frank", age: 55})
overwrite, age is still 55
{:ok, %Airtable.Result.Item{id: ^id, fields: %{"name": "Martin", age: 55}} = Airtable.replace("API_KEY", "TABLE_KEY", "persons", id, fields: %{"name": "Martin"})