Facing issues in consume Streaming API using PHP and Curl

We have created a stream api key and trying to consume Streaming API via postman but we got error as below.

We have encoded Stream api key by base64(RFC4648) and passing a query parameter as timepoint(also tried without timepoint). but we are getting error as below.

{

"error": "Invalid Authorization",

"type": "ch:service"

}

Any assistance would be greatly appreciated.

Kind Regards,
Ashish

Hi Ashish,
Please see (unofficial) Obtaining a key | CH Guide for how to authenticate on the streaming API.

You need to have a streaming API key which you put in the Authorization header (base64 encoded with a trailing colon).

On the authorisation tab of postman, it should look like this:

3 Likes

Hi @ebrian101 - I used your reply to try a streaming test, thanks for posting this it got me connected (I think - I used the filings endpoint) - the status on Postman is ‘Status: 200 OK’ the time clock is running but I cannot see any data being returned on the screen - could you add anything that may help point me in the right direction?

Many thanks for any assistance you can give. Kind regards.

At some times of day (outside of office hours) there are very few events on the streams so you might not receive anything. You can use https://companies.stream to check if there are currently events coming through.
To connect via postman, I had to wait about 30 seconds for the response to show. (for some reason it doesn’t appear to show the response while its still receiving new data, which with the streaming api is always).
Using cURL may be easier:

curl --user APIKEY: -s https://stream.companieshouse.gov.uk/filings

or there is a simple nodejs example in the repository for companies.stream (linked above).

Hi @ebrian101, thanks for replying – I did use Curl and got it working with data being sent – thanks for that. :+1:

On the Postman forum I did read this reply from – ‘postman-staff commented on Dec 20, 2021’
‘At the moment we (postman) do not support a fully streamed response.’
And from the text in linked updates, it looks likely that Postman will only display data when the stream ends, or there’s a big enough gap in the data updates, presumably in the filings option that is never as it’s constantly updating and perhaps why I’m connected on Postman but not seeing any data displayed!

It looks likely that Postman will add a full streaming solution under Feature request: Support for streamed responses #5040, but as of 10 days ago (the last update on that post) – this is still on their future development list.

Thank again for your help – much appreciated.