# datasette-remote-metadata
[![PyPI](https://img.shields.io/pypi/v/datasette-remote-metadata.svg)](https://pypi.org/project/datasette-remote-metadata/)
[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-remote-metadata?include_prereleases&label=changelog)](https://github.com/simonw/datasette-remote-metadata/releases)
[![Tests](https://github.com/simonw/datasette-remote-metadata/workflows/Test/badge.svg)](https://github.com/simonw/datasette-remote-metadata/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-remote-metadata/blob/main/LICENSE)
Periodically refresh Datasette metadata from a remote URL
## Installation
Install this plugin in the same environment as Datasette.
$ datasette install datasette-remote-metadata
## Usage
Add the following to your `metadata.json`:
```json
{
"plugins": {
"datasette-remote-metadata": {
"url": "https://example.com/remote-metadata.yml"
}
}
}
```
The plugin will fetch the specified metadata from that URL at startup and combine it with any existing metadata. You can use a URL to either a JSON file or a YAML file.
It will periodically refresh that metadata - by default every 30 seconds, unless you specify an alternative `"ttl"` value in the plugin configuration.
## Configuration
Available configuration options are as follows:
- `"url"` - the URL to retrieve remote metadata from. Can link to a JSON or a YAML file.
- `"ttl"` - integer value in secords: how frequently should the script check for fresh metadata. Defaults to 30 seconds.
- `"headers"` - a dictionary of additional request headers to send.
- `"cachebust"` - if true, a random `?0.29508` value will be added to the query string of the remote metadata to bust any intermediary caches.
This example `metadata.json` configuration refreshes every 10 seconds, uses cache busting and sends an `Authorization: Bearer xyz` header with the request:
```json
{
"plugins": {
"datasette-remote-metadata": {
"url": "https://example.com/remote-metadata.yml",
"ttl": 10,
"cachebust": true,
"headers": {
"Authorization": "Bearer xyz"
}
}
}
}
```
This example if you are using `metadata.yaml` for configuration:
```yaml
plugins:
datasette-remote-metadata:
url: https://example.com/remote-metadata.yml
ttl: 10
cachebust: true
headers:
Authorization: Bearer xyz
```
## Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-remote-metadata
python3 -mvenv venv
source venv/bin/activate
Or if you are using `pipenv`:
pipenv shell
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Raw data
{
"_id": null,
"home_page": "https://github.com/simonw/datasette-remote-metadata",
"name": "datasette-remote-metadata",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "Simon Willison",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/eb/9c/4f9fb6d35732958af98566cdfbdf3b965e820b47e03d3bc88432faf310da/datasette-remote-metadata-0.1.tar.gz",
"platform": "",
"description": "# datasette-remote-metadata\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-remote-metadata.svg)](https://pypi.org/project/datasette-remote-metadata/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-remote-metadata?include_prereleases&label=changelog)](https://github.com/simonw/datasette-remote-metadata/releases)\n[![Tests](https://github.com/simonw/datasette-remote-metadata/workflows/Test/badge.svg)](https://github.com/simonw/datasette-remote-metadata/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-remote-metadata/blob/main/LICENSE)\n\nPeriodically refresh Datasette metadata from a remote URL\n\n## Installation\n\nInstall this plugin in the same environment as Datasette.\n\n $ datasette install datasette-remote-metadata\n\n## Usage\n\nAdd the following to your `metadata.json`:\n\n```json\n{\n \"plugins\": {\n \"datasette-remote-metadata\": {\n \"url\": \"https://example.com/remote-metadata.yml\"\n }\n }\n}\n```\nThe plugin will fetch the specified metadata from that URL at startup and combine it with any existing metadata. You can use a URL to either a JSON file or a YAML file.\n\nIt will periodically refresh that metadata - by default every 30 seconds, unless you specify an alternative `\"ttl\"` value in the plugin configuration.\n\n## Configuration\n\nAvailable configuration options are as follows:\n\n- `\"url\"` - the URL to retrieve remote metadata from. Can link to a JSON or a YAML file.\n- `\"ttl\"` - integer value in secords: how frequently should the script check for fresh metadata. Defaults to 30 seconds.\n- `\"headers\"` - a dictionary of additional request headers to send.\n- `\"cachebust\"` - if true, a random `?0.29508` value will be added to the query string of the remote metadata to bust any intermediary caches.\n\nThis example `metadata.json` configuration refreshes every 10 seconds, uses cache busting and sends an `Authorization: Bearer xyz` header with the request:\n\n```json\n{\n \"plugins\": {\n \"datasette-remote-metadata\": {\n \"url\": \"https://example.com/remote-metadata.yml\",\n \"ttl\": 10,\n \"cachebust\": true,\n \"headers\": {\n \"Authorization\": \"Bearer xyz\"\n }\n }\n }\n}\n```\nThis example if you are using `metadata.yaml` for configuration:\n```yaml\nplugins:\n datasette-remote-metadata:\n url: https://example.com/remote-metadata.yml\n ttl: 10\n cachebust: true\n headers:\n Authorization: Bearer xyz\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-remote-metadata\n python3 -mvenv venv\n source venv/bin/activate\n\nOr if you are using `pipenv`:\n\n pipenv shell\n\nNow install the dependencies and test dependencies:\n\n pip install -e '.[test]'\n\nTo run the tests:\n\n pytest\n\n\n",
"bugtrack_url": null,
"license": "Apache License, Version 2.0",
"summary": "Periodically refresh Datasette metadata from a remote URL",
"version": "0.1",
"project_urls": {
"CI": "https://github.com/simonw/datasette-remote-metadata/actions",
"Changelog": "https://github.com/simonw/datasette-remote-metadata/releases",
"Homepage": "https://github.com/simonw/datasette-remote-metadata",
"Issues": "https://github.com/simonw/datasette-remote-metadata/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4bea9a92446ead3ec6baf8921515533a6067f31bc41ff525935eda6e4c81454d",
"md5": "0e612bb74441432aae59511b88c86234",
"sha256": "e1c41cf3b836ae44105d8f86ad989f672209603b20f76c2dcaca92082a6eff4a"
},
"downloads": -1,
"filename": "datasette_remote_metadata-0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0e612bb74441432aae59511b88c86234",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 3729,
"upload_time": "2021-07-29T01:44:08",
"upload_time_iso_8601": "2021-07-29T01:44:08.836434Z",
"url": "https://files.pythonhosted.org/packages/4b/ea/9a92446ead3ec6baf8921515533a6067f31bc41ff525935eda6e4c81454d/datasette_remote_metadata-0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "eb9c4f9fb6d35732958af98566cdfbdf3b965e820b47e03d3bc88432faf310da",
"md5": "4e4107ede97b01fb6828ddc8fa618641",
"sha256": "eaa2a2205eb700cfcfbb342813d1a454208e221324b5cee09cb686b03314a046"
},
"downloads": -1,
"filename": "datasette-remote-metadata-0.1.tar.gz",
"has_sig": false,
"md5_digest": "4e4107ede97b01fb6828ddc8fa618641",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3617,
"upload_time": "2021-07-29T01:44:10",
"upload_time_iso_8601": "2021-07-29T01:44:10.238239Z",
"url": "https://files.pythonhosted.org/packages/eb/9c/4f9fb6d35732958af98566cdfbdf3b965e820b47e03d3bc88432faf310da/datasette-remote-metadata-0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-07-29 01:44:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "simonw",
"github_project": "datasette-remote-metadata",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "datasette-remote-metadata"
}