|
1 |
| -# eBird client for Go |
| 1 | +# go-ebird: eBird API Client for Go |
2 | 2 |
|
3 |
| -[](http://godoc.org/github.com/siansiansu/go-ebird) [](https://opensource.org/licenses/MIT) |
| 3 | +[](http://godoc.org/github.com/siansiansu/go-ebird) |
| 4 | +[](https://opensource.org/licenses/MIT) |
| 5 | +[](https://goreportcard.com/report/github.com/siansiansu/go-ebird) |
4 | 6 |
|
5 | 7 | ## Overview
|
6 | 8 |
|
7 |
| -go-ebird is a Go client library designed for the eBird API. This library enables developers to seamlessly integrate bird observation data from eBird into their Go applications. |
| 9 | +go-ebird is a comprehensive Go client library for the eBird API. It provides an easy-to-use interface for developers to integrate bird observation data from eBird into their Go applications. |
8 | 10 |
|
9 | 11 | ## Features
|
10 | 12 |
|
11 |
| -- **Data Retrieval**: Access bird observation data from eBird effortlessly. |
12 |
| -- **Flexible Filtering**: Filter data based on parameters such as location, date, and species. |
13 |
| -- **Easy Integration**: Integrate eBird data seamlessly into your Go applications. |
| 13 | +- **Comprehensive Data Access**: Retrieve various types of bird observation data, including recent observations, notable sightings, and checklists. |
| 14 | +- **Flexible Filtering**: Filter data based on location, date, species, and more. |
| 15 | +- **Robust Error Handling**: Clear error messages and proper handling of API rate limits. |
| 16 | +- **Customizable Client**: Configure timeout, base URL, and other HTTP client options. |
| 17 | +- **Full API Coverage**: Support for all major eBird API endpoints. |
14 | 18 |
|
15 | 19 | ## Installation
|
16 | 20 |
|
17 |
| -Install `go-ebird` using `go get`: |
| 21 | +Install go-ebird using `go get`: |
18 | 22 |
|
19 | 23 | ```shell
|
20 | 24 | go get -u github.com/siansiansu/go-ebird
|
21 | 25 | ```
|
22 | 26 |
|
23 |
| -## Usage |
| 27 | +## Quick Start |
| 28 | + |
| 29 | +Here's a simple example to get you started: |
24 | 30 |
|
25 | 31 | ```go
|
26 | 32 | package main
|
27 | 33 |
|
28 | 34 | import (
|
29 |
| - "context" |
30 |
| - "fmt" |
| 35 | + "context" |
| 36 | + "fmt" |
| 37 | + "log" |
31 | 38 |
|
32 |
| - "github.com/siansiansu/go-ebird" |
| 39 | + "github.com/siansiansu/go-ebird" |
33 | 40 | )
|
34 | 41 |
|
35 | 42 | func main() {
|
36 |
| - var ctx = context.Background() |
37 |
| - client, err := ebird.NewClient("YOUR_EBIRD_API_KEY") |
38 |
| - if err != nil { |
39 |
| - panic(err) |
40 |
| - } |
41 |
| - r, err := client.RecentNotableObservationsInRegion(ctx, "TW") |
42 |
| - if err != nil { |
43 |
| - panic(err) |
44 |
| - } |
45 |
| - for _, e := range r { |
46 |
| - fmt.Println(e.ComName, e.LocName, e.HowMany) |
47 |
| - } |
| 43 | + client, err := ebird.NewClient("YOUR_EBIRD_API_KEY") |
| 44 | + if err != nil { |
| 45 | + log.Fatalf("Failed to create client: %v", err) |
| 46 | + } |
| 47 | + |
| 48 | + observations, err := client.RecentObservationsInRegion(context.Background(), "US-NY", ebird.MaxResults(5)) |
| 49 | + if err != nil { |
| 50 | + log.Fatalf("Failed to get observations: %v", err) |
| 51 | + } |
| 52 | + |
| 53 | + for _, obs := range observations { |
| 54 | + fmt.Printf("%s spotted at %s\n", obs.ComName, obs.LocName) |
| 55 | + } |
48 | 56 | }
|
49 | 57 | ```
|
50 | 58 |
|
51 |
| -Remember to replace `"YOUR_EBIRD_API_KEY"` with your actual eBird API key. You can obtain an API key by creating an account on the [eBird website](https://ebird.org/api/keygen). |
| 59 | +## Detailed Usage |
| 60 | + |
| 61 | +Check out the [examples directory](./examples/) for more detailed usage examples, including: |
| 62 | + |
| 63 | +- Retrieving notable observations |
| 64 | +- Getting nearby hotspots |
| 65 | +- Fetching recent checklists |
| 66 | +- Accessing taxonomy information |
| 67 | + |
| 68 | +## API Endpoints |
| 69 | + |
| 70 | +go-ebird supports all major eBird API endpoints, including: |
| 71 | + |
| 72 | +- Observations |
| 73 | +- Hotspots |
| 74 | +- Taxonomy |
| 75 | +- Checklists |
| 76 | +- Region information |
| 77 | + |
| 78 | +Refer to the [GoDoc](https://pkg.go.dev/github.com/siansiansu/go-ebird) for a complete list of supported endpoints and their usage. |
| 79 | + |
| 80 | +## Configuration |
| 81 | + |
| 82 | +You can configure the client with various options: |
| 83 | + |
| 84 | +```go |
| 85 | +client, err := ebird.NewClient( |
| 86 | + "YOUR_EBIRD_API_KEY", |
| 87 | + ebird.WithBaseURL("https://api.ebird.org/v2/"), |
| 88 | + ebird.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}), |
| 89 | + ebird.WithAcceptLanguage("en"), |
| 90 | +) |
| 91 | +``` |
52 | 92 |
|
53 |
| -Refer to the [GoDoc](https://pkg.go.dev/github.com/siansiansu/go-ebird) page for comprehensive documentation and more examples. |
| 93 | +## Rate Limiting |
| 94 | + |
| 95 | +The eBird API has rate limits. This client does not automatically handle rate limiting, so be sure to implement appropriate backoff and retry logic in your application. |
54 | 96 |
|
55 | 97 | ## Contributing
|
56 | 98 |
|
57 |
| -Contributions are welcome! Report bugs or request features by opening an issue. If you want to contribute code, fork the repository and submit a pull request. |
| 99 | +Contributions are welcome! Here's how you can contribute: |
| 100 | + |
| 101 | +1. Fork the repository |
| 102 | +2. Create your feature branch (`git checkout -b feature/AmazingFeature`) |
| 103 | +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) |
| 104 | +4. Push to the branch (`git push origin feature/AmazingFeature`) |
| 105 | +5. Open a Pull Request |
| 106 | + |
| 107 | +Please ensure your code adheres to the existing style and includes appropriate tests. |
| 108 | + |
| 109 | +## Testing |
| 110 | + |
| 111 | +Run the tests using: |
| 112 | + |
| 113 | +```shell |
| 114 | +go test -v ./... |
| 115 | +``` |
58 | 116 |
|
59 | 117 | ## License
|
60 | 118 |
|
61 | 119 | This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
| 120 | + |
| 121 | +## Acknowledgments |
| 122 | + |
| 123 | +- Thanks to the eBird team for providing the API |
| 124 | +- Inspired by other excellent Go API clients |
| 125 | + |
| 126 | +## Support |
| 127 | + |
| 128 | +If you encounter any issues or have questions, please [open an issue](https://github.com/siansiansu/go-ebird/issues/new) on GitHub. |
0 commit comments