Pulling information from external API’S


#1

Hi

I’m trying to input the contents of Wikipedia using their API (I followed these instructions https://www.mediawiki.org/wiki/API:Tutorial) but nothing happens.

I’ve set my input URL

lib - WIKIPEDIA_BY_MILNER
*// Copyright 2019 Nial Milner,  //*

@;
	http://en.wikipedia.org/w/api.php* -- //recall 

But all that appears at the output is:

#000,000_0

ERROR, scrib 0001

So I changed the conversation to check everything worked

@read.txt

POST;
  contents, in change 

After doing this whatever I wrote in ‘read.txt’ appeared on the output URL but if I changed the input back I get the error‘ERROR, scrib 0001’ again.

I can’t find out what it means anywhere does anybody here know?


#2

Hi @Milner,

Have you included an instruction to pull the information from the API?

For example;

REQUEST.WIKI;
   {ARTICLE -- ^PULL _ALL VAL(@)}
   (EN.WIKIPEDIA.ORG/)

You’ll also need to look at creating an Array to store the information otherwise you’ll have a very poor (slow) experience for example;

  $_WIKI;
    RECORD_WIKI.EN

The error message is rare, in-this-case it means KC 0001 is causing too many handshakes, or isn’t readable, does the Conversation have any other KC’s?


#3

Thanks!

I’ve added a pull request. Am I correct in assuming I can use substitutions ‘$_’ to change the information being requested?

Like

   LOOKUP;
      {srsearch=$_RQST} 

I’ve change the Conversation to

@;
  search.html

$_RQST;
  @search.html

My Library now looks like this

@;
	http://en.wikipedia.org/w/api.php* -- //recall 

LOOKUP;
    {srsearch=$_RQST} 

ARTICLE;
    @, LOOKUP

MILNER.WIKI;
    {ARTICLE -- ^PULL _ALL VAL(@)}
    (EN.WIKIPEDIA.ORG/)

But if I type “Apple%20inc” in search.html I get nothing on the output URL guessing I’ve missed something.


#4

Okay, it looks like you have conflicting statements; could you change

@;
	http://en.wikipedia.org/w/api.php* -- //recall 

LOOKUP;
    {srsearch=$_RQST} 

ARTICLE;
    @, LOOKUP

MILNER.WIKI;
    {ARTICLE -- ^PULL _ALL VAL(@)}
    (EN.WIKIPEDIA.ORG/)

To

@;
	http://en.wikipedia.org/w/api.php* -- //recall 

REQUEST;
    [‘srsearch=$_RQST’]

MILNER.WIKI;
    {REQUEST -- ^PULL _ALL VAL(@)}
    (EN.WIKIPEDIA.ORG/)

Essentially before you were creating a loop (remember the ‘@‘ represents the domain in-this-case http://en.wikipedia.org/w/api.php so by including the ‘@‘ once more you’re creating a request to http://en.wikipedia.org/w/api.phphttp://en.wikipedia.org/w/api.php

The KCs I removed wasn’t necessary if you rename ‘ARTICLE’ to “REQUEST” thus speeding the process up (smaller files run faster).


#5

Not being clever but shouldn’t ^PULL be in the syntax page.

Mike


#6

@mjb

From everything I’ve read the answer is no as the definition in use is the meaning of the word (“An act of pulling something/Retrieve (an item of data) from the top of a stack”) and yes I know about .PLL but even the offical Libraries use meaning based syntax instead.

By your logic every word should be present on the syntax page defeating a basic principle of deadCL.


#7

Hi @Milner

You’re correct! However you could use ^.PLL instead this is potentially safer as the meaning is not left open for interpretation.

^PULL is employed within the official Libraries as the command (.PLL) wasn’t introduced till May of this year.

@mjb We try to avoid, using ‘proper’ words in the syntax, to reduce the risk of a conflict between meaning based and fixed syntax. This unique writing concept permits the user to create their own sandboxed logic resulting in much more powerful applications!