{"id":23131160,"url":"https://github.com/friendlycaptcha/friendly-captcha-go-sdk","last_synced_at":"2025-08-17T08:31:03.492Z","repository":{"id":57708020,"uuid":"420052953","full_name":"FriendlyCaptcha/friendly-captcha-go-sdk","owner":"FriendlyCaptcha","description":"A Go client for the Friendly Captcha verification API","archived":false,"fork":false,"pushed_at":"2024-10-24T14:03:53.000Z","size":18,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-25T17:15:02.645Z","etag":null,"topics":["captcha","friendly-captcha","golang","libary","sdk"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FriendlyCaptcha.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}},"created_at":"2021-10-22T10:13:56.000Z","updated_at":"2024-10-24T14:03:56.000Z","dependencies_parsed_at":"2022-09-08T11:24:27.661Z","dependency_job_id":null,"html_url":"https://github.com/FriendlyCaptcha/friendly-captcha-go-sdk","commit_stats":null,"previous_names":["friendlycaptcha/friendly-captcha-go"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FriendlyCaptcha%2Ffriendly-captcha-go-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FriendlyCaptcha%2Ffriendly-captcha-go-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FriendlyCaptcha%2Ffriendly-captcha-go-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FriendlyCaptcha%2Ffriendly-captcha-go-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FriendlyCaptcha","download_url":"https://codeload.github.com/FriendlyCaptcha/friendly-captcha-go-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230105996,"owners_count":18173954,"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","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":["captcha","friendly-captcha","golang","libary","sdk"],"created_at":"2024-12-17T11:12:12.277Z","updated_at":"2024-12-17T11:12:12.928Z","avatar_url":"https://github.com/FriendlyCaptcha.png","language":"Go","readme":"# friendly-captcha-go-sdk\nA Go client for the Friendly Captcha v1 verification API.\n\n\u003e Note: This is for Friendly Captcha v1 only, if you are creating a new implementation you probably want to use the new [**Friendly Captcha Go SDK**](https://github.com/FriendlyCaptcha/friendly-captcha-go).\n\n## Installation\n```\ngo get github.com/friendlycaptcha/friendly-captcha-go-sdk\n```\n\n## Usage\n\n```go\nimport \"github.com/friendlycaptcha/friendly-captcha-go-sdk\"\n\nfrcClient := friendlycaptcha.NewClient(apikey, sitekey)\n```\n\n\n```go\n// In your middleware or request handler\nsolution := r.FormValue(friendlycaptcha.SolutionFormFieldName)\nshouldAccept, err := frcClient.CheckCaptchaSolution(r.Context(), solution)\n\nif err != nil {\n    if errors.Is(err, friendlycaptcha.ErrVerificationFailedDueToClientError) {\n        log.Printf(\"!!!!!\\n\\nFriendlyCaptcha is misconfigured! Check your Friendly Captcha API key and sitekey: %v\\n\", err)\n        // Send yourself an alert - the captcha won't be able to do its job to prevent spam.\n    } else if (errors.Is(err, friendlycaptcha.ErrVerificationRequest)) {\n        log.Printf(\"Could not talk to the Friendly Captcha API: %v\\n\", err)\n        // Perhaps the Friendly Captcha API is down?\n    }\n}\n\nif !shouldAccept { // The captcha was invalid\n    // Show the user a message that the anti-robot verification failed and that they should try again\n    return\n}\n\n// The captcha check was succesful, handle the request :)\n```\n\nBeware that the `CheckCaptchaSolution` function returns two values:\n * Whether you should accept the request (`bool`)\n * An error (or nil)\n \n Even if the error is non-nil, the first boolean value may still be true and you should accept the request! \n### Advanced, optional strictness setting\nAs a best practice we accept the captcha solution if we are unable to verify it: if we misconfigure our apikey or Friendly Captcha's API goes down we would rather accept all requests than lock all users out. \n\n If you want to change this behavior you can set `client.Strict` to true, then the accept value will only be true if we were actually able to verify the captcha solution and it was valid.\n\n\n## Example\n\nRun the example\n```shell\ncd examples/form\nFRC_SITEKEY=\u003cmy sitekey\u003e FRC_APIKEY=\u003cmy api key\u003e go run main.go\n```\n\nThen open your browser and head to [http://localhost:8844](http://localhost:8844)\n\n\u003e Note: you can create a sitekey and API key in the [Friendly Captcha dashboard](https://app.friendlycaptcha.com/account).\n\n**Example Screenshot**\n\n![Example screenshot](https://i.imgur.com/bsp7qDA.png)\n\n## License\n[MIT](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendlycaptcha%2Ffriendly-captcha-go-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriendlycaptcha%2Ffriendly-captcha-go-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendlycaptcha%2Ffriendly-captcha-go-sdk/lists"}