### Fetch Protected FINT Resource with Authentication (Bash) Source: https://fintlabs.github.io/api/tools The fint-curl script fetches a protected FINT resource. It handles obtaining a bearer token using client credentials from a client.json file and then makes the authenticated API request. It requires 'curl' and 'jq' to be installed and has OS-specific 'stat' commands. ```bash #!/bin/bash #set -x if ! ( curl --version > /dev/null && jq --version > /dev/null) then echo "Required tools curl and jq not installed" exit 1 fi case $(uname -s) in Linux) STATSZ="stat -c %s" STATMT="stat -c %Y" ;; Darwin) STATSZ="stat -f %z" STATMT="stat -f %m" ;; *) echo "Unknown OS $(uname -s)" exit 1 ;; esac CLIENT=${CLIENT:-client.json} TOKEN=${CLIENT}.token if [[ ! -e $CLIENT ]] then echo "Client settings missing" exit 1 fi eval $(cat $CLIENT | jq -r "\"OAUTH_ID=\"+.clientId, \"OAUTH_SECRET=\"+.openIdSecret, \"OAUTH_USER=\"+.username, \"OAUTH_PWD=\"+.password, \"SCOPE=\"+.scope, \"IDP_URL=\"+.idpUri, \"ASSET_ID=\"+.assetId") if [[ ! ( -e $TOKEN ) || $($STATSZ $TOKEN) -lt 10 || ( $(( $(date +%s) - $($STATMT $TOKEN) )) -gt 3500 ) ]] then curl -f -s ${IDP_URL:-https://idp.felleskomponent.no/nidp/oauth/nam/token} -u "${OAUTH_ID}:${OAUTH_SECRET}" -d grant_type=password -d username="${OAUTH_USER}" -d password="${OAUTH_PWD}" -d scope="${SCOPE:-fint-client}" | jq -r '.access_token' > $TOKEN fi if [[ $($STATSZ $TOKEN) -lt 10 ]] then echo "Authorization failure" exit 1 fi curl -H "Authorization: Bearer $(cat $TOKEN)" -H "accept: application/json;charset=UTF-8" -H "Content-Type: application/json" -H "x-org-id: ${ASSET_ID:-fintlabs.no}" -H "x-client: ${OAUTH_USER}" $* ``` -------------------------------- ### API Pagination Example (JSON) Source: https://fintlabs.github.io/api/overview Demonstrates how to paginate API results using 'size' and 'offset' query parameters. The response includes links for 'next' and 'prev' pages, along with total item count, current size, and offset. This is useful for handling large datasets efficiently. ```json { "_links": { "self": [ { "href": "/administrasjon/personal/person?size=25000&offset=0" } ], "next": [ { "href": "/administrasjon/personal/person?size=25000&offset=25000" } ] }, "total_items": 123456, "size": 25000, "offset": 0 } ``` ```json { "_links": { "self": [ { "href": "/administrasjon/personal/person?size=25000&offset=100000" } ], "prev": [ { "href": "/administrasjon/personal/person?size=25000&offset=75000" } ] }, "total_items": 123456, "size": 23456, "offset": 100000 } ``` -------------------------------- ### FINT API - Get All Objects of a Class Source: https://fintlabs.github.io/api/overview This operation retrieves all instances of a specified class from the FINT cache. It returns a JSON object containing a list of entries under '_embedded._entries', along with pagination details and links. The structure is consistent for all main classes in the FINT information model. ```json { "_embedded": { "_entries": [ { }, { } ] }, "_links": { "self": [ { "href": "..." } ] }, "total_items": 111, "size": 111, "offset": 0 } ``` -------------------------------- ### Get Objects Updated Since Timestamp Source: https://fintlabs.github.io/api/overview Retrieves a collection of objects that have been updated (added or modified) after a specified timestamp. Supports pagination and `size=0` for no updates. ```APIDOC ## Get objects updated since timestamp `/domain/package/class?sinceTimeStamp=