Datasette plugin for fetching details of actors from a remote endpoint
Project description
datasette-remote-actors
A Datasette plugin for fetching details of actors (users or API clients) from a remote, centralized JSON endpoint.
See Datasette issue #2180 for background on this plugin.
Installation
datasette install datasette-remote-actors
API Endpoint Requirements
Configure this plugin with a URL pointing to an API endpoint that provides actor information.
This endpoint must:
- Accept a GET request.
- Accept a query string parameter
idscontaining a comma-separated list of actor IDs (e.g.,?ids=1,a2,b3). - Return a JSON response with a
200 OKstatus code upon success. - The JSON response body must be a dictionary where the keys are the string representations of the actor IDs requested, and the values are dictionaries containing the details for each actor.
Example Request:
GET /path/to/your/endpoint?ids=1,2
Example Successful JSON Response:
{
"1": {
"id": "1",
"name": "Cleopatra",
"email": "cleo@example.com"
},
"2": {
"id": 2,
"name": "Julius Caesar",
"username": "jcaesar"
}
}
Important Notes:
- The keys in the returned JSON object (
"1","2"in the example) must be strings, even if the original IDs are integers. - Each actor dictionary value must contain an
idfield, which can be a string or an integer matching the requested ID. Other fields (likename,username,email) are flexible and defined by your endpoint. - Small Actor Sets: If you have a small, fixed number of actors, your endpoint can optionally ignore the
?ids=parameter and always return the entire dictionary of all known actors. The plugin will cache these and use the cached data for subsequent lookups (ifttlis configured). - Error Handling: If the remote endpoint returns a non-200 status code, times out, or returns invalid JSON, this plugin will log an error (if Datasette logging is configured) and will not return actor data for the requested IDs for that request.
Configuration
You configure the plugin using Datasette's metadata.json or metadata.yaml file.
Minimal Configuration:
plugins:
datasette-remote-actors:
url: https://example.com/actors.json
Full Configuration Example:
plugins:
datasette-remote-actors:
# (Required) URL to the remote actor endpoint
url: https://example.com/actors.json
# (Optional) Cache Time-To-Live in seconds.
# If set, actor details will be cached in memory.
# Uses cachetools.TTLCache with a default maxsize of 1000.
# Omit for no caching.
ttl: 60
# (Optional) Bearer token for authentication.
# If set, adds an "Authorization: Bearer <token>" header to the request.
token: your-secret-api-token
# (Optional) Enable integration with datasette-profiles.
# Requires datasette-profiles plugin to be installed.
# See section below for details.
datasette-profiles: true
Configuration Options:
url(string, required): The URL to the endpoint that can resolve actor IDs into JSON actor dictionaries.ttl(integer, optional): The number of seconds to cache the result for a specific actor ID. Uses an in-memoryTTLCache(defaultmaxsize=1000). Omit this or set to0for no caching.token(string, optional): An authentication token. If provided, it will be sent in theAuthorization: Bearer <token>HTTP header when calling theurl.datasette-profiles(boolean, optional): Set totrueto enable integration with the datasette-profiles plugin. Defaults tofalse.
Integration with datasette-profiles
If you want to allow users to override or supplement the actor details fetched from the remote endpoint with their own profile information stored within Datasette, you can use the datasette-profiles plugin.
- Install the companion plugin:
datasette install datasette-profiles
- Enable the integration in the
datasette-remote-actorsconfiguration:plugins: datasette-remote-actors: url: https://example.com/actors.json datasette-profiles: true # other options...
When enabled:
- The plugin will first fetch actor details from the configured
url. - It will then query the
profilestable (created bydatasette-profiles) in Datasette's internal database for matching actor IDs. - If a profile exists for an actor ID, the data from the
profilestable will be merged into the actor dictionary fetched from the remote URL. Any non-null values in theprofilestable (except theidcolumn itself) will overwrite corresponding keys from the remote data.
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-remote-actors
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datasette_remote_actors-0.1a7.tar.gz.
File metadata
- Download URL: datasette_remote_actors-0.1a7.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb3d1958b22078a9e5cb89620b9c52b7b034706c2ca41ec74a713b77951782bc
|
|
| MD5 |
defa6df801198957ae482bb8813c317c
|
|
| BLAKE2b-256 |
a1a77dbe3f5122187365dddc1965b44968407a5eb87be7b9fdf887e7bd438342
|
Provenance
The following attestation bundles were made for datasette_remote_actors-0.1a7.tar.gz:
Publisher:
publish.yml on datasette/datasette-remote-actors
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_remote_actors-0.1a7.tar.gz -
Subject digest:
fb3d1958b22078a9e5cb89620b9c52b7b034706c2ca41ec74a713b77951782bc - Sigstore transparency entry: 684152587
- Sigstore integration time:
-
Permalink:
datasette/datasette-remote-actors@820453aaa5ebdc17ae4beeeafe43bd7f6088b959 -
Branch / Tag:
refs/tags/0.1a7 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@820453aaa5ebdc17ae4beeeafe43bd7f6088b959 -
Trigger Event:
release
-
Statement type:
File details
Details for the file datasette_remote_actors-0.1a7-py3-none-any.whl.
File metadata
- Download URL: datasette_remote_actors-0.1a7-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d489dfc75ba7c9bba83f84878c03992a5ee1c6dd00c1ec4dff520a7974da9f4b
|
|
| MD5 |
2905c9b2999a035683722896bc919913
|
|
| BLAKE2b-256 |
3b033d5de00cd7053de2c59f5220be68dccf5260d89c690cc80d0c45533a8815
|
Provenance
The following attestation bundles were made for datasette_remote_actors-0.1a7-py3-none-any.whl:
Publisher:
publish.yml on datasette/datasette-remote-actors
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_remote_actors-0.1a7-py3-none-any.whl -
Subject digest:
d489dfc75ba7c9bba83f84878c03992a5ee1c6dd00c1ec4dff520a7974da9f4b - Sigstore transparency entry: 684152591
- Sigstore integration time:
-
Permalink:
datasette/datasette-remote-actors@820453aaa5ebdc17ae4beeeafe43bd7f6088b959 -
Branch / Tag:
refs/tags/0.1a7 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@820453aaa5ebdc17ae4beeeafe43bd7f6088b959 -
Trigger Event:
release
-
Statement type: