Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card Codecov Go Version License Release Stars Issues


Logo

client-go

Go client library for SMSGate APIs.
Explore API docs »

Report Bug · Request Feature

About The Project

client-go provides typed clients for the SMSGate ecosystem:

  • smsgateway package for 3rd-party API operations (messages, devices, health, logs, settings, webhooks, and token lifecycle).
  • ca package for Certificate Authority workflows (submit CSR and check CSR status).
  • Shared low-level HTTP handling in the rest package.

The library supports both Basic authentication (user + password) and Bearer token authentication for the SMSGate client.

(back to top)

Built With

  • Go 1.22+
  • Standard net/http client with configurable transport

(back to top)

Getting Started

Prerequisites

  • Go 1.22 or newer
  • SMSGate account/device credentials and/or API token

Installation

go get github.com/android-sms-gateway/client-go

(back to top)

Usage

SMSGate client (smsgateway)

package main

import (
	"context"
	"log"
	"os"

	"github.com/android-sms-gateway/client-go/smsgateway"
)

func main() {
	ctx := context.Background()

	client := smsgateway.NewClient(smsgateway.Config{
		User:     os.Getenv("ASG_USERNAME"),
		Password: os.Getenv("ASG_PASSWORD"),
		// or use Token: os.Getenv("ASG_TOKEN"),
	})

	state, err := client.Send(ctx, smsgateway.Message{
		TextMessage: &smsgateway.TextMessage{Text: "Hello from Go"},
		PhoneNumbers: []string{
			"+15555550100",
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("message queued: %s", state.ID)
}

Certificate Authority client (ca)

package main

import (
	"context"
	"log"

	"github.com/android-sms-gateway/client-go/ca"
)

func main() {
	ctx := context.Background()
	client := ca.NewClient()

	resp, err := client.PostCSR(ctx, ca.PostCSRRequest{
		Type:    ca.CSRTypeWebhook,
		Content: "-----BEGIN CERTIFICATE REQUEST-----...",
	})
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("request id: %s, status: %s", resp.RequestID, resp.Status)
}

(back to top)

API Coverage

smsgateway.Client

  • Messages: Send, GetState
  • Devices: ListDevices, DeleteDevice
  • Health: CheckHealth
  • Inbox export: ExportInbox
  • Logs: GetLogs
  • Settings: GetSettings, UpdateSettings, ReplaceSettings
  • Webhooks: ListWebhooks, RegisterWebhook, DeleteWebhook
  • Token management: GenerateToken, RefreshToken, RevokeToken

For endpoint semantics and payload details, see https://api.sms-gate.app/

ca.Client

  • CSR workflows: PostCSR, GetCSRStatus

(back to top)

Contributing

Contributions are welcome. Please open an issue to discuss major changes before submitting a pull request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/my-change)
  3. Commit your changes (git commit -m 'Describe change')
  4. Push to your branch
  5. Open a Pull Request

(back to top)

License

Distributed under the Apache-2.0 License. See LICENSE for details.

(back to top)