LogoLogo
Studio
4.5
4.5
  • Harper Docs
  • Getting Started
  • Developers
    • Applications
      • Caching
      • Defining Schemas
      • Defining Roles
      • Debugging Applications
      • Define Fastify Routes
      • Web Applications
      • Example Projects
    • Components
      • Managing
      • Reference
      • Built-In Components
    • REST
    • Operations API
      • Quick Start Examples
      • Databases and Tables
      • NoSQL Operations
      • Bulk Operations
      • Users and Roles
      • Clustering
        • Clustering with NATS
      • Custom Functions
      • Components
      • Registration
      • Jobs
      • Logs
      • Utilities
      • Token Authentication
      • SQL Operations
      • Advanced JSON SQL Examples
    • Real-Time
    • Replication/Clustering
      • Sharding
      • Legacy NATS Clustering
        • Requirements and Definitions
        • Creating A Cluster User
        • Naming A Node
        • Enabling Clustering
        • Establishing Routes
        • Subscription Overview
        • Managing Subscriptions
        • Things Worth Knowing
        • Certificate Management
    • Security
      • JWT Authentication
      • Basic Authentication
      • mTLS Authentication
      • Configuration
      • Users & Roles
      • Certificate Management
    • SQL Guide
      • SQL Features Matrix
      • SQL Date Functions
      • SQL Reserved Word
      • SQL Functions
      • SQL JSON Search
      • SQL Geospatial Functions
    • Miscellaneous
      • Google Data Studio
      • SDKs
      • Query Optimization
  • Administration
    • Best Practices and Recommendations
    • Logging
      • Standard Logging
      • Audit Logging
      • Transaction Logging
    • Clone Node
    • Compact
    • Jobs
    • Harper Studio
      • Create an Account
      • Log In & Password Reset
      • Organizations
      • Instances
      • Query Instance Data
      • Manage Databases / Browse Data
      • Manage Clustering
      • Manage Instance Users
      • Manage Instance Roles
      • Manage Applications
      • Instance Metrics
      • Instance Configuration
      • Enable Mixed Content
  • Deployments
    • Configuration File
    • Harper CLI
    • Install Harper
      • On Linux
    • Upgrade a Harper Instance
    • Harper Cloud
      • IOPS Impact on Performance
      • Instance Size Hardware Specs
      • Alarms
      • Verizon 5G Wavelength
  • Technical Details
    • Reference
      • Analytics
      • Architecture
      • Content Types
      • Data Types
      • Dynamic Schema
      • GraphQL
      • Harper Headers
      • Harper Limits
      • Globals
      • Resource Class
      • Transactions
      • Storage Algorithm
      • Blob
    • Release Notes
      • Harper Tucker (Version 4)
        • 4.5.8
        • 4.5.7
        • 4.5.6
        • 4.5.5
        • 4.5.4
        • 4.5.3
        • 4.5.2
        • 4.5.1
        • 4.5.0
        • 4.4.24
        • 4.4.23
        • 4.4.22
        • 4.4.21
        • 4.4.20
        • 4.4.19
        • 4.4.18
        • 4.4.17
        • 4.4.16
        • 4.4.15
        • 4.4.14
        • 4.4.13
        • 4.4.12
        • 4.4.11
        • 4.4.10
        • 4.4.9
        • 4.4.8
        • 4.4.7
        • 4.4.6
        • 4.4.5
        • 4.4.4
        • 4.4.3
        • 4.4.2
        • 4.4.1
        • 4.4.0
        • 4.3.38
        • 4.3.37
        • 4.3.36
        • 4.3.35
        • 4.3.34
        • 4.3.33
        • 4.3.32
        • 4.3.31
        • 4.3.30
        • 4.3.29
        • 4.3.28
        • 4.3.27
        • 4.3.26
        • 4.3.25
        • 4.3.24
        • 4.3.23
        • 4.3.22
        • 4.3.21
        • 4.3.20
        • 4.3.19
        • 4.3.18
        • 4.3.17
        • 4.3.16
        • 4.3.15
        • 4.3.14
        • 4.3.13
        • 4.3.12
        • 4.3.11
        • 4.3.10
        • 4.3.9
        • 4.3.8
        • 4.3.7
        • 4.3.6
        • 4.3.5
        • 4.3.4
        • 4.3.3
        • 4.3.2
        • 4.3.1
        • 4.3.0
        • 4.2.8
        • 4.2.7
        • 4.2.6
        • 4.2.5
        • 4.2.4
        • 4.2.3
        • 4.2.2
        • 4.2.1
        • 4.2.0
        • 4.1.2
        • 4.1.1
        • 4.1.0
        • 4.0.7
        • 4.0.6
        • 4.0.5
        • 4.0.4
        • 4.0.3
        • 4.0.2
        • 4.0.1
        • 4.0.0
        • Tucker
      • HarperDB Monkey (Version 3)
        • 3.3.0
        • 3.2.1
        • 3.2.0
        • 3.1.5
        • 3.1.4
        • 3.1.3
        • 3.1.2
        • 3.1.1
        • 3.1.0
        • 3.0.0
      • HarperDB Penny (Version 2)
        • 2.3.1
        • 2.3.0
        • 2.2.3
        • 2.2.2
        • 2.2.0
        • 2.1.1
      • HarperDB Alby (Version 1)
        • 1.3.1
        • 1.3.0
        • 1.2.0
        • 1.1.0
  • More Help
    • Support
    • Slack
    • Contact Us
Powered by GitBook
On this page
  • Create dog Table
  • Body
  • Response: 200
  • Create breed Table
  • Body
  • Response: 200
  • Insert 1 Dog
  • Body
  • Response: 200
  • Insert Multiple Dogs
  • Body
  • Response: 200
  • Bulk Insert Breeds Via CSV
  • Body
  • Response: 200
  • Update 1 Dog Using NoSQL
  • Body
  • Response: 200
  • Select a Dog by ID Using SQL
  • Body
  • Response: 200
  • Select Dogs and Join Breed
  • Body
  • Response: 200
  1. Developers
  2. Operations API

Quick Start Examples

PreviousOperations APINextDatabases and Tables

Last updated 1 month ago

Harper recommends utilizing for defining databases, tables, and other functionality. However, this guide is a great way to get started using on the Harper Operations API.

Create dog Table

We first need to create a table. Since our company is named after our CEO's dog, lets create a table to store all our employees' dogs. We'll call this table, dogs.

Tables in Harper are schema-less, so we don't need to add any attributes other than a primary_key (in pre 4.2 versions this was referred to as the hash_attribute) to create this table.

Harper does offer a database parameter that can be used to hold logical groupings of tables. The parameter is optional and if not provided the operation will default to using a database named data.

If you receive an error response, make sure your Basic Authentication user and password match those you entered during the installation process.

Body

{
    "operation": "create_table",
    "table": "dog",
    "primary_key": "id"
}

Response: 200

{
    "message": "table 'data.dog' successfully created."
}

Create breed Table

Now that we have a table to store our dog data, we also want to create a table to track known breeds. Just as with the dog table, the only attribute we need to specify is the primary_key.

Body

{
    "operation": "create_table",
    "table": "breed",
    "primary_key": "id"
}

Response: 200

{
    "message": "table 'data.breed' successfully created."
}

Insert 1 Dog

We're ready to add some dog data. Penny is our CTO's pup, so she gets ID 1 or we're all fired. We are specifying attributes in this call, but this doesn't prevent us from specifying additional attributes in subsequent calls.

Body

{
    "operation": "insert",
    "table": "dog",
    "records": [
        {
            "id": 1,
            "dog_name": "Penny",
            "owner_name": "Kyle",
            "breed_id": 154,
            "age": 7,
            "weight_lbs": 38
        }
    ]
}

Response: 200

{
    "message": "inserted 1 of 1 records",
    "inserted_hashes": [
        1
    ],
    "skipped_hashes": []
}

Insert Multiple Dogs

Let's add some more Harper doggies! We can add as many dog objects as we want into the records collection. If you're adding a lot of objects, we would recommend using the .csv upload option (see the next section where we populate the breed table).

Body

{
    "operation": "insert",
    "table": "dog",
    "records": [
        {
            "id": 2,
            "dog_name": "Harper",
            "owner_name": "Stephen",
            "breed_id": 346,
            "age": 7,
            "weight_lbs": 55,
            "adorable": true
        },
        {
            "id": 3,
            "dog_name": "Alby",
            "owner_name": "Kaylan",
            "breed_id": 348,
            "age": 7,
            "weight_lbs": 84,
            "adorable": true
        },
        {
            "id": 4,
            "dog_name": "Billy",
            "owner_name": "Zach",
            "breed_id": 347,
            "age": 6,
            "weight_lbs": 60,
            "adorable": true
        },
        {
            "id": 5,
            "dog_name": "Rose Merry",
            "owner_name": "Zach",
            "breed_id": 348,
            "age": 8,
            "weight_lbs": 15,
            "adorable": true
        },
        {
            "id": 6,
            "dog_name": "Kato",
            "owner_name": "Kyle",
            "breed_id": 351,
            "age": 6,
            "weight_lbs": 32,
            "adorable": true
        },
        {
            "id": 7,
            "dog_name": "Simon",
            "owner_name": "Fred",
            "breed_id": 349,
            "age": 3,
            "weight_lbs": 35,
            "adorable": true
        },
        {
            "id": 8,
            "dog_name": "Gemma",
            "owner_name": "Stephen",
            "breed_id": 350,
            "age": 5,
            "weight_lbs": 55,
            "adorable": true
        },
        {
            "id": 9,
            "dog_name": "Yeti",
            "owner_name": "Jaxon",
            "breed_id": 200,
            "age": 5,
            "weight_lbs": 55,
            "adorable": true
        },
        {
            "id": 10,
            "dog_name": "Monkey",
            "owner_name": "Aron",
            "breed_id": 271,
            "age": 7,
            "weight_lbs": 35,
            "adorable": true
        },
        {
            "id": 11,
            "dog_name": "Bode",
            "owner_name": "Margo",
            "breed_id": 104,
            "age": 8,
            "weight_lbs": 75,
            "adorable": true
        },
        {
            "id": 12,
            "dog_name": "Tucker",
            "owner_name": "David",
            "breed_id": 346,
            "age": 2,
            "weight_lbs": 60,
            "adorable": true
        },
        {
            "id": 13,
            "dog_name": "Jagger",
            "owner_name": "Margo",
            "breed_id": 271,
            "age": 7,
            "weight_lbs": 35,
            "adorable": true
        }
    ]
}

Response: 200

{
    "message": "inserted 12 of 12 records",
    "inserted_hashes": [
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13
    ],
    "skipped_hashes": []
}

Bulk Insert Breeds Via CSV

We need to populate the 'breed' table with some data so we can reference it later. For larger data sets, we recommend using our CSV upload option.

Each header in a column will be considered as an attribute, and each row in the file will be a row in the table. Simply specify the file path and the table to upload to, and Harper will take care of the rest. You can pull the breeds.csv file from here: https://s3.amazonaws.com/complimentarydata/breeds.csv

Body

{
    "operation": "csv_url_load",
    "table": "breed",
    "csv_url": "https://s3.amazonaws.com/complimentarydata/breeds.csv"
}

Response: 200

{
    "message": "Starting job with id e77d63b9-70d5-499c-960f-6736718a4369",
    "job_id": "e77d63b9-70d5-499c-960f-6736718a4369"
}

Update 1 Dog Using NoSQL

Harper supports NoSQL and SQL commands. We're going to update the dog table to show Penny's last initial using our NoSQL API.

Body

{
    "operation": "update",
    "table": "dog",
    "records": [
        {
            "id": 1,
            "dog_name": "Penny B"
        }
    ]
}

Response: 200

{
    "message": "updated 1 of 1 records",
    "update_hashes": [
        1
    ],
    "skipped_hashes": []
}

Select a Dog by ID Using SQL

Now we're going to use a simple SQL SELECT call to pull Penny's updated data. Note we now see Penny's last initial in the dog name.

Body

{
    "operation": "sql",
    "sql": "SELECT * FROM data.dog where id = 1"
}

Response: 200

[
    {
        "owner_name": "Kyle",
        "adorable": null,
        "breed_id": 154,
        "__updatedtime__": 1610749428575,
        "dog_name": "Penny B",
        "weight_lbs": 38,
        "id": 1,
        "age": 7,
        "__createdtime__": 1610749386566
    }
]

Select Dogs and Join Breed

Here's a more complex SQL command joining the breed table with the dog table. We will also pull only the pups belonging to Kyle, Zach, and Stephen.

Body

{
    "operation": "sql",
    "sql": "SELECT d.id, d.dog_name, d.owner_name, b.name, b.section FROM data.dog AS d INNER JOIN data.breed AS b ON d.breed_id = b.id WHERE d.owner_name IN ('Kyle', 'Zach', 'Stephen') AND b.section = 'Mutt' ORDER BY d.dog_name"
}

Response: 200

[
    {
        "id": 4,
        "dog_name": "Billy",
        "owner_name": "Zach",
        "name": "LABRADOR / GREAT DANE MIX",
        "section": "Mutt"
    },
    {
        "id": 8,
        "dog_name": "Gemma",
        "owner_name": "Stephen",
        "name": "SHORT HAIRED SETTER MIX",
        "section": "Mutt"
    },
    {
        "id": 2,
        "dog_name": "Harper",
        "owner_name": "Stephen",
        "name": "HUSKY MIX",
        "section": "Mutt"
    },
    {
        "id": 5,
        "dog_name": "Rose Merry",
        "owner_name": "Zach",
        "name": "TERRIER MIX",
        "section": "Mutt"
    }
]
Harper Applications