{"id":13831920,"url":"https://github.com/WillAbides/octo-go","last_synced_at":"2025-07-09T15:34:00.556Z","repository":{"id":57536462,"uuid":"264309095","full_name":"WillAbides/octo-go","owner":"WillAbides","description":"A generated go client for GitHub's REST API","archived":false,"fork":false,"pushed_at":"2020-09-10T22:18:59.000Z","size":4513,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-21T12:17:18.316Z","etag":null,"topics":["api","client","github","golang","rest"],"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/WillAbides.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":"2020-05-15T22:10:25.000Z","updated_at":"2024-06-07T18:41:32.000Z","dependencies_parsed_at":"2022-08-28T17:42:08.486Z","dependency_job_id":null,"html_url":"https://github.com/WillAbides/octo-go","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":"WillAbides/goproject-tmpl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WillAbides%2Focto-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WillAbides%2Focto-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WillAbides%2Focto-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WillAbides%2Focto-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WillAbides","download_url":"https://codeload.github.com/WillAbides/octo-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213903224,"owners_count":15654934,"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":["api","client","github","golang","rest"],"created_at":"2024-08-04T10:01:44.500Z","updated_at":"2024-08-04T10:08:01.088Z","avatar_url":"https://github.com/WillAbides.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# octo-go\n\n[![godoc](https://godoc.org/github.com/WillAbides/octo-go?status.svg)](https://godoc.org/github.com/WillAbides/octo-go)\n[![ci](https://github.com/WillAbides/octo-go/workflows/ci/badge.svg?branch=main\u0026event=push)](https://github.com/WillAbides/octo-go/actions?query=workflow%3Aci+branch%3Amain+event%3Apush)\n\nocto-go is an experimental client for GitHub's v3 API. It is generated from the openapi schema published at \nhttps://github.com/github/rest-api-description\n\nProject status: __Experimental__\n\n## Overview\n\nFor every API endpoint, octo-cli provides a request struct and a response struct. The request struct is used to build \nthe http request, and the response struct is used to handle the api's response. You can use these structs as-is and \nhandle all the http details yourself, or you can let octo-go do the request for you as well. Each endpoint also has a \nfunction that accepts the endpoints request struct and returns the response struct.\n\nLet's use the `issues/create` endpoint as an example. You would use `issues.CreateReq` to build your request.\n\nYou can build a request like this:\n\n```go\nreq := issues.CreateReq{\n    Owner: \"myorg\",\n    Repo:  \"myrepo\",\n    RequestBody: issues.CreateReqBody{\n        Title: octo.String(\"hello world\"),\n        Body:  octo.String(\"greetings from octo-cli\"),\n        Labels: []string{\"test\", \"hello-world\"},\n    },\n}\n```\n\nThen you can perform the request with:\n\n```go\nresp, err := issues.Create(ctx, \u0026req)\n```\n\nAnd finally get the id of the newly created issue with:\n\n```go\nissueID := resp.Data.Id\n```\n\n## User Agent\n\nGitHub requires all requests have a User-Agent header set. Octo-go sets it to `octo-go` by default, but please set it\n to the name of your program instead. Do that with the option `octo.WithUserAgent(\"my wonderful computer program\")`.\n\n## Authentication\n\nIn most situations, octo-go can handle the authentication, but you can also provide your own transport to set the\n Authentication header if you want.\n \n### Personal Access Token\n\nThis is the simplest and most common way to authenticate.\n\n```go\nmyToken := os.Getenv(\"GITHUB_TOKEN\") // or however you want to provide your token\n\nclient := octo.NewClient(octo.WithPATAuth(myToken))\n```\n\n### GitHub App\n\nIf you want to authenticate as a GitHub App, octo can do that for you too. You need to provide the app's private key\n in PEM format along with your app's ID.\n\n```go\nappID := int64(1)\nkey, err := ioutil.ReadFile(\"appsecretkey.pem\")\nif err != nil {\n    log.Fatal(err)\n}\nclient := octo.NewClient(octo.WithAppAuth(appID, key))\n```\n\n### GitHub App Installation\n\nTo authenticate as a GitHub App Installation, you need the installation's ID along with the app's ID and private key.\n\n```go\nappID := int64(1)\ninstallationID := int64(99)\nkey, err := ioutil.ReadFile(\"appsecretkey.pem\")\nif err != nil {\n    log.Fatal(err)\n}\n\ninstTokenClient := octo.NewClient(octo.WithAppAuth(appID, key))\n\nauth := octo.WithAppInstallationAuth(installationID, instTokenClient, nil)\nclient := octo.NewClient(auth)\n```\n\nWhen authenticating as an App Installation, you can also limit the token's authorization to specific repositories and\n scopes by setting the request body used to create the token.\n \n```go\nappID := int64(1)\ninstallationID := int64(99)\nrepoID := int64(12)\nkey, err := ioutil.ReadFile(\"appsecretkey.pem\")\nif err != nil {\n    log.Fatal(err)\n}\n\ninstTokenClient := octo.NewClient(octo.WithAppAuth(appID, key))\n\nauth := octo.WithAppInstallationAuth(installationID, instTokenClient, \u0026apps.CreateInstallationAccessTokenReqBody{\n    Permissions: map[string]string{\n        \"deployments\": \"write\",\n        \"content\":     \"read\",\n    },\n    RepositoryIds: []int64{repoID},\n})\nclient := octo.NewClient(auth)\n```\n\n## Pagination\n\nThe GitHub API supports paging through result sets using relative links in the Link header. Octo-go makes use of\n these headers to enable paging. Every response has the methods `RelLink(lnk string)` and `HasRelLink(lnk string)` \n to get relative links. You can call this with `RelNext` for the next page of results, `RelPrev` for the previous\n page. `RelFirst` and `RelLast` point the first and last page of results.\n \nEvery request has a `Rel(lnk string, resp *ResponseType)` method that will update the request to point to a response's\n relative link.\n \nLet me demonstrate with an example. `getReleaseBlockers` will page through all open golang/go issues that are labeled\n \"release-blocker\" and return their titles.\n\n```go\nfunc getReleaseBlockers(ctx context.Context, client octo.Client) ([]string, error) {\n\tvar result []string\n\n\t// Build the initial request.\n\treq := \u0026issues.ListForRepoReq{\n\t\tOwner:  \"golang\",\n\t\tRepo:   \"go\",\n\t\tLabels: octo.String(\"release-blocker\"),\n\t}\n\n\t// ok will be true as long as there is a next page.\n\tfor ok := true; ok; {\n\t\t// Get a page of issues.\n\t\tresp, err := client.Issues().ListForRepo(ctx, req)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Add issue titles to the result.\n\t\tfor _, issue := range resp.Data {\n\t\t\tresult = append(result, issue.Title)\n\t\t}\n\n\t\t// Update req to point to the next page of results.\n\t\t// If there is no next page, req.Rel will return false and break the loop\n\t\tok = req.Rel(octo.RelNext, resp)\n\t}\n\treturn result, nil\n}\n```\n\n## Rate Limits\n\nThe GitHub API has a general rate limit of 5,000 requests per hour for most authenticated requests and 60 per hour per\n ip address for unauthenticated requests. More details are in the [API documentation](https://developer.github.com/v3/#rate-limiting).\n\nThe API includes rate limit information in response headers, and octo-go provides three helper functions:\n\n`octo.RateLimitRemaining()` - returns the number of requests remaining (or -1 if the header is missing)\n\n`octo.RateLimitReset()` - returns the time when the rate limit will reset (or zero value if the header is missing)\n\n`octo.RateLimit()` - returns the rate limit (or -1 if the header is missing)\n\nYou can also explicitly get your rate limit status with `ratelimit.Get()`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWillAbides%2Focto-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWillAbides%2Focto-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWillAbides%2Focto-go/lists"}