### Fetch feed with HTTP GET and Bearer authorization Source: https://navikt.github.io/pam-stilling-feed Use this HTTP request to fetch the job vacancy feed. It requires a bearer token in the Authorization header. The token can be a public token for experiments or a private token obtained by registering as a consumer. ```http GET https://pam-stilling-feed.nav.no/api/v1/feed Accept: application/json Authorization: Bearer ``` -------------------------------- ### Feed item object Source: https://navikt.github.io/pam-stilling-feed JSON structure of a feed item. Contains top-level details and a nested `_feed_entry` object with metadata. The `url` field can be queried to get full vacancy details. ```json { "id": "string - Id of the entry", "url": "string - URL for fetching the details of the given vacancy", "title": "string - Job vacancy title", "content": "string", "date_modified": "2023-05-25T07:47:08.935Z - ISO formatted time for last change to the ad", "_feed_entry": { "uuid": "string - UUID for the ad", "status": "string - Status of the given ad, can be ACTIVE or INACTIVE", "title": "string - Title of the ad", "businessName": "string - Name of the business", "municipal": "string - Municipal of the work place", "sistEndret": "2023-05-25T07:47:08.935Z - ISO formatted time for last change to the ad" } } ``` -------------------------------- ### Migrate from old public-feed: download active ads in Bergen Source: https://navikt.github.io/pam-stilling-feed Use this pseudo-code to migrate from the old public-feed to the new feed. It downloads all active ads in the Bergen municipality, handling pagination, conditional requests, and filtering. Note that ads are never active for more than 6 months, so only fetch ads after 2024-06-01 when today is 2024-12-01. The time format uses RFC-1123, and the If-None-Match header is optional on the first call. ```pseudo-code lastModified = Sat, 1 Jun 2024 00:00:00 +0200 etag = null feedPage = "/api/v1/feed" while (true) { response = GET https://pam-stilling-feed.nav.no/$feedPage Accept: application/json Authorization: Bearer If-Modified-Since: $lastModified If-None-Match: $etag (not mandatory: only provide this if etag is not null, i.e. don't provide etag in first call) if (response.status == 200) { lastModifed = response.header.last-modified etag = response.header.etag feedPage = response.next_url foreach (adHeader in response.bodyAsJson.items) { if (adHeader._feed_entry.status != "ACTIVE") # Delete inactive ads even if their municipality is wrong # Municipality, and other fields that you filter on, might change DELETE_AD(adHeader._feed_entry.id) } else { if (adHeader._feed_entry.municipal == "BERGEN") { adResponse = GET https://pam-stilling-feed.nav.no/${adHeader.url} Accept: application/json Authorization: Bearer if (adResponse.status == 200) SAVE_AD(adResponse.bodyAsJson.ad_content) } } else { # We have either downloaded all ads, or an error occured # In any case, sleep for 2 minutes before trying to fetch ad updates sleep(120 seconds) } } ``` -------------------------------- ### Feed page response object Source: https://navikt.github.io/pam-stilling-feed JSON structure of a feed page response. Contains metadata and a list of feed items. The `next_url` and `next_id` fields are used for pagination; when both are null, the end of the feed has been reached. ```json { "version": "string - Version of the feed", "title": "string - Feed title", "home_page_url": "string", "feed_url": "string - relative url of the returned feed-page", "description": "string", "next_url": "string - relative url to the next page in the feed", "id": "string - ID of the current page", "next_id": "string - ID of next page", "items": [ FeedItem ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.