Overview
This is the Archivematica API section of “Trying the Archivematica API.” (There is also a separate “Storage Service API” section.)
This time, I will try the following “Transfer” API.
Usage
You can try it with the following notebook.
https://colab.research.google.com/github/nakamura196/ndl_ocr/blob/main/ArchivematicaのAPIを使ってみる.ipynb
The following configuration was required. The location UUID was confirmed from the storage service.
## Server settings
endpoint = "http://<domain>:81/api"
username = "<username>"
api_key = "<API key>"
location_uuid = "<location UUID>"
## Transfer settings
name = "mc_api_transfer"
type = "standard"
accession = "2023-1234"
paths = ["files/movie_test"]
row_ids = [""]
## Encode to base64
import base64
paths_encoded = []
for path in paths:
path_encoded = base64.b64encode(f"{location_uuid}:{path}".encode()).decode()
paths_encoded.append(path_encoded)
## POST
import requests
data = {
"name": name,
"type": type,
"accession": accession,
"paths[]": paths_encoded,
"row_ids[]": row_ids
}
headers = {'Authorization': f'ApiKey {username}:{api_key}'}
response = requests.post(f'{endpoint}/transfer/start_transfer/', headers=headers, data=data)
Summary
This time I only tried Start Transfer, but APIs are provided for various operations, enabling a wide range of system integrations.