{"id":19703456,"url":"https://github.com/crowdin/crowdin-api-client-go","last_synced_at":"2025-04-29T14:30:44.261Z","repository":{"id":214647678,"uuid":"737024739","full_name":"crowdin/crowdin-api-client-go","owner":"crowdin","description":"Go client library for Crowdin API","archived":false,"fork":false,"pushed_at":"2025-03-24T10:32:43.000Z","size":442,"stargazers_count":7,"open_issues_count":1,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-20T13:07:58.877Z","etag":null,"topics":["api","api-client","go","golang","hacktoberfest","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/crowdin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2023-12-29T15:20:58.000Z","updated_at":"2025-03-24T10:42:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"6f82929f-1341-41e7-bac3-a76669e5b376","html_url":"https://github.com/crowdin/crowdin-api-client-go","commit_stats":null,"previous_names":["crowdin/crowdin-api-client-go"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdin%2Fcrowdin-api-client-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdin%2Fcrowdin-api-client-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdin%2Fcrowdin-api-client-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdin%2Fcrowdin-api-client-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crowdin","download_url":"https://codeload.github.com/crowdin/crowdin-api-client-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251518776,"owners_count":21602208,"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","api-client","go","golang","hacktoberfest","sdk"],"created_at":"2024-11-11T21:17:54.908Z","updated_at":"2025-04-29T14:30:44.245Z","avatar_url":"https://github.com/crowdin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://support.crowdin.com/assets/logos/symbol/png/crowdin-symbol-cWhite.png\"\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://support.crowdin.com/assets/logos/symbol/png/crowdin-symbol-cDark.png\"\u003e\n    \u003cimg width=\"150\" height=\"150\" src=\"https://support.crowdin.com/assets/logos/symbol/png/crowdin-symbol-cDark.png\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n# Crowdin Go client\n\nThe Crowdin Go client is a lightweight interface to the Crowdin API. It provides common services for making API requests.\n\nOur API is a full-featured RESTful API that helps you to integrate localization into your development process. The endpoints that we use allow you to easily make calls to retrieve information and to execute actions needed.\n\n\u003cdiv align=\"center\"\u003e\n\n[**`Developer portal`**](https://developer.crowdin.com/) \u0026nbsp;|\u0026nbsp;\n[**`Crowdin API`**](https://developer.crowdin.com/api/v2/) \u0026nbsp;|\u0026nbsp;\n[**`Crowdin Enterprise API`**](https://developer.crowdin.com/enterprise/api/v2/)\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/crowdin/crowdin-api-client-go/crowdin.svg)](https://pkg.go.dev/github.com/crowdin/crowdin-api-client-go/crowdin)\n[![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/crowdin/crowdin-api-client-go)](https://github.com/crowdin/crowdin-api-client-go/blob/main/go.mod)\n[![tests](https://github.com/crowdin/crowdin-api-client-go/actions/workflows/basic.yml/badge.svg)](https://github.com/crowdin/crowdin-api-client-go/actions/workflows/basic.yml)\n[![codecov](https://codecov.io/gh/crowdin/crowdin-api-client-go/graph/badge.svg?token=BC055K8EOG)](https://codecov.io/gh/crowdin/crowdin-api-client-go)\n[![GitHub contributors](https://img.shields.io/github/contributors/crowdin/crowdin-api-client-go?cacheSeconds=3600)](https://github.com/crowdin/crowdin-api-client-go/graphs/contributors)\n[![License](https://img.shields.io/github/license/crowdin/crowdin-api-client-go?cacheSeconds=3600)](https://github.com/crowdin/crowdin-api-client-go/blob/main/LICENSE)\n\n\u003c/div\u003e\n\n## Installation\n\n```bash\ngo get github.com/crowdin/crowdin-api-client-go\n```\n\n## Quick Start\n\nCreate a new Crowdin client, then use the exposed services to access different parts of the Crowdin API.  \nYou can generate Personal Access Token in your Crowdin Account Settings.\n\n```go\nimport \"github.com/crowdin/crowdin-api-client-go/crowdin\"\n\nclient, err := crowdin.NewClient(\n    os.Getenv(\"CROWDIN_ACCESS_TOKEN\"),\n    crowdin.WithOrganization(\"organization-name\"), // optional for Crowdin Enterprise\n)\n```\n\nFor example, to create a new project:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/crowdin/crowdin-api-client-go/crowdin\"\n\t\"github.com/crowdin/crowdin-api-client-go/crowdin/model\"\n)\n\nfunc main() {\n    client, err := crowdin.NewClient(os.Getenv(\"CROWDIN_ACCESS_TOKEN\"))\n    if err != nil {\n        log.Fatalf(\"Error creating client: %s\", err)\n    }\n\n    ctx := context.Background()\n    request := \u0026model.ProjectsAddRequest{\n        Name: \"My Project\",\n\t\tSourceLanguageID: \"en\",\n\t\tTargetLanguageIDs: []string{\"uk\", \"de\"},\n\n    }\n    project, _, err := client.Projects.Add(ctx, request)\n    if err != nil {\n        log.Fatalf(\"Error creating project: %s\", err)\n    }\n\n    fmt.Printf(\"Project: %+v\\n\", project)\n}\n\n```\n\nSome API methods have optional parameters that can be passed.  \nFor example, to list all projects for a specific user:\n\n```go\n\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/crowdin/crowdin-api-client-go/crowdin\"\n\t\"github.com/crowdin/crowdin-api-client-go/crowdin/model\"\n)\n\nfunc main() {\n    client, err := crowdin.NewClient(os.Getenv(\"CROWDIN_ACCESS_TOKEN\"))\n    if err != nil {\n        log.Fatalf(\"Error creating client: %s\", err)\n    }\n\n    // list all projects for a specific user\n    opts := \u0026model.ProjectsListOptions{UserID: 1}\n    projects, _, err := client.Projects.List(context.Background(), opts)\n    if err != nil {\n        log.Fatalf(\"Error getting projects: %s\", err)\n    }\n\n    fmt.Printf(\"Projects: %+v\\n\", projects)\n}\n```\n\n### Error Handling\n\nIn case of an error, the client returns an error object. This can either be a generic error with an error message and a code, or a validation error that additionally contains validation error codes.\n\nTo detect this condition of error, you can use a type assertion:\n\n```go\nres, _, err := client.SourceStrings.Add(ctx, 1, nil)\nif err != nil {\n    if validationErr, ok := err.(*model.ValidationErrorResponse); ok {\n        fmt.Printf(\"Validation error: %v\\n\", validationErr)\n    } else \n        fmt.Printf(\"Error: %v\\n\", err)\n    }\n}\n```\n\n### HTTP Request Timeout\n\nTo set a timeout for HTTP requests, you can pass a custom HTTP client with a timeout to the client.  \nYou can also use the context package, you can pass cancellation signals and deadlines to various services of the client to handle a request. \n\n```go\nclient, err := crowdin.NewClient(\n    os.Getenv(\"CROWDIN_ACCESS_TOKEN\"),\n    crowdin.WithHTTPClient(\u0026http.Client{Timeout: 10 * time.Second}),\n)\n```\n\n\n## GraphQL API\n\nThis library also provides possibility to use [GraphQL API](https://support.crowdin.com/developer/graphql-api/).\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/crowdin/crowdin-api-client-go/crowdin\"\n)\n\nfunc main() {\n\tclient, _ := crowdin.NewClient(token)\n\n\t// Create a new GraphQL query request.\n\tquery := client.GraphQL.NewRequest(`\n\t\tquery Demo( $projectLimit: Int!, $withTranslations: Boolean! ) {\n\t\t\tviewer {\n\t\t\t\tprojects( first: $projectLimit ) {\n\t\t\t\t\tedges {\n\t\t\t\t\t\tnode {\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t\tdescription\n\n\t\t\t\t\t\t\ttranslations(first: 20, languageId: \"en\") @include(if: $withTranslations) {\n\t\t\t\t\t\t\t\tedges {\n\t\t\t\t\t\t\t\t\tnode {\n\t\t\t\t\t\t\t\t\t\t... on PlainStringTranslation {\n\t\t\t\t\t\t\t\t\t\t\ttext\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttotalCount\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t`)\n\n\t// Set the variables to be used in the query.\n\tquery.Var(\"projectLimit\", 2)\n\tquery.Var(\"withTranslations\", true)\n\n\t// Capture the response in a map.\n\t// Can also be a struct with the same fields as the response.\n\tvar resp map[string]any\n\n\t// Send the query to the server.\n\tif err := client.GraphQL.Query(context.Background(), query, \u0026resp); err != nil {\n\t\tlog.Fatalf(\"graphql: %v\", err)\n\t}\n\n\tfmt.Printf(\"%+v\\n\", resp)\n}\n```\n\n## Seeking Assistance\n\nIf you find any problems or would like to suggest a feature, please read the [How can I contribute](/CONTRIBUTING.md#how-can-i-contribute) section in our contributing guidelines.\n\n## Contributing\n\nIf you want to contribute please read the [Contributing](/CONTRIBUTING.md) guidelines.\n\n## License\n\n\u003cpre\u003e\nThe Crowdin Go client is licensed under the MIT License.\nSee the LICENSE file distributed with this work for additional\ninformation regarding copyright ownership.\n\nExcept as contained in the LICENSE file, the name(s) of the above copyright\nholders shall not be used in advertising or otherwise to promote the sale,\nuse or other dealings in this Software without prior written authorization.\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrowdin%2Fcrowdin-api-client-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrowdin%2Fcrowdin-api-client-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrowdin%2Fcrowdin-api-client-go/lists"}