Sign In
Call Us: 888-829-7576

Server API

Overview

The Server API can be used by other applications (and even command line tools like curl) to securely read and write data to your database.

In its simplest form, a single line of code in a shell script might use curl to query a table in your cloud database and export it to a local CSV file on your computer:

curl "https://www.parasql.com/api?apiKey=YOUR_API_KEY&action=executeQuery&responseFormat=CSV&query=SELECT+*+FROM+Customers" > test.csv

You can even paste the above URL into a web browser and download a CSV file.

Building The URL

In the above URL you would need to replace YOUR_API_KEY with a valid API Key. To create an API Key and set what permissions it has, see Tools > API Keys... (in the ParaSQL design window).

The next parameter is the action parameter; this tells the API what action to take. All other parameters depend upon the value of the action parameter and are thus described below.

Any of the actions may be used with either GET or POST. Any POST body must be x-www-form-urlencoded encoded.

action=executeQuery

Allows you to run an SQL query and retrieve the results in either CSV or JSON format.

action=executeUpdate

Allows you to send an INSERT, UPDATE or DELETE statement to update the database. (A single INSERT statement may insert many rows in a single call; see the MySQL reference manual for details.)

action=convertHtmlToPdf (PDF Generation)

This feature is configurable and must be enabled for your account.

This action allows you to convert an HTML document into a PDF file. The HTML must be in XHTML format meaning that all elements are closed (i.e. <br> will NOT work but <br/> will). Most of CSS 2.1 is supported.

Two parameters are required:

A PDF file will be generated and stored in the database's storage bucket. The response will look like the following:

{"status":"OK","errorMessage":"","errorCode":"","data":"MyHelloWorld.pdf;1168;1522959552652;database/files/bfefdf76-521c-4085-b5fb-ff02206d49ae.pdf"}

In the above JSON response the "data" element is in ParaSQL DocumentField format. See the SQL/REST Documentation for example usage.

General Limitations

Responses to Server API calls are limited to ~32MB.

Actions must complete in less than 60 seconds.