Query CLI App
Set up and use Payabli’s Query CLI app to run queries against your Payabli data.
The Payabli Query CLI application is a command-line tool that allows you to run queries against your Payabli data. It supports all of Payabli’s query APIs and provides a flexible way to retrieve and analyze your data. The app also supports special clauses to help you adjust your queries and can save multiple configurations for different environments.
Visit the repo to see the code.
Once you have the application installed, we recommend you add the application to your PATH for easy access.
Dependencies
Before you begin, make sure you have the following installed on your machine:
Manual setup
Run these commands in your terminal to install the query CLI app on your local machine:
Clone the repo
Compile the application
Make a default config
Follow the prompts and enter your Payabli API information to create a default config.
Run a query
Optional: Add the app to your PATH
If you want to run the query CLI app from anywhere on your machine, you can add it to your PATH.
This allows you to run the application as payquery
from any directory, instead of navigating to the application directory and running cargo run
.
Install the application
Add the binary to your PATH
Run the app from anywhere
You can also manually place the binary in a directory that is already in your PATH.
Usage
The Payabli Query CLI application supports all of Payabli’s query APIs.
To run a query, put the name of the API endpoint after the payquery
command.
Clauses
The application supports special clauses to help you adjust your queries to be more helpful and precise.
only N ...
: Limit the number of records to N (comes before the API endpoint).... for NAME
: Use the configuration named NAME.... where FILTERS
: Filter records based on the given conditions.... by FIELD
: Sort records by FIELD in ascending order.... by FIELD desc
: Sort records by FIELD in descending order.... crop
: Output only the sorted field values (must come after a BY clause).
The for
clause uses the query parameters for the API endpoint.
The by
clause uses the field names of the response object for the API endpoint.
To retrieve only 5 transactions where the transaction date is after the beginning of this week, run:
To retrieve all chargebacks where the net amount is less than $100.00, and then sort those chargebacks by reply date, run:
To see a list of all payment methods used in transactions by customers with the first name “John”, run:
To retrieve all customers for the configuration named sandbox
, run:
Configurations are stored in a YAML file located in your home directory as payquery.yml
.
Each configuration contains an API token, organization ID, entrypoint ID, and environment (sandbox or production).
Subcommands
The Payabli Query CLI application also supports the following subcommands:
new
: Create a new configuration.list
: List all available configurations.help
: Show this help message.
To create a new configuration, run:
To list all available configurations, run:
To see the help message, run:
Options
Finally, the Payabli Query CLI application supports the following options that must be provided at the beginning of the command:
--json
: Output in JSON format (default).--yaml
: Output in YAML format.--quiet
: Don’t output information besides the query result.
To output the query result in YAML format, run:
To output the query result in JSON format, run:
To output only the query result without any additional information, run:
If you are writing a script that uses the query CLI app, you can use the --quiet
option to get only the query result without any response status information.
This can be useful if you want to parse the query result in your script or use the query result as input for another command.
Was this page helpful?