CLI API anyone?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

CLI API anyone?

Jim R. Wilson
Hi all,

I'd really like to see a CLI version of the api.php that doesn't have any limits on volume of output (since it's CLI, it's assumed to be trusted).

This would be incredibly useful for various types of dumps and statistics gathering.  Your thoughts?

-- Jim R. Wilson (jimbojw)

_______________________________________________
Mediawiki-api mailing list
[hidden email]
http://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: CLI API anyone?

Yuri Astrakhan
Sounds like a reasonable request. API can already be used internally -
http://www.mediawiki.org/wiki/API:Calling_internally , but it
currently checks the user limits.

Please file a bug and I will fix it to allow any limit value for
internal calls (the limits will still be there, just won't be checked
against the maximum allowed).

On 7/11/07, Jim Wilson <[hidden email]> wrote:

> Hi all,
>
> I'd really like to see a CLI version of the api.php that doesn't have any
> limits on volume of output (since it's CLI, it's assumed to be trusted).
>
> This would be incredibly useful for various types of dumps and statistics
> gathering.  Your thoughts?
>
> -- Jim R. Wilson (jimbojw)
>
> _______________________________________________
> Mediawiki-api mailing list
> [hidden email]
> http://lists.wikimedia.org/mailman/listinfo/mediawiki-api
>
>

_______________________________________________
Mediawiki-api mailing list
[hidden email]
http://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: CLI API anyone?

Jim R. Wilson
In your response to the bug, you mentioned that:

> It is fairly simple to remove maximum limit checks when processing an internal
query.

Can you expand on this?  I'm in the process of creating my own cliApi.php - the meat of which is this:

------
parse_str($argv[0], $params);
$request = new FauxRequest($params);
$processor = new CLIApiMain($request, $wgEnableWriteAPI);
$processor->execute();
------

I was hoping to extend ApiMain, but because of all the private "modules" and such, it's non-trivial to simply "override" the limit check.  Could you provide some suggestions on how to easily abolish all checks?  Does this require changing core code?  I was hoping it wouldn't - thanks in advance.

-- Jim

On 7/11/07, Yuri Astrakhan <[hidden email]> wrote:
Sounds like a reasonable request. API can already be used internally -
http://www.mediawiki.org/wiki/API:Calling_internally , but it
currently checks the user limits.

Please file a bug and I will fix it to allow any limit value for
internal calls (the limits will still be there, just won't be checked
against the maximum allowed).

On 7/11/07, Jim Wilson <[hidden email]> wrote:

> Hi all,
>
> I'd really like to see a CLI version of the api.php that doesn't have any
> limits on volume of output (since it's CLI, it's assumed to be trusted).
>
> This would be incredibly useful for various types of dumps and statistics
> gathering.  Your thoughts?
>
> -- Jim R. Wilson (jimbojw)
>
> _______________________________________________
> Mediawiki-api mailing list
> [hidden email]
> http://lists.wikimedia.org/mailman/listinfo/mediawiki-api
>
>


_______________________________________________
Mediawiki-api mailing list
[hidden email]
http://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: CLI API anyone?

Yuri Astrakhan
Core code will need to be changed for both limit and the CLI:

1) limits -- just change the apiBase to check if the
$this->getMain()->isInternalMode() is false before checking the
limits. That function needs to be created in the ApiMain to return the
value of $this->mInternalMode

2) You do not really need a CLIApiMain object - just use the
$api = new ApiMain($params);
$api->execute();
directly.

There probably should be an extra function in main to generate output
for a given format in addition to $api->getResultData() :
  $api->getFormattedResult($format)

3) Sometimes the parameter string is very long. For example when you
try to get data for a long list of titles.  The command line is not
going to be enough.

On 7/11/07, Jim Wilson <[hidden email]> wrote:

> In your response to the bug, you mentioned that:
>
> > It is fairly simple to remove maximum limit checks when processing an
> internal
> query.
>
> Can you expand on this?  I'm in the process of creating my own cliApi.php -
> the meat of which is this:
>
> ------
> parse_str($argv[0], $params);
> $request = new FauxRequest($params);
> $processor = new CLIApiMain($request, $wgEnableWriteAPI);
> $processor->execute();
> ------
>
> I was hoping to extend ApiMain, but because of all the private "modules" and
> such, it's non-trivial to simply "override" the limit check.  Could you
> provide some suggestions on how to easily abolish all checks?  Does this
> require changing core code?  I was hoping it wouldn't - thanks in advance.
>
> -- Jim
>
> On 7/11/07, Yuri Astrakhan <[hidden email]> wrote:
> > Sounds like a reasonable request. API can already be used internally -
> > http://www.mediawiki.org/wiki/API:Calling_internally ,
> but it
> > currently checks the user limits.
> >
> > Please file a bug and I will fix it to allow any limit value for
> > internal calls (the limits will still be there, just won't be checked
> > against the maximum allowed).
> >
> > On 7/11/07, Jim Wilson < [hidden email]> wrote:
> > > Hi all,
> > >
> > > I'd really like to see a CLI version of the api.php that doesn't have
> any
> > > limits on volume of output (since it's CLI, it's assumed to be trusted).
> > >
> > > This would be incredibly useful for various types of dumps and
> statistics
> > > gathering.  Your thoughts?
> > >
> > > -- Jim R. Wilson (jimbojw)
> > >
> > > _______________________________________________
> > > Mediawiki-api mailing list
> > > [hidden email]
> > >
> http://lists.wikimedia.org/mailman/listinfo/mediawiki-api
> > >
> > >
> >
>
>

_______________________________________________
Mediawiki-api mailing list
[hidden email]
http://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: CLI API anyone?

Przemek Piotrowski
Oups,

sorry for the mess. I thought I'm sending last one to the list.

>> > There probably should be an extra function in main to generate  
>> output
>> > for a given format in addition to $api->getResultData() :
>> >   $api->getFormattedResult($format)
>>
>> This would be a very usefull method.
>>
>> Or better - let API return a description what has been returned.
>> getResultDescription, twin brother to getParamDescription?

> Why would api describe what it has returned?? The requestor better
> know what it asked for :).

Two scenarios:
- flash widget as a "multi-purpose" client. User can ask for several  
things.

- multi api call. User asks for eg. recent changes but from more than  
one wiki. If they run different MW codebase results will have  
slightly different form.

Btw. api.php?action=query&meta=siteinfo&siprop=apiversion would be  
usefull as well as with different MW even calls have different params,

przem.


_______________________________________________
Mediawiki-api mailing list
[hidden email]
http://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: CLI API anyone?

Phil Boswell
In reply to this post by Yuri Astrakhan
Yuri Astrakhan wrote
3) Sometimes the parameter string is very long. For example when you
try to get data for a long list of titles.  The command line is not
going to be enough.
Presumably in this kind of situation you would be piping in your list from a file?
--
Phil