Agent-optimized CLI for the Pexels API.
Install
- Build from source:
cargo install --path pexels
Auth
- Env:
PEXELS_TOKEN(orPEXELS_API_KEY); fallback order:PEXELS_TOKEN→PEXELS_API_KEY. - Config file:
~/.config/pexels/config.yaml(or OS equivalent). Usepexels auth login [TOKEN].
Usage examples
pexels auth statuspexels photos search -q catspexels photos curatedpexels videos popularpexels collections featured
Output
- Successful outputs are wrapped as
{ data: <payload> }for single-resource outputs, and{ data: <items[]>, meta: { total_results?, next_page?, prev_page?, request_id? } }for list endpoints. - For list endpoints,
datais the items array (photos/videos/collections/media). For single-resource endpoints,datais the object andmetais omitted. page/per_pageare omitted.next_page/prev_pageare integers (page numbers) or null.- Field selection via
--fieldssupports dot paths and sets:@ids,@urls,@files,@thumbnails,@all. - Some fields are omitted by default for lighter responses; include heavy fields via
--fields.
Testing
- Unit tests cover projection, config precedence, error mapping, and page parsing.
- Live tests run in CI when
PEXELS_TOKENis present and event is safe. Commands:pexels auth statuspexels photos search -q catspexels photos curatedpexels videos popularpexels collections featured
CI/Release
- CI runs: lint -> unit tests -> build -> live tests (guarded by
secrets.PEXELS_TOKENand internal PRs/main). - On push to main, a release tag is created and binaries for Linux/macOS/Windows are uploaded.