{"id":38421902,"url":"https://github.com/patch-technology/patch-python","last_synced_at":"2026-01-17T04:15:35.029Z","repository":{"id":38337361,"uuid":"331965427","full_name":"patch-technology/patch-python","owner":"patch-technology","description":"Patch's Python client library - https://www.patch.io","archived":false,"fork":false,"pushed_at":"2025-11-07T21:05:00.000Z","size":250,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-11-07T23:14:32.229Z","etag":null,"topics":["carbon","carbon-dioxide","carbon-emissions","carbon-footprint","carbon-offsets","carbon-offsetting","carbon-removal","python"],"latest_commit_sha":null,"homepage":"https://www.usepatch.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patch-technology.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-01-22T14:12:40.000Z","updated_at":"2025-11-07T21:04:24.000Z","dependencies_parsed_at":"2025-03-19T19:36:04.769Z","dependency_job_id":"b64220c5-7ded-40c4-822c-dcd0a2930a59","html_url":"https://github.com/patch-technology/patch-python","commit_stats":{"total_commits":75,"total_committers":12,"mean_commits":6.25,"dds":0.6,"last_synced_commit":"e8e799fdc159080d27d08b0b533250769d05819b"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/patch-technology/patch-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patch-technology%2Fpatch-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patch-technology%2Fpatch-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patch-technology%2Fpatch-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patch-technology%2Fpatch-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patch-technology","download_url":"https://codeload.github.com/patch-technology/patch-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patch-technology%2Fpatch-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28494597,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"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":["carbon","carbon-dioxide","carbon-emissions","carbon-footprint","carbon-offsets","carbon-offsetting","carbon-removal","python"],"created_at":"2026-01-17T04:15:34.407Z","updated_at":"2026-01-17T04:15:35.021Z","avatar_url":"https://github.com/patch-technology.png","language":"Python","readme":"# Patch Python SDK\n\n![Test](https://github.com/patch-technology/patch-python/workflows/Test/badge.svg)\n[![PyPI version](https://badge.fury.io/py/patch-api.svg)](https://badge.fury.io/py/patch-api)\n[![Discord](https://img.shields.io/discord/733029448558837792)](https://discord.gg/AU8543D)\n\nThe official Python library for the [Patch API](https://www.patch.io).\n\n## Documentation\n\nFor a complete API reference, check out [Patch's API Reference.](https://docs.patch.io/).\n\n## Installation\n\nAdd the library to your `requirements.txt` file:\n\n```txt\npatch_api \u003e= 1.5.0\n```\n\nThen run:\n\n```shell\npip install -r requirements.txt\n```\n\nOr install it directly with\n\n```shell\npip install patch-api\n```\n\n### Requirements\n\n- Python 3.6.1\n\n## Usage\n\n### Configuration\n\nAfter installing the gem, you'll have to initialize it with your API key which is available from the API key page in the Patch dashboard. The `patch` object will be used to to make calls to the Patch API:\n\n```python\nimport patch_api\n\npatch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))\norders = patch.orders.retrieve_orders()\n```\n\n### Orders\n\n[API Reference](https://docs.patch.io/#/orders)\n\n#### Examples\n\n```python\nimport patch_api\n\npatch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))\n\n# Create an order - you can create an order\n# providing either amount (and unit) or total_price (and currency), but not both\n\n# Create order with amount\namount = 1_000_000 # Pass in the amount in unit specified\nunit = \"g\"\npatch.orders.create_order(amount=amount, unit=unit)\n\n# Create an order with total price\ntotal_price = 5_00 # Pass in the total price in smallest currency unit (ie cents for USD).\ncurrency = \"USD\"\npatch.orders.create_order(total_price=total_price, currency=currency)\n\n## You can also specify a project-id field (optional) to be used instead of the preferred one\nproject_id = 'pro_test_1234' # Pass in the project's ID\npatch.orders.create_order(project_id=project_id, amount=amount, unit=unit)\n\n## Orders also accept a metadata field (optional)\nmetadata = {\"user\": \"john doe\"}\npatch.orders.create_order(metadata=metadata, amount=amount, unit=unit)\n\n## Orders also accept a metadata field (optional)\nmetadata = {\"user\": \"john doe\"}\npatch.orders.create_order(metadata=metadata, amount=amount, unit=unit)\n\n## Orders also accept an issued_to field (optional)\nissued_to = {\"name\": \"Company A\", \"email\": \"envimpact@companya.com\"}\npatch.orders.create_order(issued_to=issued_to, amount=amount, unit=unit)\n\n# Retrieve an order\norder_id = 'ord_test_1234' # Pass in the order's id\npatch.orders.retrieve_order(id=order_id)\n\n# Place an order\norder_id = 'ord_test_1234' # Pass in the order's id\npatch.orders.place_order(id=order_id)\n\n## Placing an order on behalf of another party\nissued_to = {\"name\": \"Company A\", \"email\": \"envimpact@companya.com\"}\npatch.orders.place_order(id=order_id, issued_to=issued_to)\n\n# Cancel an order\norder_id = 'ord_test_1234' # Pass in the order's id\npatch.orders.cancel_order(id=order_id)\n\n# Retrieve a list of orders\npage = 1 # Pass in which page of orders you'd like\npatch.orders.retrieve_orders(page=page)\n```\n\n\u003c\u003c\u003c\u003c\u003c\u003c\u003c HEAD\n=======\n### Estimates\n\nEstimates allow API users to get a quote for the cost of compensating a certain amount of CO2. When creating an estimate, an order in the `draft` state will also be created, reserving the allocation of a project for 5 minutes. If you don't place your draft order within those 5 minutes, the order will automatically be cancelled.\n\n[API Reference](https://docs.patch.io/#/estimates)\n\n#### Examples\n\n```python\nimport patch_api\n\npatch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))\n\n# Create an estimate\nmass_g = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)\npatch.estimates.create_mass_estimate(mass_g=mass_g)\n\n## You can also specify a project-id field (optional) to be used instead of the preferred one\nproject_id = 'pro_test_1234' # Pass in the project's ID\npatch.estimates.create_mass_estimate(mass_g=mass_g, project_id=project_id)\n\n# Create a bitcoin estimate\ntransaction_value_btc_sats = 1000 # [Optional] Pass in the transaction value in satoshis\npatch.estimates.create_bitcoin_estimate(transaction_value_btc_sats=transaction_value_btc_sats)\n\n# Retrieve an estimate\nestimate_id = 'est_test_1234'\npatch.estimates.retrieve_estimate(id=estimate_id)\n\n# Retrieve a list of estimates\npage = 1 # Pass in which page of estimates you'd like\npatch.estimates.retrieve_estimates(page=page)\n```\n\n\u003e\u003e\u003e\u003e\u003e\u003e\u003e origin/main\n### Projects\n\nProjects are the ways Patch takes CO2 out of the air. They can represent reforestation, enhanced weathering, direct air carbon capture, etc. When you place an order via Patch, it is allocated to a project.\n\nWhen fetching projects, you can supply filters to the query to narrow your result. Currently supported filters are:\n\n- `country`\n- `type`\n- `minimum_available_mass`\n\n[API Reference](https://docs.patch.io/#/projects)\n\n#### Examples\n\n```python\nimport patch_api\n\npatch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))\n\n# Retrieve a project\nproject_id = 'pro_test_1234' # Pass in the project's ID\npatch.projects.retrieve_project(id=project_id)\n\n# Retrieve a list of projects\npage = 1 # Pass in which page of projects you'd like\npatch.projects.retrieve_projects(page=page)\n\n# Retrieve a list of biomass projects\npatch.projects.retrieve_projects(type=\"biomass\")\n\n# Retrieve a list of projects from Canada\npatch.projects.retrieve_projects(country=\"CA\")\n\n# Retrieve a list of projects with at least 100 grams of available offsets\npatch.projects.retrieve_projects(minimum_available_mass=100)\n\n# Retrieve a project / all projects in a different language\n# See http://docs.patch.test:3000/#/internationalization for more information and support\npatch.projects.retrieve_projects(accept_language='fr')\nproject_id = 'pro_test_1234'\npatch.projects.retrieve_project(id=project_id, accept_language='fr')\n```\n\n## Contributing\n\nWhile we value open-source contributions to this SDK, the core of this library is generated programmatically. Complex additions made directly to the library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!\n\nOn the other hand, contributions to the README, as well as new test cases are always very welcome!\n\n### Pre-commit\n\nThis project uses pre-commit to automatically lint code on commit. Set-up lint commit the first time around using\n```\npre-commit install\n```\n\n### Linter\n\nThis project uses black for code formatting. To run the automatic formatting, run:\n\n```bash\nmake lint\n```\n\n### Running tests\n\nSet up the required environment variable:\n\n```bash\nexport SANDBOX_API_KEY=\u003cSANDBOX API KEY\u003e\n```\n\nRun tests:\n\n```bash\nmake test\n```\n\nTo run an individual test:\n\n```bash\npython -m unittest test/xxx_test.py\n```\n\n### Testing the built package locally\n\nTo build the library locally, run:\n\n```bash\nmake build\n```\n\nIn another directory, create a file called `patch.py` and install the local package in this directory:\n\n```bash\ntouch patch.py\npip install ../patch-python\n```\n\nSet up the required environment variable:\n\n```bash\nexport SANDBOX_API_KEY=\u003cSANDBOX API KEY\u003e\n```\n\nTo test the package locally, create a python file in a sibling directory and add the following:\n\n```python\nimport os\nimport patch_api\n\npatch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))\norders = patch.orders.retrieve_orders(page=1)\n\nprint(orders)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatch-technology%2Fpatch-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatch-technology%2Fpatch-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatch-technology%2Fpatch-python/lists"}