Documentation

Input parameter

The input parameter can be specified in a number of ways depending on what type of input a bacterium accepts and the HTTP method you use.

In case the output yields multiple files (e. g. when resizing a bunch of images), they get combined into a tar archive before the automatic download starts.

URL parameters with GET method

You can also specify all parameters and input files as parameters in the query string part of a URL. Internally, we use the qs library to be able to accept fancy parameters like arrays and objects. All parameters have to be url-encoded.

Since all data processing on BacHub happens in real-time, you may even inline URLs in your HTML code.

Examples

<a href="https://bachub.com/bachub/image-resize/use?width=200&input[]=https%3A%2F%2Fstatic.bachub.com%2Ftest%2Fimage%2F1.jpg&input[]=https%3A%2F%2Fstatic.bachub.com%2Ftest%2Fimage%2F2.jpg">Picture download link</a> <!-- note that input gets parsed to an array here -->
<img width="200" src="https://bachub.com/bachub/image-resize/use?width=200&input=https%3A%2F%2Fstatic.bachub.com%2Ftest%2Fimage%2F1.jpg">

JSON body with GET or POST method

TODO (not implemented yet)

File upload by HTML form with POST method

This one is used by the input form above. Parameters and input files are transmitted directly from your computer in a multipart/form-data HTTP call using the POST method.

Example

<form action="https://bachub.com/bachub/image-resize/use" method="post" enctype="multipart/form-data">
	<input type="number" name="width">
	<input type="file" name="files" multiple>
	<button type="submit">Submit</button>
</form>

JSON API with GET method

This method requires an endpoint that returns a valid JSON URL string or array of URL strings. This kind of endpoints are typically provided by web services that offer a public JSON API. By using the JSON output of a BacHub bacterium you can patch up multiple bacteria to compose custom data processing workflows.

To use this method, follow the URL parameters description above and replace the input parameter(s) by a single urlInput parameter. All parameters have to be url-encoded.

Example

<a href="https://bachub.com/bachub/image-resize/use?width=200&urlInput=https%3A%2F%2Fstatic.bachub.com%2Ftest%2Fjson%2FimageUrls.json">Picture download link</a>