aurweb/doc/rpc.txt
Kevin Morris 2dfa41c9a5
feat(rpc): support POST method
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-02-07 00:49:34 -08:00

61 lines
2.2 KiB
Text

aurweb RPC Interface
====================
Package Search
--------------
Package searches can be performed by issuing HTTP GET 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_)
* `optdepends` (search for packages that optdepend on _keywords_)
* `checkdepends` (search for packages that checkdepend on _keywords_)
The _by_ parameter can be skipped and defaults to `name-desc`.
If a maintainer search is performed and the search argument is left empty, a
list of orphan packages is returned.
Package Details
---------------
Package information can be obtained by issuing HTTP GET requests of the form
+/rpc?v=5&type=info&arg[]=_pkg1_&arg[]=_pkg2_&...+ where _pkg1_, _pkg2_, ...
are the names of packages to retrieve package details for.
Request Types
-------------
The GET method here parses arguments in an odd way due to `v=5` historically
supporting this ordering. Later versions will remove support for this kind
of parsing, and the POST method is our first step toward solving it.
* `GET`
- Search arguments are constructed using the last found argument(s).
If the last related argument is `arg[]`, we collect arguments from
end to start until we hit a non-`arg[]` argument. If the last related
argument is `arg`, it used as the one and only argument.
* `POST`
- Search arguments are constructed using `[arg] + args` where
`args == arg[]`.
Examples
--------
`search`::
`/rpc?v=5&type=search&arg=foobar`
`search` by maintainer::
`/rpc?v=5&type=search&by=maintainer&arg=john`
`search` packages that have _boost_ as `makedepends`::
`/rpc?v=5&type=search&by=makedepends&arg=boost`
`search` with callback::
`/rpc?v=5&type=search&arg=foobar&callback=jsonp1192244621103`
`info`::
`/rpc?v=5&type=info&arg[]=foobar`
`info` with multiple packages::
`/rpc?v=5&type=info&arg[]=foo&arg[]=bar`