API CLI
foo-api
CLI is a Node.js package to provide utilities using Foo's REST API. This package is hosted on NPM.
#
Getting StartedFollow the steps in getting started and make sure you have an API token as outlined in that section. You will use this token to populate FOO_API_TOKEN
environment variable.
Install the CLI. This example installs globally.
To see the version of the CLI you can use the v
option as below.
#
UsageBelow is the format for the CLI. Note the dependency on environment variables.
#
Example UsageIn the below example we use the import
command to import pages to Foo from a CSV file.
If you've set FOO_API_TOKEN
environment variable separately, it would simply be the below.
Boolean options can have a false
value, or no value to represent a true
value. Below shows how we use the silent
boolean option.
#
Global OptionsThe below options are available for all commands.
silent
#
Optional
The silent options will supress all output entirely.
fail-on-error
#
Optional
With batch operations, the CLI will throw an error if one occurs at the time it occurs. For example, the import
command will import line by line from the specified CSV file. By default, if an error occurs, the CLI will store any error, and continue on - outputting all errors in the end. if fail-on-error
is set, then the CLI will not continue and throw an error as soon as one occurs.
#
Commandsimport
#
Imports pages to Foo from a CSV file.
import
: Example#
import
: Resources#
- Pages: See API documentation about the Page resource.
import
: Options#
file-path
#
Required
The CSV file path relative to the CLI executor, for example: ./input/pages.csv
. When importing pages, the format of the CSV is important and must follow the below example format (name
, url
).
file-path-output
#
Optional
A CSV file path relative to the CLI executor that the CLI will output the result to, for example: ./output/pages.csv
. When importing pages, the CLI will create an output similar to the following (id
, name
, url
).
#
Environment VariablesFOO_API_TOKEN
#
Required
Follow the steps in getting started to acquire an API token and populate FOO_API_TOKEN
environment variable with it. This is required for API authentication.