{"id":20494840,"url":"https://github.com/gitguardian/py-gitguardian","last_synced_at":"2025-05-16T08:03:51.188Z","repository":{"id":39365295,"uuid":"256156191","full_name":"GitGuardian/py-gitguardian","owner":"GitGuardian","description":"Python API client library for the GitGuardian API","archived":false,"fork":false,"pushed_at":"2025-05-07T12:27:17.000Z","size":540,"stargazers_count":79,"open_issues_count":0,"forks_count":16,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-16T08:03:46.404Z","etag":null,"topics":["api-client","ci","devsecops","gitguardian","library","python","secrets-detection","security-tools","shift-left"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/GitGuardian.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-16T08:34:10.000Z","updated_at":"2025-05-07T12:27:21.000Z","dependencies_parsed_at":"2024-01-08T14:28:51.110Z","dependency_job_id":"137bfb10-5e1a-4d09-9f22-11875b9abee9","html_url":"https://github.com/GitGuardian/py-gitguardian","commit_stats":{"total_commits":97,"total_committers":13,"mean_commits":7.461538461538462,"dds":0.5979381443298969,"last_synced_commit":"183784df9a4cc6770bab4c7e04dedb20f0eb0d13"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GitGuardian%2Fpy-gitguardian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GitGuardian%2Fpy-gitguardian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GitGuardian%2Fpy-gitguardian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GitGuardian%2Fpy-gitguardian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GitGuardian","download_url":"https://codeload.github.com/GitGuardian/py-gitguardian/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493380,"owners_count":22080126,"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","ci","devsecops","gitguardian","library","python","secrets-detection","security-tools","shift-left"],"created_at":"2024-11-15T17:43:23.164Z","updated_at":"2025-05-16T08:03:51.142Z","avatar_url":"https://github.com/GitGuardian.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://gitguardian.com/\"\u003e\u003cimg src=\"https://cdn.jsdelivr.net/gh/gitguardian/py-gitguardian/doc/logo.svg\"\u003e\u003c/a\u003e\n\n# [py-gitguardian](https://github.com/GitGuardian/py-gitguardian) - GitGuardian API Client\n\n[![PyPI](https://img.shields.io/pypi/v/pygitguardian?color=%231B2D55\u0026style=for-the-badge)](https://pypi.org/project/pygitguardian/)\n[![License](https://img.shields.io/github/license/GitGuardian/py-gitguardian?color=%231B2D55\u0026style=for-the-badge)](LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/gitguardian/py-gitguardian?color=%231B2D55\u0026style=for-the-badge)](https://github.com/GitGuardian/py-gitguardian/stargazers)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/GitGuardian/py-gitguardian/test-lint.yml?branch=master\u0026style=for-the-badge)\n[![Codecov](https://img.shields.io/codecov/c/github/GitGuardian/py-gitguardian?style=for-the-badge)](https://codecov.io/gh/GitGuardian/py-gitguardian/)\n\nAPI client library for the [GitGuardian API](https://api.gitguardian.com/).\n\nThe GitGuardian API puts at your fingertips the power to detect more than 200 types of secrets in any text content, as well as other potential security vulnerabilities.\n\n**py-gitguardian** can be used to create integrations to scan various data sources, from your workstation's filesystem to your favorite chat application.\n\nYou can check API details [here](https://api.gitguardian.com/docs)\nwith all the response codes and expected structures on each method.\n\n## Requirements\n\nPython 3.8+\n\n## Projects using `py-gitguardian`\n\n- [**GitGuardian Shield**](https://github.com/GitGuardian/gg-shield) - Scan for secrets in your CI and pre-commit.\n\n## Getting started\n\nYou can obtain API keys for API usage on your [dashboard](https://dashboard.gitguardian.com/api/v1/auth/user/github_login/authorize?utm_source=github\u0026utm_medium=py_gitguardian\u0026utm_campaign=py1).\n\n**pip**\n\n```bash\npip3 install --upgrade pygitguardian\n```\n\n**pipenv**\n\n```bash\npipenv install pygitguardian\n```\n\n**pdm**\n\n```bash\npdm add pygitguardian\n```\n\n**poetry**\n\n```bash\npoetry add pygitguardian\n```\n\n## Examples\n\nCheck [examples/](examples/) for full examples on how to use py-gitguardian.\n\n### Scanning text content\n\n```py\n# please don't hardcode your gg_api_key in source code :)\nAPI_KEY = os.getenv(\"GITGUARDIAN_API_KEY\")\nDOCUMENT = \"\"\"\n    import urllib.request\n    url = 'http://jen_barber:correcthorsebatterystaple@cake.gitguardian.com/isreal.json'\n    response = urllib.request.urlopen(url)\n    consume(response.read())\"\n\"\"\"\n\nclient = GGClient(api_key=API_KEY)\n\n# Check the health of the API and the API key used.\nif client.health_check().success:\n    try:\n        scan_result = client.content_scan(DOCUMENT)\n    except Exception as exc:\n        # Handle exceptions such as schema validation\n        traceback.print_exc(2, file=sys.stderr)\n        print(str(exc))\n        print(scan_result)\nelse:\n    print(\"Invalid API Key\")\n```\n\n### Scanning multiple files\n\n```py\nAPI_KEY = os.getenv(\"GITGUARDIAN_API_KEY\")\nclient = GGClient(api_key=API_KEY)\n\n# Create a list of dictionaries for scanning\nfile_paths = (pathlib.Path(name) for name in glob.iglob(\"**/*\", recursive=True))\nto_scan = [\n    {\"filename\": path.name, \"document\": path.read_text(errors=\"replace\")}\n    for path in file_paths\n]\n\nscan = client.multi_content_scan(to_scan)\n```\n\n### Transform results to dict or JSON\n\nAny model in `py-gitguardian` can be turned to a JSON string or a dictionary using\nthe `to_dict` and `to_json` methods.\n\n```py\nfrom pygitguardian.models import Detail\n\ndetail = Detail(\"Invalid API Key.\")\nprint(detail.to_dict())\nprint(detail.to_json())\n```\n\n### Dependencies\n\nPy-gitguardian depends on these excellent libraries:\n\n- `requests` - HTTP client\n- `marshmallow` - Request (de)serialization and input validation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitguardian%2Fpy-gitguardian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitguardian%2Fpy-gitguardian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitguardian%2Fpy-gitguardian/lists"}