Connect R to Knack API

What is the exact code I can use to connect to my Knack database using the Knack API through R Studio?

I would like to be able to analyze my data in R without having to download it as a csv and read it in each time. I would also like to be able to update records using R.

I found the answer to my own question. Here is the code:

library(httr)
library(jsonlite)

result <- GET("https://api.knack.com/v1/objects/object_xx/records",
    add_headers("X-Knack-Application-Id" = "YOUR-APP-ID",
                "X-Knack-REST-API-Key" = "YOUR-API-KEY"))

data = fromJSON(content(result, as = "text"))
1 Like

Thanks a lot! It would be great to have a package on CRAN for this.

1 Like

I took your recommendation and built an R Package! Can you check it out and let me know what you think? knackr | R Package for Connecting to Knack Databases (mcodrescu.github.io). I would appreciate help testing it so I can fix any bugs and hopefully submit it for approval to CRAN.

@Marcus and @LuizSchmid92663
Out of curiosity, what are you building with R and Knack? Just curious.

I have been using it to analyze the data I store on Knack. My business uses Knack as an employee portal to track timesheets and expense reports and as a sort of financial database to track accounts payable and accounts receivable. I pull data from Knack to run payroll twice a month, calculate expense report totals, and analyze job-related trends like which jobs are bringing in the most income. R is my data analysis and visualization tool of choice.

1 Like