APIs for importing locations
9th March 2021
Originally posted to my internal blog at VaccinateCA
An important aspect of the new backend is the ability to import new locations.
These can come from a bunch of different sources. I’ve previously written Django management command scripts for this, but these are fiddly to run from a permissions perspective and don’t necessarily play well with Cloud Run.
So I decided to build an /api/importLocations
API. This can take a single or multiple locations, and can either create new locations or update existing locations based on a provided unique import reference (import_ref
) value.
The API is documented in full here: https://github.com/CAVaccineInventory/django.vaccinate/blob/f78afbd1e5bbba4ddc4722c9a592dfd004cb143e/docs/api.md#post-apiimportlocations
You can see how it developed in issue 98
API keys
As part of building this API I needed a simple authentication mechanism. I’ve added a Django admin page for creating API keys, with a required description field. This can be used to create an API key for use with the new API.
This mechanism differs from the JWT tokens used by the caller app API, mainly because API tokens used for import scripts need to not expire—and also don’t need to be tied to specific users.
A few more APIs
Some of the fields that can be passed to the import location API need to accept values from a specific list: county
, location_type
and provider_type
all have this requirement.
I added APIs that return valid values for these:
More recent articles
- Weeknotes: more datasette-secrets, plus a mystery video project - 7th May 2024
- Weeknotes: Llama 3, AI for Data Journalism, llm-evals and datasette-secrets - 23rd April 2024
- Options for accessing Llama 3 from the terminal using LLM - 22nd April 2024
- AI for Data Journalism: demonstrating what we can do with this stuff right now - 17th April 2024
- Three major LLM releases in 24 hours (plus weeknotes) - 10th April 2024
- Building files-to-prompt entirely using Claude 3 Opus - 8th April 2024
- Running OCR against PDFs and images directly in your browser - 30th March 2024
- llm cmd undo last git commit - a new plugin for LLM - 26th March 2024
- Building and testing C extensions for SQLite with ChatGPT Code Interpreter - 23rd March 2024
- Claude and ChatGPT for ad-hoc sidequests - 22nd March 2024