BookmarkSubscribeRSS Feed
harisahmad

Staff (Retired)

Joined:

Jul 25, 2018

Getting Started With REST in JMP

These are the instructions on how to utilize the Getting Started With REST APIs add-in in the best way to learn how HTTP Requests and REST APIs in JMP work.

 

  1. Download the add-in and launch it via Addins->API Toolbar. This is what it should look like:

title.png

  1. You can go through the examples in any which order you’d like. They are listed in order of least complex to most complex.catnokey.png
  2. The Random cat example is simplest as it requires no authentication. The example is already preloaded with the URL and HTTP Request method to utilize (GET).
    1. Press the send button to see the images of cats appear on the screen.
    2. Press the Show JSL button to see the JSL script going on behind the scenes. After you’re done with the example, click back to go back to the title screen.catkey.png
  3. Next is the More Random Cats This example appears to be the exact same as the previous one, except that now there’s a textbox for entering in an APIKey.
    1. Obtain an APIKey from the aforementioned link, and paste it into the textbox as stated.
    2. Send the request. A log file with an overview of the information retrieved for the specific APIKey/Account that you are using should come back.
    3. Press the Show JSL button to see how this code differs from the previous example (you’ll be surprised).weather.PNG
  4. Next is the Weather This has the same level of authentication as the previous “More cats” example, and requires the use of an APIKey to have it successfully work.
    1. Click the “Get my Key” button and register for an account; after you obtain your key, paste it into the keybox below.
    2. Click “Send.” A log file with the data for a specific city should come up, in this case it’s London, UK.
    3. Click the “Show JSL” button to see the code behind the script. You can find the weather information for any city or location that you want by simply searching it up on the API, and replacing the URL in the JSL script.tumblr.png
  5. Look at the Tumblr This has a more complex level of Authentication known as OAuth (specifically OAuth 1.0a); it requires the use of a Consumer Key, Consumer Secret, Token Key, Token Secret, and depending on the API being used, more or fewer parameters to access or post information.
    1. In order for this to successfully work, register for a Tumblr account, and register an application to utilize with OAuthentication.
    2. After all of this is complete, copy the OAuth Consumer Key and paste it into the textbox below. Click “Send.” Information regarding the current Tumblr account should be obtained in a Log.
    3. Click the “Show JSL” button to see the code behind the script.dropbox.png
  6. Look at the Dropbox This is the most up to date level of OAuth currently available (OAuth 2.0), and is currently the most complex level of authentication I will cover. It requires the same things as OAuth 1.0a, except there is the possibility of a refresh token and access token as well.
    1. In order for this example to successfully work, sign into your Dropbox account and obtain an access token from the given URL.
    2. Obtain and copy the access token and paste it into the text box below. Click “Send” once you’ve done everything. This example “POSTS” a file to your directory. A new “JMP” folder should be created in your Dropbox with the file “Big Class” in it.
    3. Click the “Show JSL” button to see the code behind the script.

 

If there are any questions withstanding for how to use the add-in, or any issues that you may run into, please don’t hesitate to leave a comment.

Comments
mark_anawis

Good afternoon. I installed the addin and ran it using JMP Pro 14.1 with Windows 7. It did not return a cat picture and I received the following error for the Random Cat option even when I increased the Internet Open Timeout to 10000:

GET http://thecatapi.com/api/images/get?concept_tags=false&limit=1000
Failed to connect to thecatapi.com port 80: Timed outEmpty()