{"id":20534170,"url":"https://github.com/gookit/greq","last_synced_at":"2026-02-21T08:12:03.858Z","repository":{"id":37942207,"uuid":"446292065","full_name":"gookit/greq","owner":"gookit","description":"🛠   greq is a simple http client request builder and sender.","archived":false,"fork":false,"pushed_at":"2025-06-03T06:05:03.000Z","size":152,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-03T17:59:29.276Z","etag":null,"topics":["golang","http","http-client","middleware","request"],"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/gookit.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-10T05:29:01.000Z","updated_at":"2025-06-03T06:04:59.000Z","dependencies_parsed_at":"2024-02-08T04:33:41.657Z","dependency_job_id":"d5132ca4-9568-411e-a103-3abcd413dda6","html_url":"https://github.com/gookit/greq","commit_stats":null,"previous_names":["gookit/hreq","gookit/hireq"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/gookit/greq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gookit%2Fgreq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gookit%2Fgreq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gookit%2Fgreq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gookit%2Fgreq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gookit","download_url":"https://codeload.github.com/gookit/greq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gookit%2Fgreq/sbom","scorecard":{"id":441112,"data":{"date":"2025-08-11","repo":{"name":"github.com/gookit/greq","commit":"aa421718f89120fe00698dca91874120da1cf217"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.3,"checks":[{"name":"Code-Review","score":-1,"reason":"Found no human activity in the last 30 changesets","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":1,"reason":"2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/gookit/greq/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/gookit/greq/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/gookit/greq/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/gookit/greq/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/gookit/greq/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/gookit/greq/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/gookit/greq/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/gookit/greq/release.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   6 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T05:36:00.134Z","repository_id":37942207,"created_at":"2025-08-19T05:36:00.134Z","updated_at":"2025-08-19T05:36:00.134Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29677134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T06:23:40.028Z","status":"ssl_error","status_checked_at":"2026-02-21T06:23:39.222Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["golang","http","http-client","middleware","request"],"created_at":"2024-11-16T00:25:35.636Z","updated_at":"2026-02-21T08:12:03.852Z","avatar_url":"https://github.com/gookit.png","language":"Go","readme":"# Greq\n\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/gookit/greq?style=flat-square)\n[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/gookit/greq)](https://github.com/gookit/goutil)\n[![GoDoc](https://pkg.go.dev/badge/github.com/gookit/greq.svg)](https://pkg.go.dev/github.com/gookit/greq)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gookit/greq)](https://goreportcard.com/report/github.com/gookit/greq)\n[![Unit-Tests](https://github.com/gookit/greq/workflows/Unit-Tests/badge.svg)](https://github.com/gookit/greq/actions)\n[![Coverage Status](https://coveralls.io/repos/github/gookit/greq/badge.svg?branch=main)](https://coveralls.io/github/gookit/greq?branch=main)\n\n\u003e [中文说明](README.zh-CN.md) | [English](README.md)\n\n**greq** A simple HTTP client request builder and sender, with retry feature.\n\n## Features\n\n- Make HTTP requests, supports `GET,POST,PUT,PATCH,DELETE,HEAD`\n- Transform request and response data\n- Supports chain configuration request\n- Supports defining and adding middleware\n- Supports defining request body provider and response decoder\n- Supports request retry feature, with default retry checker `DefaultRetryChecker`\n- Built-In: fom, json request body provider\n- Built-In: xml, json response body decoder\n- Support for directly parsing and sending `.http` file format requests\n- Supports download and upload file(s)\n- Built-in command tool:\n  - `cmd/greq` Lightweight HTTP request tool similar to curl and supports the IDEA `.http` file format\n  - `cmd/gbench` Lightweight HTTP request load testing tool similar to `ab` testing tool\n\n## Install\n\n```bash\ngo get github.com/gookit/greq\n```\n\n### Install Tools\n\n```bash\n# HTTP request tool\ngo install github.com/gookit/greq/cmd/greq@latest\n# HTTP request testing\ngo install github.com/gookit/greq/cmd/gbench@latest\n```\n\n## Quick start\n\n```go\npackage main\n\nimport (\n\t\"github.com/gookit/goutil/dump\"\n\t\"github.com/gookit/greq\"\n)\n\nfunc main() {\n\tresp, err := greq.New(\"https://httpbin.org\").\n\t\tJSONType().\n\t\tUserAgent(\"custom-client/1.0\").\n\t\tPostDo(\"/post\", `{\"name\": \"inhere\"}`)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tret := make(map[string]any)\n\terr = resp.Decode(\u0026ret)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdump.P(ret)\n}\n```\n\nResult:\n\n```text\nPRINT AT github.com/gookit/greq_test.TestHReq_Send(greq_test.go:73)\nmap[string]interface {} { #len=4\n  \"args\": map[string]interface {} { #len=0\n  },\n  \"headers\": map[string]interface {} { #len=4\n    \"Host\": string(\"httpbin.org\"), #len=11\n    \"User-Agent\": string(\"custom-client/1.0\"), #len=17\n    \"X-Amzn-Trace-Id\": string(\"Root=1-61e4d41e-06e27ae12ff872a224373ca7\"), #len=40\n    \"Accept-Encoding\": string(\"gzip\"), #len=4\n  },\n  \"origin\": string(\"222.210.59.218\"), #len=14\n  \"url\": string(\"https://httpbin.org/post\"), #len=24\n},\n```\n\n## Request headers\n\n```go\ngreq.New(\"some.host/api\").\n\tSetHeader(\"req-id\", \"a string\")\n```\n\nSet multi at once:\n\n```go\ngreq.New(\"some.host/api\").\n\tSetHeaders(map[string]string{\n\t\t\"req-id\": \"a string\",\n\t})\n```\n\n### Set content type\n\n```go\ngreq.New(\"some.host/api\").\n    ContentType(\"text/html\")\n```\n\nBuilt in `JSONType()` `FromType()` `XMLType()`\n\n```go\ngreq.New(\"some.host/api\").JSONType()\n```\n\n\n## Use middleware\n\n```go\n\tbuf := \u0026bytes.Buffer{}\n\tmid0 := greq.MiddleFunc(func(r *http.Request, next greq.HandleFunc) (*greq.Response, error) {\n\t\tbuf.WriteString(\"MID0\u003e\u003e\")\n\t\tw, err := next(r)\n\t\tbuf.WriteString(\"\u003e\u003eMID0\")\n\t\treturn w, err\n\t})\n\n\tmid1 := greq.MiddleFunc(func(r *http.Request, next greq.HandleFunc) (*greq.Response, error) {\n\t\tbuf.WriteString(\"MID1\u003e\u003e\")\n\t\tw, err := next(r)\n\t\tbuf.WriteString(\"\u003e\u003eMID1\")\n\t\treturn w, err\n\t})\n\n\tmid2 := greq.MiddleFunc(func(r *http.Request, next greq.HandleFunc) (*greq.Response, error) {\n\t\tbuf.WriteString(\"MID2\u003e\u003e\")\n\t\tw, err := next(r)\n\t\tbuf.WriteString(\"\u003e\u003eMID2\")\n\t\treturn w, err\n\t})\n\n\tresp, err := greq.New(\"https://httpbin.org\").\n\t\tDoer(httpreq.DoerFunc(func(req *http.Request) (*http.Response, error) {\n\t\t\ttw := httptest.NewRecorder()\n\t\t\tbuf.WriteString(\"(CORE)\")\n\t\t\treturn tw.Result(), nil\n\t\t})).\n\t\tMiddleware(mid0, mid1, mid2).\n\t\tGetDo(\"/get\")\n\n    fmt.Println(buf.String())\n```\n\n**Output**:\n\n```text\nMID2\u003e\u003eMID1\u003e\u003eMID0\u003e\u003e(CORE)\u003e\u003eMID0\u003e\u003eMID1\u003e\u003eMID2\n```\n\n## More usage\n\n### Check response\n\n- `Response.IsOK() bool`\n- `Response.IsFail() bool`\n- `Response.IsEmptyBody() bool`\n- `Response.IsJSONType() bool`\n- `Response.IsContentType(prefix string) bool`\n\n### Get response data\n\n- `Response.ContentType() string`\n- `Response.Decode(ptr any) error`\n\n### Request to string\n\n```go\n    str := greq.New(\"https://httpbin.org\").\n\t\tUserAgent(\"some-client/1.0\").\n\t\tBasicAuth(\"inhere\", \"some string\").\n\t\tJSONType().\n\t\tBody(\"hi, with body\").\n\t\tPost(\"/post\").\n\t\tString()\n\n\tfmt.Println(str)\n```\n\n**Output**:\n\n```text\nPOST https://httpbin.org/post/ HTTP/1.1\nUser-Agent: some-client/1.0\nAuthorization: Basic aW5oZXJlOnNvbWUgc3RyaW5n\nContent-Type: application/json; charset=utf-8\n\nhi, with body\n```\n\n### Response to string\n\n`greq.Response.String()` can convert response to string.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/gookit/goutil/dump\"\n\t\"github.com/gookit/greq\"\n)\n\nfunc main() {\n\tresp, err := greq.New(\"https://httpbin.org\").\n\t\tUserAgent(\"custom-client/1.0\").\n\t\tSend(\"/get\")\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Print(resp.String())\n}\n```\n\n**Output**:\n\n```text\nHTTP/2.0 200 OK\nAccess-Control-Allow-Origin: *\nAccess-Control-Allow-Credentials: true\nDate: Tue, 18 Jan 2022 04:52:39 GMT\nContent-Type: application/json\nContent-Length: 272\nServer: gunicorn/19.9.0\n\n{\n  \"args\": {},\n  \"headers\": {\n    \"Accept-Encoding\": \"gzip\",\n    \"Host\": \"httpbin.org\",\n    \"User-Agent\": \"custom-client/1.0\",\n    \"X-Amzn-Trace-Id\": \"Root=1-61e64797-3e428a925f7709906a8b7c01\"\n  },\n  \"origin\": \"222.210.59.218\",\n  \"url\": \"https://httpbin.org/get\"\n}\n```\n\n## Command Tool Usage\n\n### `greq` Tool\n\n`cmd/greq` Lightweight HTTP request tool similar to curl and supports the IDEA `.http` file format\n\n**Install tool**:\n\n```bash\ngo install github.com/gookit/greq/cmd/greq@latest\n```\n\n**Show options**:\n\n```bash\ngreq -h\n```\n\n**Usage examples**:\n\n```bash\ngreq https://httpbin.org/get\ngreq -X POST -d '{\"name\": \"inhere\"}' https://httpbin.org/post\n```\n\n### `gbench` Tool\n\n`cmd/gbench` Lightweight HTTP request load testing tool similar to `ab` testing tool\n\n**Install tool**:\n\n```bash\ngo install github.com/gookit/greq/cmd/gbench@latest\n```\n\n**Show options**:\n\n```bash\ngbench -h\n```\n\n**Usage examples**：\n\n```bash\ngbench -c 10 -n 100 https://httpbin.org/get\ngbench -c 10 -n 100 -d '{\"name\": \"inhere\"}' https://httpbin.org/post\n```\n\n## Refers\n\n- https://github.com/dghubble/sling\n- https://github.com/zhshch2002/goreq\n- https://github.com/go-resty/resty\n- https://github.com/monaco-io/request\n\n[1]: https://github.com/dghubble/sling\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgookit%2Fgreq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgookit%2Fgreq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgookit%2Fgreq/lists"}