{"id":31940740,"url":"https://github.com/ableinc/go-notificationsapi","last_synced_at":"2025-10-14T09:00:05.341Z","repository":{"id":310526282,"uuid":"1040209210","full_name":"ableinc/go-notificationsapi","owner":"ableinc","description":"Unofficial Go NotificationsAPI SDK. ","archived":false,"fork":false,"pushed_at":"2025-08-18T16:19:25.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-18T18:21:43.849Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ableinc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-18T16:08:46.000Z","updated_at":"2025-08-18T16:17:17.000Z","dependencies_parsed_at":"2025-08-18T18:23:12.255Z","dependency_job_id":null,"html_url":"https://github.com/ableinc/go-notificationsapi","commit_stats":null,"previous_names":["ableinc/go-notificationsapi"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ableinc/go-notificationsapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ableinc%2Fgo-notificationsapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ableinc%2Fgo-notificationsapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ableinc%2Fgo-notificationsapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ableinc%2Fgo-notificationsapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ableinc","download_url":"https://codeload.github.com/ableinc/go-notificationsapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ableinc%2Fgo-notificationsapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018308,"owners_count":26086352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-14T09:00:03.428Z","updated_at":"2025-10-14T09:00:05.334Z","avatar_url":"https://github.com/ableinc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NotificationAPI Go Server SDK\n\n[![Go Version](https://img.shields.io/badge/go-%3E%3D1.24-blue.svg)](https://golang.org/)\n[![License](https://img.shields.io/badge/license-ISC-green.svg)](https://opensource.org/licenses/ISC)\n\nThe official Go server SDK for [NotificationAPI](https://www.notificationapi.com). This library allows you to send notifications, manage users, and interact with the NotificationAPI platform from your Go applications.\n\n## Features\n\n- Send notifications across multiple channels (Email, SMS, Push, In-App, etc.)\n- User management and identification\n- Notification preferences management\n- Scheduled notifications\n- Sub-notifications\n- Comprehensive logging and querying\n- Regional API endpoint support\n- Full type safety with Go structs\n\n## Installation\n\n```bash\ngo get github.com/ableinc/go-notificationsapi\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \n    \"github.com/ableinc/go-notificationsapi\"\n)\n\nfunc main() {\n    // Initialize the client\n    client, err := notificationapi.NewClient(\"your-client-id\", \"your-client-secret\", nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Send a notification\n    req := notificationapi.SendRequest{\n        Type: stringPtr(\"welcome_email\"),\n        To: \u0026notificationapi.User{\n            ID:    \"user123\",\n            Email: stringPtr(\"user@example.com\"),\n        },\n        Parameters: map[string]interface{}{\n            \"firstName\": \"John\",\n            \"lastName\":  \"Doe\",\n        },\n    }\n\n    resp, err := client.Send(req)\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    fmt.Printf(\"Notification sent successfully: %d\\n\", resp.StatusCode)\n}\n\n// Helper function to create string pointers\nfunc stringPtr(s string) *string {\n    return \u0026s\n}\n```\n\n## Configuration\n\n### Regional Endpoints\n\nYou can configure the SDK to use different regional endpoints:\n\n```go\n// US Region (default)\nclient, err := notificationapi.NewClient(clientID, clientSecret, \u0026notificationapi.InitConfiguration{\n    BaseURL: string(notificationapi.USRegion),\n})\n\n// EU Region\nclient, err := notificationapi.NewClient(clientID, clientSecret, \u0026notificationapi.InitConfiguration{\n    BaseURL: string(notificationapi.EURegion),\n})\n\n// CA Region\nclient, err := notificationapi.NewClient(clientID, clientSecret, \u0026notificationapi.InitConfiguration{\n    BaseURL: string(notificationapi.CARegion),\n})\n\n// Custom endpoint\nclient, err := notificationapi.NewClient(clientID, clientSecret, \u0026notificationapi.InitConfiguration{\n    BaseURL: \"https://your-custom-endpoint.com\",\n})\n```\n\n## Usage Examples\n\n### Sending Notifications\n\n#### Basic Notification\n\n```go\nreq := notificationapi.SendRequest{\n    Type: stringPtr(\"user_welcome\"),\n    To: \u0026notificationapi.User{\n        ID:    \"user123\",\n        Email: stringPtr(\"user@example.com\"),\n    },\n    Parameters: map[string]interface{}{\n        \"name\": \"John Doe\",\n        \"company\": \"Acme Corp\",\n    },\n}\n\nresp, err := client.Send(req)\n```\n\n#### Notification with Channel-Specific Content\n\n```go\nreq := notificationapi.SendRequest{\n    Type: stringPtr(\"order_confirmation\"),\n    To: \u0026notificationapi.User{\n        ID:     \"user123\",\n        Email:  stringPtr(\"user@example.com\"),\n        Number: stringPtr(\"+1234567890\"),\n    },\n    Email: \u0026notificationapi.ChannelEmail{\n        Subject: \"Order Confirmation #12345\",\n        HTML:    \"\u003ch1\u003eThank you for your order!\u003c/h1\u003e\u003cp\u003eOrder #12345 has been confirmed.\u003c/p\u003e\",\n    },\n    SMS: \u0026notificationapi.ChannelSMS{\n        Message: \"Your order #12345 has been confirmed. Thank you!\",\n    },\n}\n\nresp, err := client.Send(req)\n```\n\n#### Scheduled Notification\n\n```go\nreq := notificationapi.SendRequest{\n    Type: stringPtr(\"reminder\"),\n    To: \u0026notificationapi.User{\n        ID:    \"user123\",\n        Email: stringPtr(\"user@example.com\"),\n    },\n    Schedule: stringPtr(\"2024-12-25T10:00:00Z\"), // ISO 8601 format\n    Parameters: map[string]interface{}{\n        \"eventName\": \"Holiday Sale\",\n    },\n}\n\nresp, err := client.Send(req)\n```\n\n#### Force Specific Channels\n\n```go\nreq := notificationapi.SendRequest{\n    Type: stringPtr(\"urgent_alert\"),\n    To: \u0026notificationapi.User{\n        ID:     \"user123\",\n        Email:  stringPtr(\"user@example.com\"),\n        Number: stringPtr(\"+1234567890\"),\n    },\n    ForceChannels: []notificationapi.Channels{\n        notificationapi.EMAIL,\n        notificationapi.SMS,\n    },\n}\n\nresp, err := client.Send(req)\n```\n\n### User Management\n\n#### Identify User\n\n```go\nuser := notificationapi.User{\n    ID:       \"user123\",\n    Email:    stringPtr(\"user@example.com\"),\n    Number:   stringPtr(\"+1234567890\"),\n    Timezone: stringPtr(\"America/New_York\"),\n    PushTokens: []notificationapi.PushToken{\n        {\n            Type:  notificationapi.FCM,\n            Token: \"fcm-token-here\",\n            Device: notificationapi.Device{\n                DeviceID: \"device123\",\n                Platform: stringPtr(\"android\"),\n            },\n        },\n    },\n}\n\nresp, err := client.IdentifyUser(user)\n```\n\n### User Preferences\n\n#### Set User Preferences\n\n```go\npreferences := []notificationapi.SetUserPreferencesRequest{\n    {\n        NotificationID: \"order_updates\",\n        Channel:        stringPtr(string(notificationapi.EMAIL)),\n        Delivery:       stringPtr(\"daily\"),\n    },\n    {\n        NotificationID: \"marketing\",\n        Delivery:       stringPtr(\"off\"),\n    },\n}\n\nresp, err := client.SetUserPreferences(\"user123\", preferences)\n```\n\n#### Delete User Preferences\n\n```go\n// Delete all preferences for a notification\nresp, err := client.DeleteUserPreferences(\"user123\", \"marketing\", nil)\n\n// Delete preferences for a specific sub-notification\nsubNotificationID := \"special_offers\"\nresp, err := client.DeleteUserPreferences(\"user123\", \"marketing\", \u0026subNotificationID)\n```\n\n### Sub-Notifications\n\n#### Create Sub-Notification\n\n```go\nreq := notificationapi.CreateSubNotificationRequest{\n    NotificationID:    \"order_updates\",\n    Title:             \"Express Shipping Updates\",\n    SubNotificationID: \"express_shipping\",\n}\n\nresp, err := client.CreateSubNotification(req)\n```\n\n#### Delete Sub-Notification\n\n```go\nreq := notificationapi.DeleteSubNotificationRequest{\n    NotificationID:    \"order_updates\",\n    SubNotificationID: \"express_shipping\",\n}\n\nresp, err := client.DeleteSubNotification(req)\n```\n\n### In-App Notifications\n\n#### Update In-App Notification Status\n\n```go\nreq := notificationapi.InAppNotificationPatchRequest{\n    TrackingIDs: []string{\"tracking-id-1\", \"tracking-id-2\"},\n    Opened:      stringPtr(\"2024-01-01T12:00:00Z\"),\n    Clicked:     stringPtr(\"2024-01-01T12:05:00Z\"),\n    Reply: \u0026notificationapi.ReplyInfo{\n        Date:    \"2024-01-01T12:10:00Z\",\n        Message: \"Thank you for the update!\",\n    },\n}\n\nresp, err := client.UpdateInAppNotification(\"user123\", req)\n```\n\n### Scheduled Notifications\n\n#### Update Scheduled Notification\n\n```go\nupdateReq := notificationapi.SendRequest{\n    Schedule: stringPtr(\"2024-12-26T10:00:00Z\"), // New schedule\n    Parameters: map[string]interface{}{\n        \"newParam\": \"updated value\",\n    },\n}\n\nresp, err := client.UpdateSchedule(\"tracking-id\", updateReq)\n```\n\n#### Delete Scheduled Notification\n\n```go\nresp, err := client.DeleteSchedule(\"tracking-id\")\n```\n\n### Retract Notifications\n\n```go\nreq := notificationapi.RetractRequest{\n    NotificationID: \"order_confirmation\",\n    UserID:         \"user123\",\n}\n\nresp, err := client.Retract(req)\n```\n\n### Query Logs\n\n#### Basic Log Query\n\n```go\nparams := notificationapi.QueryLogsPostBody{\n    DateRangeFilter: \u0026notificationapi.DateRangeFilter{\n        StartTime: int64Ptr(1640995200), // Unix timestamp\n        EndTime:   int64Ptr(1641081600),\n    },\n    NotificationFilter: []string{\"order_confirmation\", \"welcome_email\"},\n    ChannelFilter:      []notificationapi.Channels{notificationapi.EMAIL, notificationapi.SMS},\n    UserFilter:         []string{\"user123\", \"user456\"},\n    StatusFilter:       []string{\"sent\", \"delivered\"},\n}\n\nresp, err := client.QueryLogs(params)\n```\n\n#### Custom Log Query\n\n```go\nparams := notificationapi.QueryLogsPostBody{\n    CustomFilter: stringPtr(\"fields @message | filter @logStream like /ERROR/ | sort @timestamp desc\"),\n}\n\nresp, err := client.QueryLogs(params)\n```\n\n## Error Handling\n\nThe SDK automatically handles HTTP errors and provides detailed error messages:\n\n```go\nresp, err := client.Send(req)\nif err != nil {\n    // Handle error\n    fmt.Printf(\"Error sending notification: %v\\n\", err)\n    return\n}\n\n// Check for warning responses (HTTP 202)\nif resp.StatusCode == 202 {\n    // Warning logged automatically, but you can handle it here\n    fmt.Println(\"Notification sent with warnings\")\n}\n```\n\n## Email Options\n\n### Email Attachments\n\n```go\nreq := notificationapi.SendRequest{\n    Type: stringPtr(\"invoice\"),\n    To: \u0026notificationapi.User{\n        ID:    \"user123\",\n        Email: stringPtr(\"user@example.com\"),\n    },\n    Options: \u0026notificationapi.NotificationOptions{\n        Email: \u0026notificationapi.EmailOptions{\n            FromName:         stringPtr(\"Acme Corp\"),\n            FromAddress:      stringPtr(\"noreply@acme.com\"),\n            ReplyToAddresses: []string{\"support@acme.com\"},\n            CCAddresses:      []string{\"accounting@acme.com\"},\n            Attachments: []notificationapi.EmailAttachment{\n                {\n                    Filename: \"invoice-12345.pdf\",\n                    URL:      \"https://secure.acme.com/invoices/12345.pdf\",\n                },\n            },\n        },\n    },\n}\n\nresp, err := client.Send(req)\n```\n\n## Push Notifications\n\n### Mobile Push Notifications\n\n```go\n// First, identify user with push tokens\nuser := notificationapi.User{\n    ID: \"user123\",\n    PushTokens: []notificationapi.PushToken{\n        {\n            Type:  notificationapi.FCM,\n            Token: \"fcm-device-token\",\n            Device: notificationapi.Device{\n                DeviceID: \"device123\",\n                Platform: stringPtr(\"android\"),\n                AppID:    stringPtr(\"com.acme.app\"),\n            },\n        },\n        {\n            Type:  notificationapi.APN,\n            Token: \"apn-device-token\",\n            Device: notificationapi.Device{\n                DeviceID: \"device456\",\n                Platform: stringPtr(\"ios\"),\n                AppID:    stringPtr(\"com.acme.app\"),\n            },\n        },\n    },\n}\n\n_, err := client.IdentifyUser(user)\nif err != nil {\n    log.Fatal(err)\n}\n\n// Send push notification\nreq := notificationapi.SendRequest{\n    Type: stringPtr(\"new_message\"),\n    To: \u0026notificationapi.User{\n        ID: \"user123\",\n    },\n    MobilePush: \u0026notificationapi.ChannelMobilePush{\n        Title:   \"New Message\",\n        Message: \"You have a new message from John\",\n    },\n    Options: \u0026notificationapi.NotificationOptions{\n        APN: \u0026notificationapi.APNOptions{\n            Badge:  intPtr(1),\n            Sound:  stringPtr(\"default\"),\n            ThreadID: stringPtr(\"messages\"),\n        },\n        FCM: \u0026notificationapi.FCMOptions{\n            Android: \u0026notificationapi.AndroidFCMOptions{\n                Priority: stringPtr(\"high\"),\n                TTL:      intPtr(3600),\n            },\n        },\n    },\n}\n\nresp, err := client.Send(req)\n```\n\n### Web Push Notifications\n\n```go\n// First, identify user with web push tokens\nuser := notificationapi.User{\n    ID: \"user123\",\n    WebPushTokens: []notificationapi.WebPushToken{\n        {\n            Sub: notificationapi.PushSubscription{\n                Endpoint: \"https://fcm.googleapis.com/fcm/send/...\",\n                Keys: struct {\n                    P256dh string `json:\"p256dh\"`\n                    Auth   string `json:\"auth\"`\n                }{\n                    P256dh: \"p256dh-key-here\",\n                    Auth:   \"auth-key-here\",\n                },\n            },\n        },\n    },\n}\n\n_, err := client.IdentifyUser(user)\nif err != nil {\n    log.Fatal(err)\n}\n\n// Send web push notification\nreq := notificationapi.SendRequest{\n    Type: stringPtr(\"breaking_news\"),\n    To: \u0026notificationapi.User{\n        ID: \"user123\",\n    },\n    WebPush: \u0026notificationapi.ChannelWebPush{\n        Title:   \"Breaking News\",\n        Message: \"Important update from our team\",\n        Icon:    stringPtr(\"https://example.com/icon.png\"),\n        URL:     stringPtr(\"https://example.com/news/123\"),\n    },\n}\n\nresp, err := client.Send(req)\n```\n\n## API Reference\n\n### Types\n\n#### Channels\n- `EMAIL` - Email notifications\n- `INAPP_WEB` - In-app web notifications  \n- `SMS` - SMS notifications\n- `CALL` - Call notifications\n- `PUSH` - Mobile push notifications\n- `WEB_PUSH` - Web push notifications\n\n#### Regions\n- `USRegion` - United States (default)\n- `EURegion` - European Union\n- `CARegion` - Canada\n\n#### Push Providers\n- `FCM` - Firebase Cloud Messaging\n- `APN` - Apple Push Notification service\n\n### Helper Functions\n\nSince Go doesn't have optional parameters, you'll often need to create pointers to basic types:\n\n```go\n// Helper functions you might want to add to your code\nfunc stringPtr(s string) *string {\n    return \u0026s\n}\n\nfunc intPtr(i int) *int {\n    return \u0026i\n}\n\nfunc int64Ptr(i int64) *int64 {\n    return \u0026i\n}\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## Testing\n\nRun the test suite:\n\n```bash\ngo test -v\n```\n\nRun tests with coverage:\n\n```bash\ngo test -v -cover\n```\n\n## License\n\nThis project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\n- [Documentation](https://docs.notificationapi.com)\n- [API Reference](https://docs.notificationapi.com/reference)\n- [Support Portal](https://notificationapi.com/support)\n- [GitHub Issues](https://github.com/ableinc/go-notificationsapi/issues)\n\n## Changelog\n\n### v1.0.0\n- Initial release\n- Full feature parity with Node.js SDK\n- Support for all NotificationAPI features\n- Comprehensive test coverage\n- Go 1.24+ support\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fableinc%2Fgo-notificationsapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fableinc%2Fgo-notificationsapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fableinc%2Fgo-notificationsapi/lists"}