Merge pull request #1689 from Homebrew/dependabot/bundler/jekyll-4.4.1
[Homebrew/formulae.brew.sh.git] / docs / api.md
blob4642234052ce27d9abf54046e87b0683ba2ec7e6
1 ---
2 layout: page
3 permalink: /docs/api/
4 redirect_from:
5   - /api/
6   - /docs/
7 ---
8 # JSON API Documentation
10 ## Metadata
12 ### List metadata for all {{ site.taps.core.name }} formulae or {{ site.taps.cask.name }} casks
14 List the `brew info --json` output for all current {{ site.taps.core.fullname }} formulae or {{ site.taps.cask.fullname }} casks.
16 ```console
17 curl https://formulae.brew.sh/api/formula.json
18 curl https://formulae.brew.sh/api/cask.json
19 ```
21 **[Response](https://formulae.brew.sh/api/formula.json):**
23 {% include api-samples/formula.md %}
25 ### Get formula metadata for a {{ site.taps.core.name }} formula
27 Get the `brew info --json --formula <formula>` output for a single, current {{ site.taps.core.fullname }} formula with extra keys containing analytics data and generation date.
29 ```console
30 curl https://formulae.brew.sh/api/formula/${FORMULA}.json
31 ```
33 **Variables:**
35 - `${FORMULA}`: the name of the formula, e.g. `wget`
37 **[Response](https://formulae.brew.sh/api/formula/wget.json):**
39 {% include api-samples/formula_wget.md %}
41 ### Get cask metadata for a {{ site.taps.cask.name }} cask
43 Get the `brew info --json=v2 --cask <cask>` JSON output for a single, current {{ site.taps.cask.fullname }} cask with extra keys containing analytics data and generation date.
45 ```console
46 curl https://formulae.brew.sh/api/cask/${CASK}.json
47 ```
49 **Variables:**
51 - `${CASK}`: the name of the cask, e.g. `docker`
53 **[Response](https://formulae.brew.sh/api/cask/docker.json):**
55 {% include api-samples/cask_docker.md %}
57 ## Analytics
59 ### List one category of analytics events
61 List all analytics events for a specified category over a number of days, ordered by event frequency count. This is the data source for `brew info --analytics`.
63 ```console
64 curl https://formulae.brew.sh/api/analytics/${CATEGORY}/${DAYS}.json
65 ```
67 **Variables:**
69 - `${CATEGORY}`: the analytics event category, i.e.
70   - `install`: the installation of all formulae
71   - `install-on-request`: the requested installation of all formulae (i.e. not as a dependency of other formulae)
72   - `build-error`: the installation failure of all formulae
73 - `${DAYS}`: the number of days of analytics events, i.e.
74   - `30d`: 30 days
75   - `90d`: 90 days
76   - `365d`: 365 days
78 **[Response](https://formulae.brew.sh/api/analytics/install/30d.json):**
80 {% include api-samples/analytics_install_30d.md %}
82 ### List analytics events for all {{ site.taps.core.name }} formulae
84 List all the {{ site.taps.core.fullname }} formulae's analytics events for a specified category over a number of days, grouped by formula name. This is the data source for `brew info --analytics --formula <formula>`.
86 ```console
87 curl https://formulae.brew.sh/api/analytics/${CATEGORY}/homebrew-core/${DAYS}.json
88 ```
90 **Variables:**
92 - `${CATEGORY}`: the analytics event category, i.e.
93   - `install`: the installation of all {{ site.taps.core.repository }} formulae
94   - `install-on-request`: the requested installation of all {{ site.taps.core.repository }} formulae (i.e. not as a dependency of other formulae)
95   - `build-error`: the installation failure of all {{ site.taps.core.repository }} formulae
96     - only `${DAYS}: 30d` (30 days) is available
97 - `${DAYS}`: the number of days of analytics events, i.e.
98   - `30d`: 30 days
99   - `90d`: 90 days
100   - `365d`: 365 days
102 **[Response](https://formulae.brew.sh/api/analytics/install/homebrew-core/30d.json):**
104 {% include api-samples/analytics_install_homebrew_core_30d.md %}
106 ### List analytics events for all {{ site.taps.cask.name }} casks
108 List all the {{ site.taps.cask.fullname }} cask's analytics events for the `cask-install` category over a number of days, grouped by cask token.
109 This is the data source for `brew info --analytics --cask <cask>`.
111 ```console
112 curl https://formulae.brew.sh/api/analytics/cask-install/homebrew-cask/${DAYS}.json
115 **Variables:**
117 - `${DAYS}`: the number of days of analytics events, i.e.
118   - `30d`: 30 days
119   - `90d`: 90 days
120   - `365d`: 365 days
122 **[Response](https://formulae.brew.sh/api/analytics/cask-install/homebrew-cask/30d.json):**
124 {% include api-samples/analytics_cask_install_homebrew_cask_30d.md %}