f/ColdFusion posted by rob -
Just released: commandbox-apiman

In the dynamic world of technology, my latest addition to the developer's toolkit is commandbox-apiman, a sleek and intuitive command-line interface (CLI) akin to curl, designed for seamless interaction with API endpoints.

The installation process is easy within the command box environment using the command box install commandbox-apiman.

Commandbox-apiman simplifies the API interaction process, making it accessible even to those new to working with APIs. The basic syntax follows the pattern apiman , introducing a level of simplicity and clarity in sending requests.

For example, executing a GET request to retrieve data from an API is as straightforward as using apiman get https://jsonplaceholder.typicode.com/todos/1. This functionality demonstrates the CLI's ability to facilitate quick data retrieval in a development environment.

The tool also offers flexibility in handling query strings. Users can either enclose the URL in quotes or utilize the query parameter, as seen in commands like apiman get "https://jsonplaceholder.typicode.com/comments?postId=1" or apiman get url=https://jsonplaceholder.typicode.com/comments query="postId=1". However, it's important to note that command box-apiman requires consistency in parameter usage, either positional or named, but not a mix of both.

Currently, commandbox-apiman supports essential HTTP verbs such as GET, DELETE, POST, and PUT, covering a wide range of API interactions. The CLI accepts various parameters, including:

An example of a POST request might be: apiman post url="http://localhost/ui/auth/login" header="Content-Type=application/json" body='{username : "admin", password : "commandbox" }'. This showcases the CLI's capability in handling complex API requests with ease.

In summary, commandbox-apiman emerges as a practical and efficient tool for developers, streamlining API interactions in a way that enhances productivity and simplifies the complexities often associated with API communication.

f/ColdFusion posted by rob -
Creating your first ColdBox application with CommandBox

Scaffolding a basic ColdBox application with CommandBox involves a series of steps, from setting up CommandBox to initializing and running your ColdBox application. Here's a guide to get you started:

Before you begin, you need to have CommandBox installed on your system. It's a CLI tool for ColdFusion (CFML) that allows you to manage dependencies, run servers, scaffold applications, and more.

Open Terminal/Command Prompt: Navigate to where you would like your new application to reside to create your new application directory.

Now create a new ColdBox application.

Create Application: Run the following command to create a new ColdBox application:

Replace myApp with your desired application name.

You can start a server using CommandBox to view your application.

Start Server: Run the following command:

This will start a server and open your default browser to the application.

Once your server is running, you can explore the structure of your ColdBox application:

Now you can start developing your application. You can create new handlers, views, and models as needed.

Create a Handler: Use CommandBox to scaffold a new handler:

Add Views: Create .cfm files in the views folder corresponding to your handlers.

Edit Configurations: Modify configurations in the config folder to set up routes, datasources, etc.

To deepen your understanding and skills in ColdBox and CommandBox:

If you run into issues or have questions:

This guide provides a basic overview of getting started with ColdBox and CommandBox. As you progress, you'll find a vast array of features and capabilities in ColdBox to explore.

Happy coding!

f/ColdFusion posted by rob -
Creating a commandline API viewer with CommandBox

As someone who's deeply enthusiastic about APIs and Ortus products, I regularly turn to ColdBox as my go-to framework and CommandBox for running my development environment. One standout feature of CommandBox is its ability to create custom commands via ColdFusion. Plus, its compatibility across operating systems, whether it's Linux, MacOS, or Windows, is a significant advantage.

In my role, I frequently engage with API work. Lately, I've noticed a trend where many desktop-based API testing tools are shifting towards requiring registered accounts and storing data in the cloud. While I understand the commercial rationale behind this, I'm not keen on storing my company's confidential information on external servers. Although there are ways around this, it's not the ideal solution for me.

This led me to explore HTTPie, an open-source API testing client. While I appreciate its capabilities, I encountered limitations with the size of API responses it could handle. Despite appreciating its command-line client, I prefer utilizing tools already installed on my system.

Fortunately, CommandBox is one such tool on my system. Recognizing an opportunity to both experiment with CommandBox custom modules and achieve practical outcomes, I set out to create a straightforward method for testing API endpoints. This turned out to be simpler than anticipated.

The repository for the resulting project, apiman, can be found here.

Currently, apiman is a work-in-progress with some rough edges. I'm planning to refine it further. As of now, it's not available on ForgeBox, so to use it, you'll need to clone the repository and link the module to the CommandBox core using the link command.

1 Comment