This isn’t something we regularly do but I’m just trying a few of these manually (if it’s an issue, we need to know…)
Picking some random companies (looking on the CH website to locate instances where they say they have PDF and iXBRL - which might perhaps mean “only some”…) but I find:
- I get the type I request (PDF or iXBRL).
- If i re-request the data (same request), I get the same type (e.g. the examples I tried it’s not switching between different types).
Very small sample size due to time, but “it works for me”…
curl -u MYAPIKEY: "https://api.company-information.service.gov.uk/company/14351587/filing-history/MzQxNzM2OTEwM2FkaXF6a2N4"
(use the “document_metadata” entry):
curl -u MYAPIKEY: "https://document-api.company-information.service.gov.uk/document/U92CyiA9WBzWktpyIxWFmhq7J1NRFm06ntFzIz4U-sA"
{"company_number":"14351587","barcode":"XD0HJ94X","significant_date":"2023-09-30T00:00:00Z","significant_date_type":"made-up-date","category":"accounts","pages":1,"filename":"14351587_aa_2024-04-06","created_at":"2024-04-06T16:54:56.384465773Z","etag":"","links":{"self":"https://document-api.company-information.service.gov.uk/document/U92CyiA9WBzWktpyIxWFmhq7J1NRFm06ntFzIz4U-sA","document":"https://document-api.company-information.service.gov.uk/document/U92CyiA9WBzWktpyIxWFmhq7J1NRFm06ntFzIz4U-sA/content"},"resources":{"application/pdf":{"content_length":22603},"application/xhtml+xml":{"content_length":14917}}}
curl -L --header "Accept: application/xhtml+xml" -u MYAPIKEY: "https://document-api.company-information.service.gov.uk/document/U92CyiA9WBzWktpyIxWFmhq7J1NRFm06ntFzIz4U-sA/content"
… consistently gives me xiBRL
curl -L --header "Accept: application/pdf" -u MYAPIKEY: "https://document-api.company-information.service.gov.uk/document/U92CyiA9WBzWktpyIxWFmhq7J1NRFm06ntFzIz4U-sA/content"
… gives me PDF.
Another:
curl -u MYAPIKEY: "https://api.company-information.service.gov.uk/company/05388912/filing-history/MzQzNDk3MDg3OGFkaXF6a2N4"
curl -u MYAPIKEY: "https://document-api.company-information.service.gov.uk/document/mHOKgQpQWfXabfh6GrO2_pUI-Y7i1JETwXoQSiXhIb4"
{"company_number":"05388912","barcode":"XDB9DYM1","significant_date":"2023-12-31T00:00:00Z","significant_date_type":"made-up-date","category":"accounts","pages":13,"filename":"05388912_aa_2024-09-09","created_at":"2024-09-09T15:00:44.037434452Z","etag":"","links":{"self":"https://document-api.company-information.service.gov.uk/document/mHOKgQpQWfXabfh6GrO2_pUI-Y7i1JETwXoQSiXhIb4","document":"https://document-api.company-information.service.gov.uk/document/mHOKgQpQWfXabfh6GrO2_pUI-Y7i1JETwXoQSiXhIb4/content"},"resources":{"application/pdf":{"content_length":174343},"application/xhtml+xml":{"content_length":195023}}}
curl -L --header "Accept: application/xhtml+xml" -u MYAPIKEY: "https://document-api.company-information.service.gov.uk/document/mHOKgQpQWfXabfh6GrO2_pUI-Y7i1JETwXoQSiXhIb4/content"
curl -L --header "Accept: application/pdf" -u MYAPIKEY: "https://document-api.company-information.service.gov.uk/document/mHOKgQpQWfXabfh6GrO2_pUI-Y7i1JETwXoQSiXhIb4/content"
That all works as expected e.g. correct types returned (and same data returned if I re-request the same thing).
Obvs. just a tiny sample - but do they work for you? If not, I guess the next direction would be do you get consistent results e.g. if you repeat a request do you get a different type? Then - how are you calling the API? If you’re consistently getting the wrong type do you have any examples?
We’ll keep tabs on this ourselves.
Good luck.