CLI
Introduction
Install the sofia command, sign in and publish from your terminal: posts, media, accounts, insights and webhooks, with JSON output you can script.
The Sofia CLI wraps Sofia API v1 in a single command, sofia. Every command is written resource:action, and every answer is JSON, so you can chain it with jq, cron jobs and CI pipelines.
Install
The CLI is published on npm as the sofia-post package; the command it installs is sofia.
npm install -g sofia-postpnpm install -g sofia-postyarn global add sofia-postCheck the install and list every command. Add --help to any command to see its options.
sofia --help
sofia posts:create --help
sofia --versionQuick start
Sign in with your browser, find your establishment, then publish a first post.
sofia auth:login
sofia establishments:list
sofia posts:create -e $ESTABLISHMENT_ID -p instagram -c "Tarte tatin du jour"Commands
| Command | What it does |
|---|---|
auth:login, auth:status, auth:logout | Sign in with the browser, check who you are, sign out. |
me | Show the account the CLI acts for. |
platforms:list | List the networks Sofia publishes to and their rules. |
establishments:list | List your establishments. |
accounts:list, accounts:connect | List the connected social accounts, or get a link to connect one. |
posts:create, posts:list, posts:get, posts:update, posts:delete | Publish, schedule, list, edit and delete posts. |
media:upload, media:list, media:get, media:delete | Upload a file or an https address to the media library, and manage it. |
insights:get | Read the statistics of an establishment. |
webhooks:create, webhooks:list, webhooks:delete, webhooks:test | Register, list, delete and test webhooks. |
JSON output
Every command prints the JSON body of the API on stdout, indented. Pipe it into jq to pick what you need.
sofia establishments:list | jq '.data[].id'On failure, the error envelope of the API (or a local error of the same shape) goes to stderr and the exit code is 1.
{ "error": { "code": "invalid_request", "message": "…", "details": [ … ] } }A deletion answers { "deleted": true, "id": "…" }. Next: authentication, then posts.