Difference between revisions of "Archivematica API"
(Fix task property name) |
|||
(25 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
[[Main Page]] > [[Development]] > Archivematica API | [[Main Page]] > [[Development]] > Archivematica API | ||
+ | |||
+ | <div style="padding: 10px 10px; border: 1px solid black; background-color: #F79086;">This page is no longer being maintained and may contain inaccurate information. Please see the [https://www.archivematica.org/en/docs/archivematica-1.13/dev-manual/ Archivematica documentation] for up-to-date information.</div> | ||
Endpoints require authentication with a username and API key. This can be submitted as GET parameters (eg <code>?username=demo&api_key=e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2</code>) or as a header (eg <code>Authorization: ApiKey demo:e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2</code>). | Endpoints require authentication with a username and API key. This can be submitted as GET parameters (eg <code>?username=demo&api_key=e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2</code>) or as a header (eg <code>Authorization: ApiKey demo:e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2</code>). | ||
+ | <br \><br \> | ||
+ | ''As GET parameters, format is:''<br \> | ||
+ | <code>?username=<''username''>&api_key=<''api_key''></code><br \> | ||
− | '' | + | ''As a header, format is:''<br \> |
− | + | <code>ApiKey <username>:<api_key></code><br \> | |
− | |||
− | |||
+ | '''NOTE:''' The 'ApiKey' prefix is a requirement of the Tastypie library in use. See the Tastypie docs for [https://django-tastypie.readthedocs.io/en/latest/authentication.html#apikeyauthentication ApiKeyAuthentication].''<br \><br \> | ||
Endpoints return JSON. If there's an error, they will return a 4xx or 5xx HTTP error code and a JSON body <code>{'error': True, 'message': 'message describing error'}</code> | Endpoints return JSON. If there's an error, they will return a 4xx or 5xx HTTP error code and a JSON body <code>{'error': True, 'message': 'message describing error'}</code> | ||
Line 50: | Line 54: | ||
=== Status === | === Status === | ||
− | * '''URL''': <code>/transfer/status/<transfer UUID>/</code> | + | * '''URL''': <code>/api/transfer/status/<transfer UUID>/</code> |
* '''Verb''': GET | * '''Verb''': GET | ||
* Returns the status of the transfer. | * Returns the status of the transfer. | ||
Line 167: | Line 171: | ||
* '''URL''': <code>/api/administration/dips/atom/levels/</code> | * '''URL''': <code>/api/administration/dips/atom/levels/</code> | ||
* '''Verb''': GET? | * '''Verb''': GET? | ||
− | * | + | * Return a JSON-encoded set of the configured levels of description. |
* ''Response'': JSON. List of AtoM Levels of description with key 'UUID' and value 'name of level of description'. | * ''Response'': JSON. List of AtoM Levels of description with key 'UUID' and value 'name of level of description'. | ||
Line 175: | Line 179: | ||
* Fetch all levels of description from an AtoM database, replacing any previously existing. | * Fetch all levels of description from an AtoM database, replacing any previously existing. | ||
* '''Response''': JSON. Updated list of AtoM Levels of description with key 'UUID' and value 'name of level of description'. | * '''Response''': JSON. Updated list of AtoM Levels of description with key 'UUID' and value 'name of level of description'. | ||
+ | |||
+ | == Unit == | ||
+ | |||
+ | ''Note: Currently, you can only query strings in English.'' | ||
+ | |||
+ | === List jobs === | ||
+ | * '''URL''': <code>/api/v2beta/jobs/<unit UUID>/</code> | ||
+ | * '''Verb''': GET | ||
+ | * Return a list of jobs for the passed unit (transfer or ingest). | ||
+ | * '''Parameters''': | ||
+ | * '''Optional filters''': | ||
+ | *** <code>microservice</code>: Name of the microservice the jobs belong to | ||
+ | *** <code>link_uuid</code>: UUID of the job chain link | ||
+ | *** <code>name</code>: Name of the job | ||
+ | * '''Response''': JSON body | ||
+ | ** '''List of dicts with keys''': | ||
+ | *** <code>uuid</code>: UUID of the job | ||
+ | *** <code>name</code>: Name of the job | ||
+ | *** <code>status</code>: One of USER_INPUT, PROCESSING, COMPLETE, FAILED or UNKNOWN | ||
+ | *** <code>microservice</code>: Microservice the job belongs to | ||
+ | *** <code>link_uuid</code>: UUID of the job chain link | ||
+ | *** <code>tasks</code>: List of dicts with information about the microservice's tasks: | ||
+ | *** <code>uuid</code>: UUID of the task | ||
+ | *** <code>exit_code</code>: Exit code of the task | ||
+ | |||
+ | === Task === | ||
+ | * '''URL''': <code>/api/v2beta/task/<task UUID>/</code> | ||
+ | * '''Verb''': GET | ||
+ | * Return information about a task. | ||
+ | * '''Response''': JSON body | ||
+ | ** <code>uuid</code>: UUID of the task | ||
+ | ** <code>exit_code</code>: Exit code of the task | ||
+ | ** <code>file_uuid</code>: UUID of the file used for the task | ||
+ | ** <code>file_name</code>: File used for the task, | ||
+ | ** <code>time_created</code>: String (YYYY-MM-DD HH:MM:SS) representing when the task was created | ||
+ | ** <code>time_started</code>: String (YYYY-MM-DD HH:MM:SS) representing when the task started | ||
+ | ** <code>time_ended</code>: String (YYYY-MM-DD HH:MM:SS) representing when the task finished | ||
+ | ** <code>duration</code>: Task duration in seconds (integer). If the duration is less than a second, this will be a < 1 string | ||
== Other == | == Other == | ||
Line 217: | Line 259: | ||
*** <code>access_system_id</code>: Access system ID (see [https://www.archivematica.org/en/docs/latest/user-manual/access/access docs]) | *** <code>access_system_id</code>: Access system ID (see [https://www.archivematica.org/en/docs/latest/user-manual/access/access docs]) | ||
*** <code>metadata_set_id</code>: Used to link to metadata sets added via the user interface. It's safe to ignore this for now since metadata can't be associated to transfer via the API at the moment. | *** <code>metadata_set_id</code>: Used to link to metadata sets added via the user interface. It's safe to ignore this for now since metadata can't be associated to transfer via the API at the moment. | ||
− | *** <code>auto_approve</code>: Boolean <code> | + | *** <code>auto_approve</code>: Boolean <code>true</code> or <code>false</code> to set the transfer to auto-approve, default: <code>true</code> |
* '''Response''': JSON | * '''Response''': JSON | ||
** <code>id</code>: Transfer UUID ('''Note:''' as the package endpoint allows the caller to interact with Archivematica asynchronously it doesn't guarantee a transfer has started. The caller must use the UUID in the response to verify it has begun or any errors that were encountered initiating one.) | ** <code>id</code>: Transfer UUID ('''Note:''' as the package endpoint allows the caller to interact with Archivematica asynchronously it doesn't guarantee a transfer has started. The caller must use the UUID in the response to verify it has begun or any errors that were encountered initiating one.) | ||
Line 231: | Line 273: | ||
-H "Content-Type: application/json" \ | -H "Content-Type: application/json" \ | ||
-d "{\ | -d "{\ | ||
− | \"path\": \"$(echo -n '/home/archivematica/archivematica-sampledata/SampleTransfers/ | + | \"path\": \"$(echo -n '/home/archivematica/archivematica-sampledata/SampleTransfers/DemoTransferCSV' | base64 -w 0)\", \ |
\"name\": \"demo_transfer_absolute\", \ | \"name\": \"demo_transfer_absolute\", \ | ||
\"processing_config\": \"automated\", \ | \"processing_config\": \"automated\", \ | ||
Line 245: | Line 287: | ||
-H "Content-Type: application/json" \ | -H "Content-Type: application/json" \ | ||
-d "{\ | -d "{\ | ||
− | \"path\": \"$(echo -n 'd1184f7f-d755-4c8d-831a-a3793b88f760:/archivematica/archivematica-sampledata/SampleTransfers/ | + | \"path\": \"$(echo -n 'd1184f7f-d755-4c8d-831a-a3793b88f760:/archivematica/archivematica-sampledata/SampleTransfers/DemoTransferCSV' | base64 -w 0)\", \ |
\"name\": \"demo_transfer_relative\", \ | \"name\": \"demo_transfer_relative\", \ | ||
\"processing_config\": \"automated\", \ | \"processing_config\": \"automated\", \ | ||
Line 252: | Line 294: | ||
"http://<archivematica-uri>/api/v2beta/package" | "http://<archivematica-uri>/api/v2beta/package" | ||
</pre> | </pre> | ||
− | |||
=== Validate === | === Validate === |
Latest revision as of 10:45, 11 December 2023
Main Page > Development > Archivematica API
Endpoints require authentication with a username and API key. This can be submitted as GET parameters (eg ?username=demo&api_key=e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2
) or as a header (eg Authorization: ApiKey demo:e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2
).
As GET parameters, format is:
?username=<username>&api_key=<api_key>
As a header, format is:
ApiKey <username>:<api_key>
NOTE: The 'ApiKey' prefix is a requirement of the Tastypie library in use. See the Tastypie docs for ApiKeyAuthentication.
Endpoints return JSON. If there's an error, they will return a 4xx or 5xx HTTP error code and a JSON body {'error': True, 'message': 'message describing error'}
Transfer[edit]
Start Transfer[edit]
- URL:
/api/transfer/start_transfer/
- Verb: POST
- Start a transfer.
- Parameters: JSON body
name
: Name of new transfertype
: Type of the new transfer. One of: standard, unzipped bag, zipped bag, dspaceaccession
: Accession number of new transferpaths[]
: List of base64-encoded "<location_uuid>:<relative_path>" to be copied into the new transfer. Location UUIDs should be associated with this pipeline, and relative path should be relative to the location (TODO confirm relative vs absolute path). E.g. NWJiYWJjMTMtMTIyNy00MWE3LWIwY2QtZjJhYzM1MjkxZTdmOi92YWdyYW50L3NhbXBsZWRhdGEvQ1NWbWV0YWRhdGE= (decoded: 5bbabc13-1227-41a7-b0cd-f2ac35291e7f:/vagrant/sampledata/CSVmetadata)row_ids[]
: ID of the associated TransferMetadataSet for disk image ingest. Can be provided as [""]
- Response: JSON
message
: "Copy successful."path
: Path the transfer was copied to on start?
List Unapproved Transfers[edit]
- URL:
/api/transfer/unapproved
- Verb: GET
- Returns a list of transfers waiting for approval.
- Response: JSON
message
: "Fetched unapproved transfers successfully."results
: List of dicts with keys:type
: Transfer type. One of: standard, unzipped bag, zipped bag, dspacedirectory
: Directory the transfer is in currentlyuuid
: UUID of the transfer
Approve Transfer[edit]
- URL:
/api/transfer/approve
- Verb: POST
- Approve a transfer waiting to be started.
- Parameters: JSON body
type
: Type of the transfer to approved. One of: standard, unzipped bag, zipped bag, dspace.directory
: Name of the directory for the transfer to approve
- Response: JSON
message
: "Approval successful."uuid
: UUID of the approved transfer
Status[edit]
- URL:
/api/transfer/status/<transfer UUID>/
- Verb: GET
- Returns the status of the transfer.
- Response: JSON
status
: One of FAILED, REJECTED, USER_INPUT, COMPLETE or PROCESSINGname
: Name of the transfer, e.g. "imgs"sip_uuid
: If status is COMPLETE, this field will exist with either the UUID of the SIP or 'BACKLOG'microservice
: Name of the current microservicedirectory
: Name of the directory, e.g. "imgs-52dd0c01-e803-423a-be5f-b592b5d5d61c"path
: Full path to the transfer, e.g. "/var/archivematica/sharedDirectory/watchedDirectories/SIPCreation/completedTransfers/imgs-52dd0c01-e803-423a-be5f-b592b5d5d61c/"message
: "Fetched status for <transfer UUID> successfully."type
: "transfer"uuid
: UUID of the transfer, e.g. "52dd0c01-e803-423a-be5f-b592b5d5d61c"
Note: for consumers of this endpoint, it is possible for Archivematica to return a status
of COMPLETE
without a sip_uuid
. Consumers looking to use the UUID of the AIP that will be created following Ingest should therefore test for both a status
of COMPLETE
and the existence of sip_uuid
that does not also equal BACKLOG
to ensure that they retrieve it. This might mean an additional call to the status endpoint while this data becomes available.
Hide[edit]
- URL:
/api/transfer/<transfer UUID>/delete/
- Verb: DELETE
- Hide a transfer
- Response: JSON
removed
: True
Completed[edit]
- URL:
/api/transfer/completed/
- Verb: GET
- Return list of Transfers that are completed
- Response: JSON
message
: "Fetched completed transfers successfully."results
: List of UUIDs of completed Transfers
- Added in Archivematica 1.6
Start Reingest[edit]
- URL:
/api/transfer/reingest
- Verb: POST
- Start a full reingest.
- Parameters: JSON body
name
: Name of the AIP. The AIP should also be found at%sharedDirectory%/tmp/<name>
uuid
: UUID of the AIP to reingest
- Response: JSON
message
: "Approval successful."reingest_uuid
: UUID of the reingested transfer
Ingest[edit]
Status[edit]
- URL:
/ingest/status/<unit UUID>/
- Verb: GET
- Returns the status of the SIP
- Response: JSON
status
: One of FAILED, REJECTED, USER_INPUT, COMPLETE or PROCESSINGname
: Name of the SIP, e.g. "imgs"microservice
: Name of the current microservicedirectory
: Name of the directory, e.g. "imgs-52dd0c01-e803-423a-be5f-b592b5d5d61c"path
: Full path to the transfer, e.g. "/var/archivematica/sharedDirectory/currentlyProcessing/imgs-52dd0c01-e803-423a-be5f-b592b5d5d61c/"message
: "Fetched status for <SIP UUID> successfully."type
: "SIP"uuid
: UUID of the SIP, e.g. "52dd0c01-e803-423a-be5f-b592b5d5d61c"
Hide[edit]
- URL:
/api/ingest/<SIP UUID>/delete/
- Verb: DELETE
- Hide a SIP
- Response: JSON
removed
: True
List SIPS Waiting for User Input[edit]
- URL:
/api/ingest/waiting
- Verb: GET
- Returns a list of SIPs waiting for user input.
- Response: JSON
message
: "Fetched units successfully."results
: List of dicts with keys:sip_directory
: Directory the SIP is in currentlysip_uuid
: UUID of the SIPsip_name
: Name of the SIPmicroservice
: Name of the current microservice
Improvement Note: Despite the URL, this currently returns both SIPs & transfers that are waiting for user input. A separate /api/transfer/waiting should be added for transfers.
|
Completed[edit]
- URL:
/api/ingest/completed/
- Verb: GET
- Return list of SIPs that are completed
- Response: JSON
message
: "Fetched completed ingests successfully."results
: List of UUIDs of completed SIPs
- Added in Archivematica 1.6
Reingest[edit]
- URL:
/api/ingest/reingest
- Verb: POST
- Start a partial or metadata-only reingest.
- Parameters: JSON body
name
: Name of the AIP. The AIP should also be found at%sharedDirectory%/tmp/<name>
uuid
: UUID of the AIP to reingest
- Response: JSON
message
: "Approval successful."reingest_uuid
: UUID of the reingested SIP
Copy Metadata[edit]
- URL:
/api/ingest/copy_metadata_files/
- Verb: POST
- Add metadata files to a SIP.
- Parameters: JSON body
sip_uuid
: UUID of the SIP to put files insource_paths[]
: List of files to be copied, base64 encoded, in the format 'source_location_uuid:full_path'
- Response: JSON
error
: Falsemessage
: "Files added successfully."
Administration[edit]
Levels of Description[edit]
- URL:
/api/administration/dips/atom/levels/
- Verb: GET?
- Return a JSON-encoded set of the configured levels of description.
- Response: JSON. List of AtoM Levels of description with key 'UUID' and value 'name of level of description'.
Fetch Levels of Description[edit]
- URL:
/api/administration/dips/atom/fetch_levels/
- Verb: GET?
- Fetch all levels of description from an AtoM database, replacing any previously existing.
- Response: JSON. Updated list of AtoM Levels of description with key 'UUID' and value 'name of level of description'.
Unit[edit]
Note: Currently, you can only query strings in English.
List jobs[edit]
- URL:
/api/v2beta/jobs/<unit UUID>/
- Verb: GET
- Return a list of jobs for the passed unit (transfer or ingest).
- Parameters:
- Optional filters:
microservice
: Name of the microservice the jobs belong tolink_uuid
: UUID of the job chain linkname
: Name of the job
- Response: JSON body
- List of dicts with keys:
uuid
: UUID of the jobname
: Name of the jobstatus
: One of USER_INPUT, PROCESSING, COMPLETE, FAILED or UNKNOWNmicroservice
: Microservice the job belongs tolink_uuid
: UUID of the job chain linktasks
: List of dicts with information about the microservice's tasks:uuid
: UUID of the taskexit_code
: Exit code of the task
- List of dicts with keys:
Task[edit]
- URL:
/api/v2beta/task/<task UUID>/
- Verb: GET
- Return information about a task.
- Response: JSON body
uuid
: UUID of the taskexit_code
: Exit code of the taskfile_uuid
: UUID of the file used for the taskfile_name
: File used for the task,time_created
: String (YYYY-MM-DD HH:MM:SS) representing when the task was createdtime_started
: String (YYYY-MM-DD HH:MM:SS) representing when the task startedtime_ended
: String (YYYY-MM-DD HH:MM:SS) representing when the task finishedduration
: Task duration in seconds (integer). If the duration is less than a second, this will be a < 1 string
Other[edit]
Path Metadata[edit]
- URL:
/api/filesystem/metadata/
- Verb: GET, POST
- Fetch (GET) or update (POST) metadata for a path (currently only level of description).
- Parameters: Query string parameters (GET) or JSON body (POST)
path
: Arranged path to get metadata on
- GET response: JSON
level_of_description
: Level of description
- POST response: JSON
success
: True
Processing Configuration[edit]
- URL:
/api/processing-configuration/<name>
- Verb: GET?
- Return processing configuration with <name>
- Response: The processing config file as a stream.
- Content type: text/xml
Beta endpoints[edit]
API endpoints which are still in-flux and that could potentially change.
Package[edit]
Provides additional functionality over the start and approve transfer endpoints, for example, wrapping both those steps into a single call.
- URL:
/api/v2beta/package
- Verb: POST
- Start a new transfer type.
- Parameters: JSON body
- Mandatory
name
: Transfer namepath
: Path relative, or absolute to a storage service transfer source
- Optional
type
: Transfer type, e.g. standard, dataverse, zipped bag, default:standard
processing_config
: Processing configuration, e.g. default, automated, default:default
accession
: Accession IDaccess_system_id
: Access system ID (see docs)metadata_set_id
: Used to link to metadata sets added via the user interface. It's safe to ignore this for now since metadata can't be associated to transfer via the API at the moment.auto_approve
: Booleantrue
orfalse
to set the transfer to auto-approve, default:true
- Mandatory
- Response: JSON
id
: Transfer UUID (Note: as the package endpoint allows the caller to interact with Archivematica asynchronously it doesn't guarantee a transfer has started. The caller must use the UUID in the response to verify it has begun or any errors that were encountered initiating one.)
Examples:
Only a subset of these options might be needed for most use-cases. A fundamental difference between the package
endpoint and others from which a transfer can be initiated is that a storage service transfer location UUID isnt always required. In some cases that might still be ideal.
Starting a transfer using an absolute path:
curl -v POST \ -H "Authorization: ApiKey test:test" \ -H "Content-Type: application/json" \ -d "{\ \"path\": \"$(echo -n '/home/archivematica/archivematica-sampledata/SampleTransfers/DemoTransferCSV' | base64 -w 0)\", \ \"name\": \"demo_transfer_absolute\", \ \"processing_config\": \"automated\", \ \"type\": \"standard\" \ }" \ "http://<archivematica-uri>/api/v2beta/package"
Starting a transfer using an relative path with a transfer source UUID:
curl -v POST \ -H "Authorization: ApiKey test:test" \ -H "Content-Type: application/json" \ -d "{\ \"path\": \"$(echo -n 'd1184f7f-d755-4c8d-831a-a3793b88f760:/archivematica/archivematica-sampledata/SampleTransfers/DemoTransferCSV' | base64 -w 0)\", \ \"name\": \"demo_transfer_relative\", \ \"processing_config\": \"automated\", \ \"type\": \"standard\" \ }" \ "http://<archivematica-uri>/api/v2beta/package"
Validate[edit]
Available in Archivematica 1.10+. This endpoint can be used to validate CSVs against embedded sets of rules. Currently works with Avalon Media System Manifest files.
In the future, this endpoint can be extended to support validation for metadata.csv
or rights.csv
, or other institutionally-based rules.
- URL:
/api/v2beta/validate/avalon
- Content-Type: text/csv; charset=utf-8
- Parameters:
<document>
Usage example: (assuming that avalon.csv
exists)
curl http://127.0.0.1:62080/api/v2beta/validate/avalon \ --data-binary "@avalon.csv" \ --header "Authorization: ApiKey test:test" \ --header "Content-Type: text/csv; charset=utf-8"
Response examples:
200 OK
{ "valid": true }
400 Bad Request (expect reason to include different validation errors)
{ "valid": false, "reason": "Administrative data must include reference name and author." }
404 Not Found
{ "error": true, "message": "Unknown validator. Accepted values: avalon" }