All Projects → nulab → go-typetalk

nulab / go-typetalk

Licence: MIT license
go-typetalk is a GO client library for accessing the Typetalk API.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-typetalk

pyFireEye
Python API bindings for FireEye Products
Stars: ✭ 12 (-36.84%)
Mutual labels:  api-client
pywnedpasswords
Checkt pwnedpasswords.com in a secure way
Stars: ✭ 22 (+15.79%)
Mutual labels:  api-client
jellyfin-apiclient-python
Python API Client for Jellyfin
Stars: ✭ 30 (+57.89%)
Mutual labels:  api-client
Clamor
The Python Discord API Framework
Stars: ✭ 14 (-26.32%)
Mutual labels:  api-client
braze-php-sdk
A PHP client to interact with Braze API
Stars: ✭ 15 (-21.05%)
Mutual labels:  api-client
closeio-api
Python API Client for Close
Stars: ✭ 53 (+178.95%)
Mutual labels:  api-client
my api client
A framework of Web API Client. Provides features error handling, retrying, pagination and so on.
Stars: ✭ 19 (+0%)
Mutual labels:  api-client
echovr api docs
Unofficial documentation for Echo VR's HTTP API
Stars: ✭ 19 (+0%)
Mutual labels:  api-client
dnsimple-python
The DNSimple API client for Python.
Stars: ✭ 66 (+247.37%)
Mutual labels:  api-client
kdecole-api
Unofficial Node.js API client of Kdecole (Skolengo EMS)
Stars: ✭ 31 (+63.16%)
Mutual labels:  api-client
ssc-restapi-client
Communicate with Fortify Software Security Center through REST API in java, a swagger generated client
Stars: ✭ 13 (-31.58%)
Mutual labels:  api-client
v-shopware-api-client
The reliable way to import and update a bazillion products.
Stars: ✭ 20 (+5.26%)
Mutual labels:  api-client
wporg-client
Standalone HTTP client for public WordPress.org API.
Stars: ✭ 73 (+284.21%)
Mutual labels:  api-client
jacky
🐄 HTTP JSON API Client for Laravel & Lumen
Stars: ✭ 17 (-10.53%)
Mutual labels:  api-client
redash-api-client
Redash API Client written in Python
Stars: ✭ 36 (+89.47%)
Mutual labels:  api-client
bitflyer-api-dotnet-client
bitFlyer HTTP APIs Client Library for .NET (C#)
Stars: ✭ 23 (+21.05%)
Mutual labels:  api-client
Jib.jl
A Julia implementation of Interactive Brokers API
Stars: ✭ 42 (+121.05%)
Mutual labels:  api-client
connectapi
An R package for interacting with the RStudio Connect Server API
Stars: ✭ 26 (+36.84%)
Mutual labels:  api-client
tiktok-scraper-php
Tiktok (Musically) PHP scraper
Stars: ✭ 65 (+242.11%)
Mutual labels:  api-client
NClient
💫 NClient is an automatic type-safe .Net HTTP client that allows you to call web service API methods using annotated interfaces or controllers without boilerplate code.
Stars: ✭ 25 (+31.58%)
Mutual labels:  api-client

go-typetalk

Build Status Coverage Status Documentation

go-typetalk is a GO client library for accessing the Typetalk API.

Prerequisite

To use this library, you must have a valid client id and client secret provided by Typetalk and register a new client application. Or you can use the Typetalk Token.

Usage

Import

Use v1:

import "github.com/nulab/go-typetalk/v3/typetalk/v1" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/nulab/go-typetalk/typetalk/v1" // with go modules disabled

Use v2:

import "github.com/nulab/go-typetalk/v3/typetalk/v2" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/nulab/go-typetalk/typetalk/v2" // with go modules disabled

Use v3:

import "github.com/nulab/go-typetalk/v3/typetalk/v3" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/nulab/go-typetalk/typetalk/v3" // with go modules disabled

Access APIs using Typetalk Token

package main

import (
	"context"

	v1 "github.com/nulab/go-typetalk/typetalk/v1"
)

func main() {
	client := v1.NewClient(nil)
	client.SetTypetalkToken("yourTypetalkToken")
	ctx := context.Background()
	topicID := 1
	message := "Hello"
	profile, resp, err := client.Messages.PostMessage(ctx, topicId, message, nil)
}

Access APIs using OAuth2 Access Token

package main

import (
	"context"
	"encoding/json"
	"net/http"
	"net/url"

	v1 "github.com/nulab/go-typetalk/typetalk/v1"
	"golang.org/x/oauth2"
)

type AccessToken struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

func main() {
	form := url.Values{}
	form.Add("client_id", "yourClientId")
	form.Add("client_secret", "yourClientSecret")
	form.Add("grant_type", "client_credentials")
	form.Add("scope", "topic.read,topic.post,topic.write,topic.delete,my")
	oauth2resp, err := http.PostForm("https://typetalk.com/oauth2/access_token", form)
	if err != nil {
		print("Client Credential request returned error")
	}
	v := &AccessToken{}
	json.NewDecoder(oauth2resp.Body).Decode(v)

	tc := oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: v.AccessToken},
	))

	client := v1.NewClient(tc)
	profile, resp, err := client.Accounts.GetMyProfile(context.Background())
}

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].