# Help with Document API & Fetch a Document

**URL:** <http://forum.companieshouse.gov.uk/t/help-with-document-api-fetch-a-document/255>\
**Category:** Uncategorized\
**Created:** [September 4, 2015, 8:05am UTC](http://forum.companieshouse.gov.uk/t/help-with-document-api-fetch-a-document/255 "2015-09-04T08:05:10Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![csmith](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/csmith/32/8_2.png) [@csmith](http://forum.companieshouse.gov.uk/u/csmith)\
**Post date:** [September 7, 2015, 3:55pm UTC](http://forum.companieshouse.gov.uk/t/help-with-document-api-fetch-a-document/255/3 "2015-09-07T15:55:09Z")

</div>

A note for step (2):

A client should be following links.document\_metadata URL of the filing history to get to a document, and not have to construct URL’s on the fly. Should we change the ID encoding, then client’s that construct their own URLs will break.

So, in the **short term** , take the links.document\_metadata URL from the filing history, and append /content onto the end. This will return the default PDF, but if PDF is not available, you’ll have to deal with the failure. Calling the document\_metatdata endpoint first allows you to query which document types are available before you request a particular form (possible types will be PDF, XBRL, iXBRL (coming soon), plus others in the future).

If a direct link to the default document is required, then we will look to adding this to the filing history links: {} sub-document. Client side (re)manipulation of URL’s is not desirable:

> **[HATEOAS](https://en.wikipedia.org/wiki/HATEOAS)**
>
> Hypermedia as the engine of application state (HATEOAS) is a constraint of the REST software architectural style that distinguishes it from other network architectural styles.
> With HATEOAS, a client interacts with a network application whose application servers provide information dynamically through hypermedia. A REST client needs little to no prior knowledge about how to interact with an application or server beyond a generic understanding of hypermedia. 
> By contrast, clients and servers in C...

Also see the following discussion:

> [@Filing-history links](http://forum.aws.chdev.org/t/filing-history-links/241):
>
> Hello there, I’m still migrating the app to the beta version of the new API Our current migration can sometimes spend about five seconds in calls for metadata currently. Will all companies have ‘document\_metadata’ links in the finished API? Kind regards, Luke

---

_[View the full topic](http://forum.companieshouse.gov.uk/t/help-with-document-api-fetch-a-document/255)._
