Skip to content

Instantly share code, notes, and snippets.

@dybber
Created August 26, 2021 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dybber/08c33a010496c834b722219f550fdc92 to your computer and use it in GitHub Desktop.
Save dybber/08c33a010496c834b722219f550fdc92 to your computer and use it in GitHub Desktop.
import urequests
import ujson
import time
# APIkey findes under Profil -> Account -> API
apiKey = "keyCGxxXYZXYZXYZ"
# baseID findes under din base -> Help -> API documentation
baseID = "app0UKKXYZXYZXYZ"
# Tabelnavn (urlencoded: %20 er mellemrum)
tableName = "Table%201"
apiURL = "https://api.airtable.com/v0/" + baseID + "/" + tableName
headers = {"Authorization": "Bearer " + apiKey,
"Content-Type": "application/json"}
# Send
def post_data(data, args=[]):
data = {
"fields": {
"KolonneNavnHer": data,
"Arguments": str(args),
}
}
json_string = ujson.dumps(data)
print(apiURL)
# erstat med requests.get kan bruges ved at hente data
response = urequests.post(apiURL, headers=headers, data=json_string)
print(response.text)
while True:
data = 17
post_data(data)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment