Skip to content

Commit 43cb99d

Browse files
committed
fix bugs and improve code quality
1 parent f02e82b commit 43cb99d

26 files changed

+1775
-2560
lines changed

README.md

+93-26
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,128 @@
1-
# eBird client for Go
1+
# go-ebird: eBird API Client for Go
22

3-
[![GoDoc](https://godoc.org/github.com/siansiansu/go-ebird?status.svg)](http://godoc.org/github.com/siansiansu/go-ebird) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3+
[![GoDoc](https://godoc.org/github.com/siansiansu/go-ebird?status.svg)](http://godoc.org/github.com/siansiansu/go-ebird)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
[![Go Report Card](https://goreportcard.com/badge/github.com/siansiansu/go-ebird)](https://goreportcard.com/report/github.com/siansiansu/go-ebird)
46

57
## Overview
68

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.
810

911
## Features
1012

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.
1418

1519
## Installation
1620

17-
Install `go-ebird` using `go get`:
21+
Install go-ebird using `go get`:
1822

1923
```shell
2024
go get -u github.com/siansiansu/go-ebird
2125
```
2226

23-
## Usage
27+
## Quick Start
28+
29+
Here's a simple example to get you started:
2430

2531
```go
2632
package main
2733

2834
import (
29-
"context"
30-
"fmt"
35+
"context"
36+
"fmt"
37+
"log"
3138

32-
"github.com/siansiansu/go-ebird"
39+
"github.com/siansiansu/go-ebird"
3340
)
3441

3542
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+
}
4856
}
4957
```
5058

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+
```
5292

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.
5496

5597
## Contributing
5698

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+
```
58116

59117
## License
60118

61119
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

Comments
 (0)