I agree that there are many exceptions and plenty of undocumented things but I don’t recall this particular issue (e.g. if you get one, it’s an object, if you get more than one, you get an array of objects) in the CH API (non-streaming - I’m not familiar with the streaming side). Do you have more info / examples?
The chargeList documentation definitely has some mistakes / inconsistencies. I think the “array” part of the documentation is incorrect in several places. I guess there could be some genuine oddity - for example maybe these suddenly become arrays where you have more than 1 person entitled but there are two people entitled in /company/SC100764/charges/9vFxc01YEwJI1I3wnrwz9Slb5zE (see in the web interface) and that’s not the case there. So I think this is just a mistake in the documentation. I’m not Companies House though! My own notes on this below - if these are incorrect / unclear please let me know!
Example companies with charges to check:
SC256721
03959649
03142135
SC118434
SC100764
In general the chargeList documentation is not great e.g. has errors and lacks clarity
Documentation for chargeList endpoint
https://developer-specs.company-information.service.gov.uk/companies-house-public-data-api/reference/charges/list
(The Swagger / Openapi documentation also has a separate issue - the main Swagger/OpenAPi document currently (09/12/201) has all links to sub-documents pointing to a local IP address so you need to correct the host to get there:
https://developer-specs.company-information.service.gov.uk/api.ch.gov.uk-specifications/swagger-2.0/spec/charges.json#/chargeList
)
Missing:
The main documentation misses that you can pass in items_per_page and start_index. These are noted in the Swagger/OpenAPI docs.
The main documentation is missing the 404 error code.
chargeList resource
Main documentation: Companies House Public Data API: chargeList
Typo:
Both main documentation (in the chargeList resource docs) AND the Swagger/OpenAPI docs have a typo:
“unfiletered_count
” - should read “unfiltered_count
”
Inconsistency:
This mostly follows the Companies House “paged data” format:
You can pass in an items_per_page
and start_item
. The start_item
parameter starts from 0 - it should be a multiple of items_per_page
. There were bugs around items_per_page
being 1 so maybe avoid that (can’t remember if just in search endpoints or generally).
You’re returned an object with a parameter list with array of all objects, and some “counts”.
In this case:
- The
start_index
or items_per_page
are not returned (e.g. no members in response) despite being able to specify these.
- You have several “counts” - but the main one is “
total_count
” rather than the “total_results
” that you see elsewhere. (I think this is the same as Filing history).
Logically missing:
Doesn’t provide count of unsatisfied charges - you have to calculate that from unfiltered_count
- satisfied_count
- part_satisfied_count
Possible inconsistency
The “enum constants” provide a way to look up text. The “scottish_alterations
” member (also incorrectly listed in docs as an array of objects - it’s a simple object) is slightly different - there are three boolean flags for “Scottish alterations” so you have to map these to the text yourself:
has_alterations_to_order
has_alterations_to_prohibitions
has_restricting_provisions
Incorrect (typos)?
The documentation (both main and Swagger/OpenAPI) lists several members as an array of objects when what you actually get returned is a single simple object:
- classification
- links
- particulars
- secured_details
- scottish_alterations
- transactions.links
Other notes:
You may want to further process the title.