https://github.com/masa-finance/masa-sdk-go
A Go library for the Masa universe
https://github.com/masa-finance/masa-sdk-go
Last synced: about 2 months ago
JSON representation
A Go library for the Masa universe
- Host: GitHub
- URL: https://github.com/masa-finance/masa-sdk-go
- Owner: masa-finance
- License: mit
- Created: 2024-12-17T23:23:59.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-15T18:47:31.000Z (4 months ago)
- Last Synced: 2025-01-26T12:14:56.580Z (4 months ago)
- Language: Go
- Size: 497 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Official Go SDK for the Masa Protocol
A powerful Go library for interacting with the Masa universe
[](https://goreportcard.com/report/github.com/masa-finance/masa-sdk-go)
[](https://godoc.org/github.com/masa-finance/masa-sdk-go)
[](https://opensource.org/licenses/MIT)## Features
- 🔄 **Asynchronous Request Queue** - Built-in priority queue system for handling concurrent API requests
- 🔍 **X (Twitter) Integration** - Comprehensive search and profile data retrieval
- ⚡ **Rate Limiting** - Intelligent rate limiting and retry mechanisms
- 🛡️ **Error Handling** - Robust error handling with custom error types
- 📊 **Response Management** - Channel-based response handling for async operations## Installation
```bash
go get github.com/masa-finance/masa-sdk-go
```## Quick Start
### Initialize Queue
```go
queue := x.NewRequestQueue(5) // 5 concurrent workers
queue.Start()
defer queue.Stop()
```### Search X (Twitter)
```go
responseChan := queue.AddRequest(x.SearchRequest, map[string]interface{}{
"query": "web3",
"count": 10,
"additionalProps": map[string]interface{}{
"fromDate": "2024-01-01",
"toDate": "2024-03-20",
},
}, x.DefaultPriority)response := <-responseChan
```### Get X Profile
```go
responseChan := queue.AddRequest(x.ProfileRequest, map[string]interface{}{
"username": "elonmusk",
}, x.DefaultPriority)response := <-responseChan
```## Queue Configuration
| Parameter | Default | Description |
|-----------|---------|-------------|
| MaxConcurrentRequests | 5 | Maximum number of concurrent workers |
| APIRequestsPerSecond | 20 | Rate limit for API requests |
| DefaultRetries | 10 | Number of retry attempts |
| DefaultPriority | 100 | Default priority for requests |## Error Handling
The SDK provides custom error types for different scenarios:
- RateLimitError
- WorkerRateLimitError
- TimeoutError
- ConnectionError
- EmptyResponseError## Testing
```bash
ginkgo tests/integration/x/... -v
```## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
- 📚 [Documentation](https://docs.masa.finance)
- 💬 [Discord Community](https://discord.gg/masa)
- 🐦 [Twitter](https://twitter.com/masa_finance)