Closed Nhoya closed 7 years ago
can you provide the full code with the timeout implemented? Also this library currently doesn't do much except make API calls and no checking of rate limiting. The rate limiting doc for it is here: https://haveibeenpwned.com/API/v2#RateLimiting
Yea sure, using 2 sec as sleep will work, the problem is that the library should have a better handling for this
import (
"fmt"
"github.com/mavjs/goPwned"
"time"
)
func main() {
fmt.Println("==== HAVEIBEENPWND SEARCH ====")
mails := []string{"mail1", "mail2", "mail3", "mail4"} #insert valid mail here
for _, mail := range mails {
fmt.Println(mail)
stuff, err := gopwned.GetAllBreachesForAccount(mail, "", "true")
if err == nil {
for _, data := range stuff {
fmt.Println(data)
}
} else {
fmt.Println(stuff)
fmt.Println(err)
}
time.Sleep(time.Second * 2)
}
}
Yes, rate limiting should be there, but it currently doesn't. If you have a way of doing it, send a pull request. I'm working on this on my own time and as a way to learn good practices in go/coding libraries (thus the 2nd committer in the code), so you could say this library isn't feature complete.
For now, I don't really have time or motivation to work on this yet, so closing this for now.
This is a library, rate limit should be done by the users, similarly to any database API.
This test case will fail for all the mail except the first,
the output is
seems like the requests are too fast and get blocked, i tried with sleep 500 but still nothing, any idea?