
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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/my-change)
- Commit your changes (
git commit -m 'Describe change')
- Push to your branch
- Open a Pull Request
(back to top)
License
Distributed under the Apache-2.0 License. See LICENSE for details.
(back to top)