Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Dev Space

Customize and extend the power of Alteryx with SDKs, APIs, custom tools, and more.

An API Client for Alteryx Gallery in R

michael_treadwell
ACE Emeritus
ACE Emeritus

For those of you R users, I have been working on an API Client for Alteryx Gallery written in R. It is mostly working the way I intend but I need to do a little bit more testing before I release it to CRAN.

 

You can find it here: https://github.com/mtreadwell/alterryx

Until I have it released on CRAN, you can install it using devtools::install_github("mtreadwell/alterryx")

 

If anyone is an R user and also set up with a private Alteryx Gallery, I would be interested in feedback.

 

The package, alterryx (double r), provides access to each of the Alteryx Gallery API endpoints. With alterryx users can:

  • Retrieve information on Alteryx Gallery resources like apps, workflows, and macros

  • Queue jobs for applications

  • Retrieve the status and output of jobs

It is pretty handy to be able to schedule jobs and retrieve the results as a data.frame directly into R.

 

Feedback appreciated!

16 REPLIES 16
sarav1981_wa
6 - Meteoroid

I am having trouble getting the API authentication to work. Receive a 401 error response, which I believe refers to "provided signature (oauth_signature) is invalid".

 

What is the option to provide oauth credentials using the library.

 

> library(alterryx)
> 
> alteryx_api_key <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> alteryx_secret_key <- "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
> alteryx_gallery <- "http://mygalleryaddress/gallery/api"
> 
> options(alteryx_api_key = alteryx_api_key)
> options(alteryx_secret_key = alteryx_secret_key)
> options(alteryx_gallery = alteryx_gallery)
> 
> subscription <- get_app()
Error in check_status(response) : 401 Unexpected Response

Thank you!

michael_treadwell
ACE Emeritus
ACE Emeritus

Generally, if the signature is invalid, it explicitly states it in the error message.

 

Try this:

 

alteryx_gallery <- "http://mygalleryaddress/gallery"

 

Instead of this:

 

alteryx_gallery <- "http://mygalleryaddress/gallery/api"

 

sarav1981_wa
6 - Meteoroid

Thank you, Michael for the tweak. I did realize it after checking the API endpoints.

 

With the change, I explicitly receive the signature invalid error.

 

Is there a need to provide parameters to generate the oauth nonce, timestamp and signatures dynamically? 

 

> library(alterryx)
> 
> alteryx_api_key <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> alteryx_secret_key <- "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
> alteryx_gallery <- "http://mygalleryaddress/gallery/"
> 
> options(alteryx_api_key = alteryx_api_key)
> options(alteryx_secret_key = alteryx_secret_key)
> options(alteryx_gallery = alteryx_gallery)
> 
> # request_params <- list(oauth_signature_method="HMAC-SHA1",oauth_version="1.0")
> # 
> # subscription <- get_app(request_params)
> subscription <- get_app()
Error in check_status(response) : 
  401 UnauthorizedException The provided signature(oauth_signature) is invalid.
michael_treadwell
ACE Emeritus
ACE Emeritus

Sorry. There is a known issue in my package that I haven't had time to fix yet. Remove the "/" from the end of your gallery URL.

 

 

Try this:

alteryx_gallery <- "http://mygalleryaddress/gallery"

 

Instead of this:

alteryx_gallery <- "http://mygalleryaddress/gallery/"
michael_treadwell
ACE Emeritus
ACE Emeritus

Can't say thank you enough for using my package and finding issues. I went ahead and opened an issue on the Github page so that it will be fixed in the next release.

https://github.com/mtreadwell/alterryx/issues/6

sarav1981_wa
6 - Meteoroid

Thank you, Michael. Looking forward to your package updates.

 

Currently, I execute and receive job status updates on Alteryx gallery runs using a tweak on the C# API client that Alteryx provides. Would be really helpful to integrate the package to my R process, once the fixes are in.

 

> library(alterryx)
> 
> alteryx_api_key <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> alteryx_secret_key <- "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
> alteryx_gallery <- "http://mygalleryaddress/gallery"
> 
> options(alteryx_api_key = alteryx_api_key)
> options(alteryx_secret_key = alteryx_secret_key)
> options(alteryx_gallery = alteryx_gallery)
> 
> # request_params <- list(oauth_signature_method="HMAC-SHA1",oauth_version="1.0")
> # subscription <- get_app(request_params)
> subscription <- get_app()
> subscription[1]
[[1]]
App Name: Test.yxmd
App ID: 5b1ffdd6529ad717d4c04b40
michael_treadwell
ACE Emeritus
ACE Emeritus

You shouldn't need to wait on the fix to have the package run properly.

When you remove the "/" at the end of your Gallery URL and run the code below, you are still getting an error?

 

library(alterryx)

alteryx_api_key <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
alteryx_secret_key <- "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
alteryx_gallery <- "http://mygalleryaddress/gallery"

options(alteryx_api_key = alteryx_api_key)
options(alteryx_secret_key = alteryx_secret_key)
options(alteryx_gallery = alteryx_gallery)
subscription <- get_app()

Would you mind restarting your R environment, running the code above, and if still doesn't work sending me the printout of:

 

sessionInfo()

 

Also, what version of Alteryx Server are you currently running?

 

Additionally, as a note, I see that in the commented-out section you are entering oauth signature method and version. None of that is necessary, it is all handled by the package.

sarav1981_wa
6 - Meteoroid

The package runs great. I pasted an error snippet by mistake.

 

Our Alteryx server is running on version 11.7.4.37815.

 

Thank you for the quick response.

 

> library(alterryx)
> 
> alteryx_api_key <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> alteryx_secret_key <- "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
> alteryx_gallery <- "http://mygalleryaddress/gallery"
> 
> options(alteryx_api_key = alteryx_api_key)
> options(alteryx_secret_key = alteryx_secret_key)
> options(alteryx_gallery = alteryx_gallery)
> 
> subscription <- get_app()
> subscription[1]
[[1]]
App Name: Test.yxmd
App ID: 5b1ffdd6529ad717d4c04b40

 

 

sarav1981_wa
6 - Meteoroid

 

Receiving a weird error attempting to source the gallery job executions for a given app, using get_app_jobs() function.

 

Obtain a 'cannot convert to alteryx_job' input error.

 

> library(alterryx)
> 
> alteryx_api_key <- "xxxxxxxxxxxxxx"
> alteryx_secret_key <- "yyyyyyyyyyyy"
> alteryx_gallery <- "http://mygalleryaddress/gallery"
> 
> options(alteryx_api_key = alteryx_api_key)
> options(alteryx_secret_key = alteryx_secret_key)
> options(alteryx_gallery = alteryx_gallery)
> 
> # Get Gallery Alteryx Apps; Filter for the required for further analysis
> gallery_apps <- get_app()
> req_app <- gallery_apps[[9]]
> req_app
App Name: Test.yxwz
App ID: 5b50d1bb529ad72b0cd378b7 
> 
> # Obtain all gallery job runs for the filtered app
> req_app_jobs <- get_app_jobs(req_app)
Error in as.alteryx_job(content, app) : 
  Unexpected input. Cannot convert to type alteryx_job.
> req_app_jobs
Error: object 'req_app_jobs' not found
> req_app_jobs2 <- get_app_jobs(gallery_apps[[9]])
Error in as.alteryx_job(content, app) : 
  Unexpected input. Cannot convert to type alteryx_job.
> req_app_jobs2
Error: object 'req_app_jobs2' not found