Go/Golang client library to interact with the Stein API

Related tags

Network go-stein
Overview

go-stein

This Go / Golang client helps you interact with the Stein API.

Stein is a suite of programs to help you turn any Google Sheet to a database. The core Stein API provides RESTful access to your sheets.

SteinHQ

Installation

$ go get github.com/nasrul21/go-stein

Usage

Initalize

package main

import (
    "time"
    stein "github.com/nasrul21/go-stein"
)

func main() {
    client := stein.NewClient(
        "https://api.steinhq.com/v1/storages/5cca0542e52a3545102c1665", // STEIN URL 
        // you can set the option nil, if your stein doesn't need authentication
        &stein.Option{
            Username: "user", // your STEIN API username
            Password: "password", // your STEIN API password
            Timeout: 20 * time.Second, // set timeout for Stein Request, default: 15s
        },
    )

    ...
}

Read Data

client.Read(sheetName, filter, v)

Arguments

Name Description Format Requirement
sheetName Your sheet name String Required
filter Filter / Query data by column name map[string]interface{} Optional (nil)
v The result will be given to v Struct / map[string]interface{} Required

Example

// set your filter
filter := map[string]interface{
    "ID": 134,
}
result := &YourStruct{}
status, err := client.Read("Sheet1", filter, &result)

// if you want to get the data without filter
// status, err := client.Read("Sheet1", nil, &result)

if err != nil {
    log.Fatal("Error read from stein: " + err)
    return
}

fmt.Printf("HTTP Status: %d \n", status)
fmt.Printf("Result : %v \n", result)

Insert Data / Add Rows

client.Insert(sheetName, body) (status, res, err)

Arguments

Name Description Format Requirement
sheetName Your sheet's name String Required
body The data you want to add Array of Struct Required

Return Value

Name Description Format
status HTTP Status Response Number (Status Code)
res Response of updated range InsertResponse
err Error message error

Example

type Employee struct {
    Name        string `json:"name"`
    Department  string `json:"department"`
    Position    string `json:"position"`
}

employees := []Employee{
    {
        Name:       "Nasrul",
        Department: "Technology",
        Position:   "Software Engineer",
    },
    // add another field of you want to insert multiple rows
    // {
    // 	...
    // },
}

status, res, err := client.Insert("Sheet1", employees)
if err != nil {
    log.Fatal("Error insert data to stein: ", status, err.Error())
    return
}

fmt.Printf("HTTP Status: %d \n", status)
fmt.Printf("Updated Range : %v \n", res)

Update Data

client.Update(sheetName, set, where) (status, res, err)

Arguments

Name Description Format Requirement
sheetName Your sheet's name String Required
set The column values to set {column: value, ...} Required
where The column values to search for {column: value, ...} Optional

Return Value

Name Description Format
status HTTP Status Response Number (Status Code)
res Response of updated range UpdateResponse
err Error message error

Example

employee := Employee{
    Name:       "Nasrul",
    Department: "Technology",
    Position:   "Software Engineer",
}

where := map[string]interface{}{
    "ID": 156,
}

status, res, err := client.Update("Sheet1", employee, where)
if err != nil {
    log.Fatal("Error update data to stein: ", status, err.Error())
    return
}

fmt.Printf("HTTP Status: %d \n", status)
fmt.Printf("Updated Range : %v \n", res)

Delete Data

client.Delete(sheetName, condition) (status, res, err)

Arguments

Name Description Format Requirement
sheetName Your sheet's name String Required
condition The column values to search for {column: value, ...} Required

Return Value

Name Description Format
status HTTP Status Response Number (Status Code)
res Response of updated range DeleteResponse
err Error message error

Example

status, res, err := client.Delete("Sheet1", map[string]interface{}{
    "ID": 156,
})
if err != nil {
    log.Fatal("Error delete data: ", status, err.Error())
    return
}

fmt.Printf("HTTP Status: %d \n", status)
fmt.Printf("Deleted Range : %v \n", res)

License

MIT licensed

Issues
  • Add Pagination on feature Read Data

    Add Pagination on feature Read Data

    current condition, the read data function still displays all the data. hopefully, we can do pagination by adding limit and offset parameters according to this stein API documentation: https://docs.steinhq.com/read-data#optional-request-parameters

    hacktoberfest 
    opened by nasrul21 0
Releases(v0.2.0)
Owner
Nasrul Faizin
Open Source Enthusiast.
Nasrul Faizin
Sonarcon - Uses the SonarQube API to interact and extract sources from public instances

Sonarcon Uses the SonarQube API to interact and extract sources from public inst

null 0 Feb 17, 2022
A Golang protobuf plugin used to generate the necessary interfaces to interact with the database

protoc-gen-go-db-enum This protobuf compiler plugin generates the Valuer and Scanner interfaces for enums defined in the proto files. It is highly bas

Hellyson Rodrigo Parteka 0 Nov 29, 2021
Spin up a local instance of an Avalanche network to interact with the standard APIs or to test a custom VM

ava-sim ava-sim makes it easy for anyone to spin up a local instance of an Avalanche network to interact with the standard APIs or to test a custom VM

Ava Labs 27 Aug 16, 2022
Godaddy-domains-client-go - Godaddy domains api Client golang - Write automaticly from swagger codegen

Go API client for swagger Overview This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you c

Mickael Stanislas 0 Jan 9, 2022
Tailscale-client-go - A client implementation for the Tailscale HTTP API

tailscale-client-go A client implementation for the Tailscale HTTP API Example p

David Bond 10 Aug 12, 2022
Client library with golang for accessing Harbor API.

go-client Client library with golang for accessing Harbor API. Client Types There are 3 swagger files in this repo. api/ v2.0/ legacy_swag

Harbor 15 Jul 25, 2022
An API Client package for Studyplus for School SYNC API

Studyplus for School SYNC API Client This project is currently alpha, possibility having breaking changes. studyplus_for_school_sync_go is a API clien

atomiyama 4 Aug 2, 2021
Go API Client for Metasploit RPC API

go-msf-rpc Golang based RPC client to communicate with Metasploit. Based on code initially developed by Wyatt Dahlenburg repo. Extended to include oth

Fagamous Prime 17 May 15, 2022
Go client library for accessing the Football Data API

football-data-sdk football-data-sdk is a Go client library for accessing the Football Data API. Successful queries return native Go structs. Services

Matheus Tex 12 Mar 15, 2022
brickset is a Go client library for accessing the brickset.com API v3.

brickset is a Go client library for accessing the brickset.com API v3.

null 3 May 21, 2022
Prisma Client Go is an auto-generated and fully type-safe database client

Prisma Client Go Typesafe database access for Go Quickstart • Website • Docs • API reference • Blog • Slack • Twitter Prisma Client Go is an auto-gene

Prisma 1.3k Aug 12, 2022
The Dual-Stack Dynamic DNS client, the world's first dynamic DNS client built for IPv6.

dsddns DsDDNS is the Dual-Stack Dynamic DNS client. A dynamic DNS client keeps your DNS records in sync with the IP addresses associated with your hom

Ryan Young 12 Aug 10, 2022
Go Substrate RPC Client (GSRPC)Go Substrate RPC Client (GSRPC)

Go Substrate RPC Client (GSRPC) Substrate RPC client in Go. It provides APIs and types around Polkadot and any Substrate-based chain RPC calls. This c

Chino Chang 1 Nov 11, 2021
Server and client implementation of the grpc go libraries to perform unary, client streaming, server streaming and full duplex RPCs from gRPC go introduction

Description This is an implementation of a gRPC client and server that provides route guidance from gRPC Basics: Go tutorial. It demonstrates how to u

Joram Wambugu 0 Nov 24, 2021
Comunicación de envios de archivos entres cliente-servidor, client-client.

Client - Server - Client Estes es un proyecto simple de comunicacion de envios de archivos del cliente al servidor y viceversamente, y de cliente a cl

Melvin RB 1 Jul 16, 2022
Golang client for querying SecurityTrails API data

haktrails haktrails is a Golang client for querying SecurityTrails API data, sponsored by SecurityTrails. SecurityTrails $50 Bug Bounty Hunter Plan Sa

Luke Stephens (hakluke) 214 Aug 12, 2022
Autify's web API client for Golang

autify-go This is a Go wrapper for working with Autify's Web API. This project tries to connect the Web API Endpoint easily by using this library. Ins

Teruo Kunihiro 8 Nov 9, 2021
Simple mDNS client/server library in Golang

mdns Simple mDNS client/server library in Golang. mDNS or Multicast DNS can be used to discover services on the local network without the use of an au

HashiCorp 896 Aug 7, 2022