In order to create a stateless API, driving process in the client application, hypermedia or links are used. This means that URLs are merely resources on a web server, obtained from other resources. Again, this implies that links should be read out of the API resources by looking for the relation rel="..."
. The links can, and will, change (non-breaking change), but the relations will not (breaking change).
An example: Let's say you want to do a search for ads. Your first impulse might very well be to look up the URL and just hard-code it.
https://cache.api.finn.no/iad/search/realestate-homes?orgId=1234567..
It looks pretty straightforward right? The problem is that the location of the search result (the URL above) might at some point in time change. If it does, your client will break ugly, and you will probably not notice until your customer(s) bother to give you a call or send an email.
Instead, you should:
Searches Workspace
until you find the collection
with the correct title
. In this case: realestate-homeshref
from that collection
and store it in a variable. If you use multiple URLs, store them in a map
with key=title
and value=URL
If you restart your application regularly you typically want to do points 1 - 4 at startup time. If not, repeat daily or so.
This approach applies to all links in the API.
Even though a field always seem to be present, it most likely will not at some time.
Hence you should always check for its presence before you try to extract the value