{"id":15722185,"url":"https://github.com/mfa/datasette-webhook-write","last_synced_at":"2025-05-13T04:36:31.742Z","repository":{"id":62566794,"uuid":"390469876","full_name":"mfa/datasette-webhook-write","owner":"mfa","description":"Datasette plugin to write to database via verified webhooks","archived":false,"fork":false,"pushed_at":"2025-03-18T12:24:00.000Z","size":48,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-02T06:49:51.505Z","etag":null,"topics":["datasette","datasette-plugin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mfa.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}},"created_at":"2021-07-28T18:58:40.000Z","updated_at":"2025-03-18T12:24:04.000Z","dependencies_parsed_at":"2024-08-06T18:58:38.269Z","dependency_job_id":"a8450350-a4a2-4813-a6a5-9fcb15f915e2","html_url":"https://github.com/mfa/datasette-webhook-write","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":"0.052631578947368474","last_synced_commit":"c6df23ede2ed90ef6bc0263a2507a33a6b9a1247"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfa%2Fdatasette-webhook-write","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfa%2Fdatasette-webhook-write/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfa%2Fdatasette-webhook-write/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfa%2Fdatasette-webhook-write/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfa","download_url":"https://codeload.github.com/mfa/datasette-webhook-write/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253877362,"owners_count":21977634,"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":["datasette","datasette-plugin"],"created_at":"2024-10-03T22:05:02.844Z","updated_at":"2025-05-13T04:36:31.731Z","avatar_url":"https://github.com/mfa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datasette-webhook-write\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-webhook-write.svg)](https://pypi.org/project/datasette-webhook-write/)\n[![Changelog](https://img.shields.io/github/v/release/mfa/datasette-webhook-write?include_prereleases\u0026label=changelog)](https://github.com/mfa/datasette-webhook-write/releases)\n[![Tests](https://github.com/mfa/datasette-webhook-write/workflows/Test/badge.svg)](https://github.com/mfa/datasette-webhook-write/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/mfa/datasette-webhook-write/blob/main/LICENSE)\n\nDatasette plugin to write to database via verified webhooks\n\n## Installation\n\nInstall this plugin in the same environment as Datasette.\n\n    $ datasette install datasette-webhook-write\n\n\n## Usage (datasette/receiving side)\n\nThis plugin allows writing to a datasette database via hmac-signed http POST calls.\n\nExample for metadata.yml (for usage to receive texts from https://nlg.ax/):\n\n```yaml\nplugins:\n  datasette-webhook-write:\n    webhook_secret:\n      \"$env\": \"WEBHOOK_SECRET\"\n    http_header_name: \"x-myax-signature\"\n    database_name: \"example\"\n    table_name: \"generated_texts\"\n    use_pk:\n      - \"uid\"\n      - \"collection_id\"\n```\n\n`WEBHOOK_SECRET` is set as environment variable.\n\nThe url to upload to the datasette instance is ``/-/webhook-write/``.\n\n\n## Usage (pushing side)\n\nThe json data pushed has to be signed with the `WEBHOOK_SECRET` and added to the headers of the POST call.\n\nGenerate the hmac signature (where `document` is the data you want to send, and `WEBHOOK_SECRET` is the secret only pushing+receving parties should know):\n\n```python\ndigest = hmac.new(\n    key=WEBHOOK_SECRET.encode(),\n    msg=json.dumps(document).encode(),\n    digestmod=hashlib.sha1,\n)\n\nheader = {\n    \"X-SIGNATURE\": f\"sha1={digest.hexdigest()}\",\n}\n```\n\nThe pushed data is written to the database only when secret+document are generating the same digest.\n\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n\n    cd datasette-webhook-write\n    python -m venv venv\n    source venv/bin/activate\n\nNow install the dependencies and test dependencies:\n\n    python -m pip install -e '.[test]'\n\nTo run the tests:\n\n    python -m pytest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfa%2Fdatasette-webhook-write","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfa%2Fdatasette-webhook-write","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfa%2Fdatasette-webhook-write/lists"}