Skip to content

Script project

One of the main resource types on the Skybear.NET platform is the Script project. In our docs we often just use the term Script, omitting the word “project”.

The Skybear.NET Script is a collection of Hurl source files. The Script defines the whole sequence of requests and assertions to do in your workflow, potentially across many files.

Even though the dashboard UI editor only allows you to edit a single Hurl source file, when using the API to trigger a script run you can actually provide as many Hurl source files as you wish (see HTTP Hook trigger docs). We plan to expand the UI editor to support multi-file editing.

A Script is uniquely identified by an ID prefixed with s_.

Example

A single Hurl source file can be the following:

file-1.hurl
GET https://www.skybear.net/_live-demo/secure.json
HTTP 403
GET https://www.skybear.net/_live-demo/secure.json
Authentication: Bearer sample-token-123
HTTP 200
[Asserts]
body == "{\"ok\":true}"

And this is another one:

file-2.hurl
GET https://www.skybear.net/_live-demo/get.json
HTTP 200
[Asserts]
# Roundtrip should be less than 1 second.
duration < 1000

These are 2 Hurl source files, and can be part of a single Skybear.NET Script project.

Why Hurl

Comprehensive assertions

GET https://www.skybear.net/_live-demo/sample-001.json
HTTP 200
[Captures]
contentType: header "Content-Type"
[Asserts]
# Assert headers.
header "content-type" endsWith "/json"
# Assert variables captured from previous responses.
variable "contentType" endsWith "/json"
# Assert the body as JSON!
jsonpath "$.projects.[0].points" == 2
jsonpath "$.projects.[0].points" isNumber
jsonpath "$.address.street" split " " nth 1 == "Maple"
# Assert the body as raw bytes or plain text!
bytes count < 1000
body contains "Maple"

As you can see from the example script above, Hurl scripts allow you to do all sorts of assertions on the response body and headers. From exact matching of values, to nested JSON assertions, or even whole body checks.

Learn more about all the assertions you can do in Hurl’s documentation.

Automations and Workflows

# Create a workflow calling multiple remote APIs.
GET https://www.skybear.net/_live-demo/get.json
HTTP 200
[Captures]
var1: jsonpath "$.var1"
# Use captured value from previous response.
POST https://www.skybear.net/_live-demo/set/{{ var1 }}
HTTP 200
# Just send requests, without asserting the response.
POST https://www.skybear.net/_live-demo/set/call-two
POST https://www.skybear.net/_live-demo/set/call/three

Among the reasons we love Hurl is that it’s trivial to write sequences of API requests, to orchestrate wholesome workflows.

You can do tens or hundreds of requests in a single script, each one extracting and using information from all previous responses.

An example user journey to test:

  1. Create a resource (POST).
  2. Modify the resource properties (PUT or/and PATCH).
  3. Assert that the resource is in the expected state (GET).
  4. Repeat steps 2 and 3, as many times as necessary.
  5. Delete resource (POST).

As seen in the example scripts earlier, you can even write comments in your scripts, which is amazing. Comprehensive Hurl scripts with appropriate comments can be great documentation for your API.

The article Testing the Cloudflare D1 REST API with Hurl is a real-world example of a user journey tested with Hurl, and configured to run periodically every few minutes with Skybear.NET.