Choose Language Hide Translation Bar
d_barnett
Community Trekker

HTTP Front End

I'm trying to access online databases using the JMP 14 'New HTTP Request' functionalilty from the help pages

 

key = "<key>"; // substitute your key
limit = 100;
url = "https://api.nasa.gov/patents/content";
request = New HTTP Request(
	URL( url ),
	Method( "Get" ),
	Query String( [["api_key" => key, "concept_tags" => "false", "limit" => limit]] )
);

json = request << Send();
jsl_json = Parse JSON( json );
dt = JSON To Data Table( As JSON Expr( jsl_json["results"] ) );
// JSON to Data Table turns JSON data into a data table
// As JSON Expr turns a JSL associative array into a JSON string
dt << Set Name( "NASA Patents" );

My question is whether there is a nicer way to input the key/ url etc? I'm mostley thinking about a front end where this could be entered.

Also, is there a better guide to doing this and what information should be where? I struggle with the guidance from the help page but that could be just my lack of knowledge in this area.

 

David

0 Kudos
1 REPLY 1
Highlighted

Re: HTTP Front End

Hey David.

I'm the developer of HTTP Request (new for JMP 14)

Currently HTTP Request is JSL scripting only (no "front end" yet) and uses JSL containers like Asscociative Arrays and Lists.

Using the example you have:

Query String( [["api_key" => key, "concept_tags" => "false", "limit" => limit]] )

Could be written like:

query = [=>];
query["api_key"] = key;
query["concept_tags"] = "false";
query["limit"] = "limit";

Query String(query);

But that's mainly JSL "style".

I'll see if I can clarify anything in the documentation, but as you REST apis can be like the "wild west".

 

That being said, interfacing with REST apis are breaking new ground.  I'm constantly trying new ones out.

Always feel free to post questions (specific or general).  I'd be interested to see how it's being used.