CLIIntroduction

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-post
pnpm install -g sofia-post
yarn global add sofia-post

Check the install and list every command. Add --help to any command to see its options.

sofia --help
sofia posts:create --help
sofia --version

Quick 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

CommandWhat it does
auth:login, auth:status, auth:logoutSign in with the browser, check who you are, sign out.
meShow the account the CLI acts for.
platforms:listList the networks Sofia publishes to and their rules.
establishments:listList your establishments.
accounts:list, accounts:connectList the connected social accounts, or get a link to connect one.
posts:create, posts:list, posts:get, posts:update, posts:deletePublish, schedule, list, edit and delete posts.
media:upload, media:list, media:get, media:deleteUpload a file or an https address to the media library, and manage it.
insights:getRead the statistics of an establishment.
webhooks:create, webhooks:list, webhooks:delete, webhooks:testRegister, 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.

Was this page helpful?