Difference between revisions of "AurJson"

From ArchWiki
Jump to: navigation, search
(Return Values)
(Return Values)
Line 22: Line 22:
  
 
The main format of the return payload is:
 
The main format of the return payload is:
  "type": returntype
+
"type": returntype
  "data": returndata
+
"data": returndata
  
 
They types are as follows:
 
They types are as follows:
  
 
1. Error
 
1. Error
  The error type has an error response string as the return value.
+
The error type has an error response string as the return value.
  Example return of type error:
+
Example return of type error:
  {"type":"error","results":"No results found"}
+
{"type":"error","results":"No results found"}
  
 
2. Search
 
2. Search
  The search type is the result returned from a search request operation. Returning the type  
+
The search type is the result returned from a search request operation. Returning the type as search is useful for detecting whether the response to a search operation is search data or an error.
  as search is useful for detecting whether the response to a search operation is search data  
+
Example return of type search:
  or an error.
+
{"type":"search","results":[{"Name":"pam_abl","ID":"1995"}]}
  Example return of type search:
+
  {"type":"search","results":[{"Name":"pam_abl","ID":"1995"}]}
+
  
 
3. Info
 
3. Info
Line 44: Line 42:
  
 
Example return of type info:
 
Example return of type info:
  {"type":"info","results":{"ID":"1995","Name":"pam_abl","Version":"0.2.3-1","Description":"Provides auto blacklisting of hosts and users responsible for repeated failed authentication attempts","URL":"http:\/\/www.hexten.net\/pam_abl","URLPath":"\/packages\/pam_abl\/pam_abl.tar.gz","License":"","NumVotes":"4","OutOfDate":"0"}}
+
{"type":"info","results":{"ID":"1995","Name":"pam_abl","Version":"0.2.3-1","Description":"Provides auto blacklisting of hosts and users responsible for repeated failed authentication attempts","URL":"http:\/\/www.hexten.net\/pam_abl","URLPath":"\/packages\/pam_abl\/pam_abl.tar.gz","License":"","NumVotes":"4","OutOfDate":"0"}}
  
 
== Example ==
 
== Example ==

Revision as of 02:56, 5 April 2008

Overview

The AurJson interface is a lightweight remote interface for the AUR. It utilizes json as the data exchange format.

Usage

The interface has two major query methods:

 * search
 * info

Each method requires the following HTTP GET syntax:

 type=methodname&arg=data

Where methodname is the name of an allowed method, and data is the argument to the call. Data is returned in json encapsulated format.

Return Values

The return payload is of one format, and currently has three main types.

The main format of the return payload is:

"type": returntype
"data": returndata

They types are as follows:

1. Error The error type has an error response string as the return value. Example return of type error:

{"type":"error","results":"No results found"}

2. Search The search type is the result returned from a search request operation. Returning the type as search is useful for detecting whether the response to a search operation is search data or an error. Example return of type search:

{"type":"search","results":[{"Name":"pam_abl","ID":"1995"}]}

3. Info

The info type is the result returned from an info request operation. Returning the type as search is useful for detecting whether the response to a search operation is search data or an error.

Example return of type info:

{"type":"info","results":{"ID":"1995","Name":"pam_abl","Version":"0.2.3-1","Description":"Provides auto blacklisting of hosts and users responsible for repeated failed authentication attempts","URL":"http:\/\/www.hexten.net\/pam_abl","URLPath":"\/packages\/pam_abl\/pam_abl.tar.gz","License":"","NumVotes":"4","OutOfDate":"0"}}

Example

Example Query:

  http://aur-url/rpc.php?type=search&arg=foobar

Example Return:

  {"type":"error","results":"No results found"}

jsonp

If you are working with a javascript page, and need a jsonp callback mechanism, you can do it. You just need to provide an additional variable callback. This callback is usually handled via the javascript library, but here is an example.

Example Query:

  http://aur-url/rpc.php?type=search&arg=foobar&callback=jsonp1192244621103

Example Return:

  jsonp1192244621103({"type":"error","results":"No results found"})