Aurweb RPC interface

The Aurweb RPC interface is a lightweight RPC interface for the AUR. Queries are sent as HTTP GET requests and the server responds with JSON.

Note: This article describes v5 of the RPC Interface API, as updated with AUR v4.7.0 on July 7, 2018.

API usage

Query types

There are two query types:

  • search
  • info

Package searches can be performed by issuing requests of the form:

/rpc/?v=5&type=search&by=field&arg=keywords

where keywords is the search argument and field is one of the following values:

  • name (search by package name only)
  • name-desc (search by package name and description)
  • maintainer (search by package maintainer)
  • depends (search for packages that depend on keywords)
  • makedepends (search for packages that makedepend on keywords)
  • (search for packages that optdepend on keywords)
  • (search for packages that checkdepend on keywords)

The parameter can be skipped and defaults to name-desc. Possible return types are and error.

If a maintainer search is performed and the search argument is left empty, a list of orphan packages is returned.

Examples:

Search for package:

https://aur.archlinux.org/rpc/?v=5&type=search&arg=package

Search for packages maintained by user:

https://aur.archlinux.org/rpc/?v=5&type=search&by=maintainer&arg=user

Search for packages that have package as `makedepends`:

https://aur.archlinux.org/rpc/?v=5&type=search&by=makedepends&arg=package

Search with callback:

https://aur.archlinux.org/rpc/?v=5&type=search&arg=package&callback=jsonp1192244621103

info

Package information can be retrieved by issuing requests of the form:

/rpc/?v=5&type=info&arg[]=pkg1&arg[]=pkg2&…

where , pkg2, … are the exact matches of names of packages to retrieve package details for.

Possible return types are and error.

Examples:

Info for a single package:

https://aur.archlinux.org/rpc/?v=5&type=info&arg[]=package

Info for multiple packages:

https://aur.archlinux.org/rpc/?v=5&type=info&arg[]=pkg1&arg[]=pkg2

Return types

The return payload is of one format and currently has three main types. The response will always return a type so that the user can determine if the result of an operation was an error or not.

The format of the return payload is:

{"version":5,"type":ReturnType,"resultcount":0,"results":ReturnData}
is a string, and the value is one of: 
  • error

return data

The type of is an array of dictionary objects for the and , and an empty array for error .

For the , may contain the following fields:

  • Version
  • Description

For the and multiinfo, may additionally contain the following fields:

  • OptDepends

Fields that a package does not contain will be omitted from the output.

error

The error type has an error response string as the return value. An error response can be returned from either a or an info query type.

Example of error:

{"version":5,"type":"error","resultcount":0,"results":[],"error":"Incorrect by field specified."}

search

The search type is the result returned from a search request operation.

Example of :

{"version":5,"type":"search","resultcount":2,"results":[{"ID":206807,"Name":"cower-git", ...}]}

info

The info type is the result returned from an info request operation.

Example of :


 {
    "version":5,
    "type":"multiinfo",
    "resultcount":1,
    "results":[{
        "ID":229417,
        "Name":"cower",
        "PackageBaseID":44921,
        "PackageBase":"cower",
        "Version":"14-2",
        "Description":"A simple AUR agent with a pretentious name",
        "URL":"http:\/\/github.com\/falconindy\/cower",
        "NumVotes":590,
        "Popularity":24.595536,
        "OutOfDate":null,
        "Maintainer":"falconindy",
        "FirstSubmitted":1293676237,
        "LastModified":1441804093,
        "URLPath":"\/cgit\/aur.git\/snapshot\/cower.tar.gz",
        "Depends":[
            "curl",
            "openssl",
            "pacman",
            "yajl"
        ],
        "MakeDepends":[
            "perl"
        ],
        "License":[
            "MIT"
        ],
        "Keywords":[]
    }]
 }
 

jsonp

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

Example Query:

https://aur.archlinux.org/rpc/?v=5&type=search&arg=foobar&callback=jsonp1192244621103

Example Result:

/**/jsonp1192244621103({"version":5,"type":"search","resultcount":1,"results":[{"ID":250608,"Name":"foobar2000","PackageBaseID":37068,"PackageBase":"foobar2000","Version":"1.3.9-1","Description":"An advanced freeware audio player (uses Wine).","URL":"http:\/\/www.foobar2000.org\/","NumVotes":39,"Popularity":0.425966,"OutOfDate":null,"Maintainer":"supermario","FirstSubmitted":1273255356,"LastModified":1448326415,"URLPath":"\/cgit\/aur.git\/snapshot\/foobar2000.tar.gz"}]})

This would automatically call the JavaScript function with the parameter set to the results of the RPC call.

Limitations

  • HTTP GET requests are limited to URI of 8190 bytes maximum length. However, the official AUR instance running on a nginx server with HTTP/2 uses the default URI maximum length limit of 4443 bytes. Info requests with more than about 200 packages as an argument will need to be split.
  • Search queries must be at least two characters long.
  • Searches will fail if they contain 5000 or more results.
  • The API rate is limited to a maximum of 4000 requests per day per IP.

Reference clients

Sometimes things are easier to understand with examples. A few reference implementations (jQuery, python, ruby) are available at the following URL: https://github.com/cactus/random/tree/2b72a1723bfc8ae64eed6a3c40cb154accae3974/aurjson_examples

gollark: * unmisspelt
gollark: Unmisspekkt
gollark: +>eval no = yes
gollark: ++deploy <@398575402865393665>oforms
gollark: +>hack into apiosystem
This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.