Autohotkey to AirTable API (read and write data to cloud) Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
labrint
Posts: 135
Joined: 14 Jun 2017, 05:06

Autohotkey to AirTable API (read and write data to cloud)

20 Jan 2019, 05:50

Hi Guys,

Airtable offers users the possibility of storing data on the cloud in spreadsheets via API calls, but so far I have not figured out how to do this using an autohotkey function.

Can any experienced user help me?

https://airtable.com/api

This is the API call written in CURL

Code: Select all

$ curl -v -XPOST **URL** \
-H "Authorization: Bearer **YOUR_API_KEY**" \
-H "Content-Type: application/json" \
 -d '{
  "fields": {
    "Field1": "Test",
    "Field2": "18101",
    "Field3": "123231"
  }
}'
Airtable provides a solution for cloud data logging in your AHK scripts in a spreadsheet format and has reasonably high limits for free users as well as cheap monthly rates for those using AHK for business. It can store a variety of data including attachments in its fields.

Let's get AHK connected with Airtable!

Thanks in advance!
User avatar
TheDewd
Posts: 1390
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Autohotkey to AirTable API (read and write data to cloud)

21 Jan 2019, 12:57

This should help you retrieve data:

Code: Select all

#SingleInstance, Force

; API_Key: Your personal API key generated from the account page (https://airtable.com/account)

; API_Base: The ID of your Base. Try hovering your mouse cursor over the Base name from the AirTables homepage to see the Base ID in the statusbar's URL text. It should look similar to https://airtable.com/appQWERTYUIOPASDF

;API_Table: The name of your table. You may use spaces.


API_Key := "keyPRIVATE"
API_Base := "appDWSRTkUCunNKAD"
API_Table := "MyTable"

WinHttp := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WinHttp.Open("GET", "https://api.airtable.com/v0/" API_Base "/" API_Table, false)
WinHttp.SetRequestHeader("Content-Type", "application/json")
WinHttp.SetRequestHeader("Authorization", "Bearer " API_Key)
WinHttp.Send()

MsgBox, % WinHttp.ResponseText
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
labrint
Posts: 135
Joined: 14 Jun 2017, 05:06

Re: Autohotkey to AirTable API (read and write data to cloud)

22 Jan 2019, 13:52

Works well TheDewd, do you know how to set up the "POST" method for creating records, please?
User avatar
TheDewd
Posts: 1390
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Autohotkey to AirTable API (read and write data to cloud)  Topic is solved

22 Jan 2019, 14:16

Here's an example to create a new record on an existing Table.

In my table, I have a column created using "Name" as the column name. "MySampleText" is the text to be inserted in the "Name" column.

Code: Select all

#SingleInstance, Force

API_Key := "keyXXXXXXXXXXXXXX"
API_Base := "appXXXXXXXXXXXXXX"
API_Table := "MyTableName"

Data = {"fields":{"Name":"MySampleText"}}

WinHttp := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WinHttp.Open("POST", "https://api.airtable.com/v0/" API_Base "/" API_Table, false)
WinHttp.SetRequestHeader("Content-Type", "application/json")
WinHttp.SetRequestHeader("Authorization", "Bearer " API_Key)
WinHttp.Send(Data)

MsgBox, % WinHttp.ResponseText
I would like to use Google Sheets instead, but the oAuth authentication is too difficult for me to implement. Retrieving data is easy for public files using API key only, but editing files requires oAuth :(
AitTables is nice because it's simple.
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
labrint
Posts: 135
Joined: 14 Jun 2017, 05:06

Re: Autohotkey to AirTable API (read and write data to cloud)

23 Jan 2019, 05:16

Thank you TheDewd, works like a charm!!
labrint
Posts: 135
Joined: 14 Jun 2017, 05:06

Re: Autohotkey to AirTable API (read and write data to cloud)

30 Jan 2019, 14:37

Anything else apart from airtable? It's good but limited to 2500 records per base.

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], Bral, chenj209, eblanc, F4Jonatas, Gigadroid, KiddoV, SilasDeVis, wyatterp, Xtra and 125 guests