| Send us feedbackOur API allows developers to query the search engine and our Catalogue database within the Discovery service application programmatically, and returns results in XML for further processing. The service is offered as a beta with some functionality still to be developed. In the meantime we welcome feedback on the initial functionality in this release.
If you make a request to this service you are deemed to have accepted the terms and conditions
A little understanding of the internals of the Discovery service catalogue will help with the API methods below. The catalogue is a seven-level hierarchical database of our records (read a more detailed description). When using the API methods below, you’ll find that some of the normally ‘invisible’ levels (levels which are present but not reflected in the citable reference, such as ‘Division’) will become relevant and may be initially confusing when using methods like Children which traverse the levels of the catalogue.
Every record in our catalogue is an Information Asset and is uniquely referenced by its IAID. Some of the Information Assets have children, and this parent-child relationship defines the catalogue hierarchy.
Every Information Asset is also categorised by subject, date range and department (“Department” in this context being the top level of the catalogue previously called a “Lettercode”). These categories can be used to further filter the results, and multiple values for each filter can be semi-colon delimited. The acceptable values for these categorisations are as follows:
Show date range search filters
Show department search filters
One method, Search, is processed by our Discovery service search engine. The remainder of the methods take an IAID and return results directly from our Discovery service database.
The Search method offers a Basic search and an Advanced search, the Advanced search offering more complex searches with logical operators. The Basic search offers an optional SmartSearch function which will spellcheck the query terms. Please see the detailed documentation for more details on the parameters available for this function.
This page describes the service operations at this endpoint.
| Uri | Method | Description |
|---|---|---|
| InformationAsset/{id} | GET |
Service at http://discovery.nationalarchives.gov.uk/ API/InformationAsset/{ID} |
| Children/{id}/{page} | GET |
Service at http://discovery.nationalarchives.gov.uk/ API/Children/{ID}/{PAGE} |
| TotalChildren/{id} | GET | Service at http://discovery.nationalarchives.gov.uk/ API/TotalChildren/{ID} |
| Parent/{id} | GET |
Service at http://discovery.nationalarchives.gov.uk/ API/Parent/{ID} |
| Siblings/{id}/{PAGE} | GET | Service at http://discovery.nationalarchives.gov.uk/ API/Siblings/{ID}/{PAGE} |
| Search/{SMARTSEARCH}/{ADVANCEDSEARCH}/{PAGE}?{query} | GET |
Service at http://discovery.nationalarchives.gov.uk/API/Search/ {SMARTSEARCH}/{ADVANCEDSEARCH}/{PAGE}?query={QUERY}&allWords={ALLWORDS}&exactPhrase={EXACTPHRASE}&orWords1={ORWORDS1}&orWords2={ORWORDS2}&orWords3={ORWORDS3}¬Words1={NOTWORDS1}¬Words2={NOTWORDS2}¬Words3={NOTWORDS3}&subjects={SUBJECTS}&timePeriods={TIMEPERIODS}&departments={DEPARTMENTS}&startDate={STARTDATE}&endDate={ENDDATE}&citableReference={CITABLEREFERENCE}&numberOfResultsPerPage={NUMBEROFRESULTSPERPAGE} |
| Search/{SMARTSEARCH}/{ADVANCEDSEARCH}/{PAGE}?{query} | GET | Service at http://discovery.nationalarchives.gov.uk/API/Search/ {SMARTSEARCH}/{ADVANCEDSEARCH}?query={QUERY}&allWords={ALLWORDS}&exactPhrase={EXACTPHRASE}&orWords1={ORWORDS1}&orWords2={ORWORDS2}&orWords3={ORWORDS3}¬Words1={NOTWORDS1}¬Words2={NOTWORDS2}¬Words3={NOTWORDS3}&subjects={SUBJECTS}&timePeriods={TIMEPERIODS}&departments={DEPARTMENTS}&startDate={STARTDATE}&endDate={ENDDATE}&citableReference={CITABLEREFERENCE}&numberOfResultsPerPage={NUMBEROFRESULTSPERPAGE} |
You will need API access to view these example links. Please follow the instructions on Labs.
http://discovery.nationalarchives.gov.uk/API/Search/false/false/1?query=witchcraft
The returned data includes the subjects into which records have been categorised in its Subjects element, for example the first record returned at the time of writing is categorised in C10117 Witchcraft, C10023 Crime and C10049 International. By performing an Advanced search we can limit the results to particular subjects. For example, the following query will find records featuring the word witchcraft and categorised with subject C10059 (Marriage and Divorce):
http://discovery.nationalarchives.gov.uk/API/Search/false/true/1?allWords=witchcraft&subjects=C10059
Some series in our catalogue contain structured data, for example PCOM 3 (Licences for early release from prison) has a standardised ScopeContent description across the entire series so could be extracted and parsed into a dataset. Here’s how you might extract this data:
First we need to identify the IAID of the container series, PCOM 3. The Search method allows searching for Document References, so the following query will return records matching “PCOM 3”: http://discovery.nationalarchives.gov.uk/API/Search/false/false?query=PCOM%203
Checking the CitableReference values we see that the first search result is for an Information Asset which represents the series PCOM 3. We see that the IAID for this series is 11498.
We can find out how many Child IAs PCOM 3 has by supplying its IAID to the TotalChildren method: http://discovery.nationalarchives.gov.uk/API/TotalChildren/C11498
Apparently 770 IAs have PCOM 3 as their parent. To find out more about those children we can call: http://discovery.nationalarchives.gov.uk/API/Children/C11498/1
This returns the first page of Child IAs for PCOM 3. The IAID of the first child IA is 2389021, and its Citable Reference is “PCOM 3/1”. The SourceLevelId value shows that this IA is at level 6 of the catalogue (i.e. a Piece). The descriptions may be more granular still if the Piece has been Itemised. Let’s check if PCOM 3/1 has further description by checking if it has any children: http://discovery.nationalarchives.gov.uk/API/TotalChildren/C2389021
This reveals that PCOM 3/1 has been itemised and has 100 child Information Assets. We need to get the IAIDs of those children and then iterate through them, sending them to the InformationAsset method to return the detailed descriptions. http://discovery.nationalarchives.gov.uk/API/Children/C2389021/1
This returns InformationAssetIdentity objects which are a brief summary of the IA, but include the IAID which can be sent to the InformationAsset method to return the detailed IA information. The first child of PCOM 3/1 is PCOM 3/1/1 with IAID 10127419 http://discovery.nationalarchives.gov.uk/API/InformationAsset/C10127419
C 3 is another series where the information has been entered in a standardised format which could be parsed into a structured dataset.
Get the IAID for C 3:
http://discovery.nationalarchives.gov.uk/API/Search/false/false/1?query=C%203
Get a list of its Children:
http://discovery.nationalarchives.gov.uk/API/Children/C3566/1
The children of C 3 are at level 6, piece level (though confusingly, the citable reference of these pieces are of the form c3/x/x, which would more commonly be an item reference). For each child we need to:
The method calls we need to make for each child IA are therefore:
http://discovery.nationalarchives.gov.uk/API/TotalChildren/[IAID]
http://discovery.nationalarchives.gov.uk/API/InformationAsset/[IAID]
If TotalChildren > 0, recurse