1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
---
title: "Package endpoints"
layout: default
canonical: "/puppetdb/latest/api/query/v4/packages.html"
---
# Package endpoints
[curl]: ../curl.markdown#using-curl-from-localhost-non-sslhttp
[paging]: ./paging.markdown
[query]: query.markdown
[subqueries]: ./ast.markdown#subquery-operators
[facts-format]: ../../wire_format/facts_format_v5.markdown
[factsets]: ./factsets.markdown
[reports]: ./reports.markdown
[catalogs]: ./catalogs.markdown
[nodes]: ./nodes.markdown
[facts]: ./facts.markdown
[fact_contents]: ./fact_contents.markdown
[events]: ./events.markdown
[edges]: ./edges.markdown
[resources]: ./resources.markdown
[inventory]: inventory.markdown
> **PE feature**: Package metadata collection, storage, and querying is
> a Puppet Enterprise-only feature.
## `/pdb/query/v4/packages`
Returns all installed packages, across all nodes. One record is returned for
each `(package_name, version, provider)` combination that exists in your
infrastructure.
### Query fields
* `package_name` (string): The name of the package. (e.g. `emacs24`)
* `version` (string): The version of the package, in the format used by the
package provider. (e.g. `24.5+1-6ubuntu1`)
* `provider` (string): The name of the provider which the package data came from;
typically the name of the packaging system. (e.g. `apt`)
### Response format
The response is a JSON array of hashes, where each hash has the form:
{"package_name": <string>,
"version": <string>,
"provider": <string>}
The array is unsorted by default.
### Example
[You can use `curl`][curl] or `puppet query` to query information about packages:
puppet query "packages { package_name ~ 'ssl'}"
curl -G http://localhost:8080/pdb/query/v4/packages --data-urlencode 'query=["~", "package_name", "ssl"]'
## `/pdb/query/v4/package-inventory`
Returns all installed packages along with the certname of the nodes they are
installed on.
### Query fields
* `certname` (string): The certname of the node the package data was collected
from.
* `package_name` (string): The name of the package. (e.g. `emacs24`)
* `version` (string): The version of the package, in the format used by the
package provider. (e.g. `24.5+1-6ubuntu1`)
* `provider` (string): The name of the provider which the package data came from;
typically the name of the packaging system. (e.g. `apt`)
### Response format
The response is a JSON array of hashes, where each hash has the form:
{"certname": <string>,
"package_name": <string>,
"version": <string>,
"provider": <string>}
The array is unsorted by default.
### Example
[You can use `curl`][curl] or `puppet query` to query information about nodes:
puppet query "package_inventory{ certname = 'agent1' }"
curl -G http://localhost:8080/pdb/query/v4/package-inventory --data-urlencode 'query=["=", "certname", "agent1"]'
puppet query "package_inventory[certname]{ package_name ~ 'openssl' and version ~ '1\.0\.1[\-a-f]' }"
## `/pdb/query/v4/package-inventory/<CERTNAME>`
This will return all packages installed on the provided certname. It behaves
exactly like a call to `/pdb/query/v4/packages` with a query string of `["=",
"certname", <CERTNAME>]`.
## Paging
These query endpoints support paged results via the common PuppetDB paging
URL parameters. For more information, please see the documentation
on [paging][paging].
|