$npx -y skills add pixee/pixee-cli --skill pixee-apiSend authenticated requests to any Pixee REST API endpoint.
| 1 | # pixee api |
| 2 | |
| 3 | > **PREREQUISITE:** Read `../pixee-shared/SKILL.md` for global flags, exit codes, and error |
| 4 | > handling. Those conventions apply to every command in this skill. See `../pixee-auth/SKILL.md` |
| 5 | > if authentication needs to be configured. |
| 6 | |
| 7 | The escape-hatch subcommand. `pixee api` sends authenticated HTTP requests to any Pixee REST API |
| 8 | endpoint, modeled on `gh api`. Use it when a dedicated subcommand does not yet exist, or when an |
| 9 | agent needs to compose multi-step operations directly against the API. |
| 10 | |
| 11 | ## HAL discovery |
| 12 | |
| 13 | The Pixee API is a HAL (Hypertext Application Language) API: every response contains `_links` that |
| 14 | name the related resources. Start at `/api/v1` and follow `_links` to reach every other endpoint. |
| 15 | Do not hardcode paths beyond the root. |
| 16 | |
| 17 | ```bash |
| 18 | # Inspect the root to find the available resources |
| 19 | pixee api /api/v1 |
| 20 | |
| 21 | # Follow a link — here, the "repositories" link on the root |
| 22 | pixee api /api/v1/repositories --paginate |
| 23 | |
| 24 | # Each resource has its own _links; follow them to related resources |
| 25 | pixee api /api/v1/repositories/<id> |
| 26 | ``` |
| 27 | |
| 28 | ## Conventions |
| 29 | |
| 30 | `pixee api` closely mirrors `gh api`: |
| 31 | |
| 32 | - Default method is `GET`. `pixee api` switches to `POST` automatically when any `-f` / `-F` field |
| 33 | is supplied. Override explicitly with `--method <VERB>`. |
| 34 | - `-f key=value` adds a raw string field. |
| 35 | - `-F key=value` adds a typed field, converting `true`/`false` to booleans and numeric strings to |
| 36 | numbers. |
| 37 | - `--input <file>` reads a pre-constructed JSON body from a file. Use `--input -` to read from |
| 38 | stdin. |
| 39 | - Output is raw JSON. `pixee` does not embed a jq implementation; pipe to `jq` externally for |
| 40 | filtering or transformation. |
| 41 | |
| 42 | ## Pagination |
| 43 | |
| 44 | By default, paginated endpoints return only the first page. Add `--paginate` to let `pixee` walk |
| 45 | the collection automatically: |
| 46 | |
| 47 | ```bash |
| 48 | pixee api /api/v1/repositories --paginate |
| 49 | ``` |
| 50 | |
| 51 | With `--paginate`, `pixee` follows `_links.next` until it is absent, merges each page's |
| 52 | `_embedded.items` array, and emits a single flat JSON array. The HAL envelope (`_links`, `page`, |
| 53 | `total`) is stripped from the output. |
| 54 | |
| 55 | This is pagination-strategy-agnostic: the CLI does not construct `page-number` query parameters |
| 56 | itself, so if the API migrates to a different strategy the same `--paginate` flag continues to |
| 57 | work. |
| 58 | |
| 59 | ## Examples |
| 60 | |
| 61 | ```bash |
| 62 | # POST a workflow with typed fields (auto-switches to POST because fields are present) |
| 63 | pixee api /api/v1/repositories/<id>/workflows \ |
| 64 | -f event=new-scan \ |
| 65 | -F branch=main \ |
| 66 | -f action=none |
| 67 | |
| 68 | # Or submit a pre-constructed body |
| 69 | pixee api /api/v1/repositories/<id>/workflows --input workflow.json |
| 70 | |
| 71 | # Filter a paginated response externally with jq |
| 72 | pixee api /api/v1/repositories --paginate | jq '.[] | .full_name' |
| 73 | ``` |
| 74 | |
| 75 | ## Best practices |
| 76 | |
| 77 | - Always use `--paginate` to collect a full collection; do not hand-roll `page-number` query |
| 78 | parameters. |
| 79 | - Discover endpoints by following `_links` from `/api/v1`; do not inject the OpenAPI specification |
| 80 | into agent context. |
| 81 | - Prefer dedicated subcommands (`pixee repo list`, `pixee workflow list`) when they exist — they |
| 82 | encode best practices on top of `pixee api`. Use `pixee api` as the escape hatch for operations |
| 83 | that do not yet have a subcommand. |