HarperDB API
HarperDB provides a REST API at the endpoint localhost:9925. Commands are sent in JSON format as an HTTP request body.
Creating a schema and a table, and inserting data:
{operation: "create_schema", schema: "hr"}
{operation: "create_table", schema: "hr", table: "employee", hash_attribute: "empno"}
{operation: "insert", schema: "hr", table: "employee", records: [{empno: 1, name: "Nitin"}]}
Fetching data
{operation: "search_by_hash", "schema": "hr", table: "employee", hash_values: [1], get_attributes: ["name"]}
{operation: "search_by_hash", "schema": "hr", table: "employee", hash_values: [1], get_attributes: ["*"]}
{operation: "search_by_value", schema: "hr", table: "employee", search_attribute: "name", search_value: "Nit*", get_attributes: ["*"]}
{operation: "sql", sql: "UPDATE hr.employee SET department='engineering' WHERE empno=1"}
{operation: "sql", sql: "SELECT * FROM hr.employee WHERE name LIKE 'Nit%' ORDER BY empno DESC"} //Can also do JOINs
Importing Data
{operation: "csv_file_load", schema: "hr", table: "employee", action: "insert", file_path: "/data.csv"}
{operation: "get_job", id: "<from output of csv_file_load>"}
HarperDB Studio provides the ability to export data to CSV
Finding the contents of a schema:
{operation: "describe_schema", schema: "hr"}
HarperDB maintains a transaction log of all changes, which is accessible from:
{operation: "read_transaction_log"}