Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Before you start you need to obtain the following information:

Code Block
CLIENT_ID="my client id"
CLIENT_SECRET="my client secret"
API_USERNAME="my Infoland API username"
API_PASSWORD="my Infoland API password"

...

In order to obtain a token, run the following:

Code Block
curl -s -H  "Content-Type: application/json" https://beta-api.ambita.com:443/authentication/v2/token -d "
        {
                \"grant_type\": \"password\",
                \"client_id\": \"CLIENT_ID\",
                \"client_secret\": \"CLIENT_SECRET\",
                \"username\": \"API_USERNAME\",
                \"password\": \"API_PASSWORD\"
        }"

Example response:

Code Block
{
  "access_token": "ej577asf-a5k6-42yq-a3a2-fh03hb8cb58c",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "aj274ajd-t1s8-48sk-v5m1-shf64j9bq25a",
  "scope": [
    "shopping.read",
    "shopping.write",
    "productcatalog.read"
  ]
}

...

To get a new access_token you can use the refresh token grant_type:

Code Block
curl -s -H  "Content-Type: application/json" https://beta-api.ambita.com:443/authentication/v2/token -d "
        {
                \"grant_type\": \"refresh_token\",
                \"refresh_token\": \"aj274ajd-t1s8-48sk-v5m1-shf64j9bq25a\"
        }"

...

  1. Use the orderId and get the order from our API described in Get order

  2. Loop through assets and do necessary actions

    Files can occur on both order level and order line level.

    Example (JavaScript):

    Code Block
     fetch('https://beta-api.ambita.com/kode/v1/orders/:orderId')
       .then(response => {
         response.orders.forEach(order => {
           if (order.assets.length > 0) {
             // loop through order assets and do necessary actions
           }
    
           order.orderLines.forEach(orderLine => {
             if (orderLine.assets.length > 0) {
               // loop through order line assets and do necessary actions
             }
           });
         })
       });
    
  3. Delete or save the file

    Response from https://beta-api.ambita.com/kode/v1/orders/:orderId:

    Code Block
     {
       "id": 1234567,
       "status": "PROGRESS",
       ...
       "orders": [
         {
           "id": 1234567,
           "supplierName": "Infoland Kommune - demo",
           "assets": [
             ...
           ],
           ...
           "orderLines": [
             {
               "id": 12345678,
               "assets": [
                 ...
               ]
    

    Take a look at the Get delivered files section, the id of the asset will be unique and should be stored in your system. Use this id as a reference to check if you have downloaded the asset before, this way you won’t end up with duplicates. You should also check the status of the asset and delete the file if it has status DELETED.

...

Send a POST request to https://beta-api.ambita.com/kode/v1/orders/cadastre

Example request:

Code Block
curl -s \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer ej577asf-a5k6-42yq-a3a2-fh03hb8cb58c" \
      https://beta-api.ambita.com/kode/v1/orders/cadastre -d "
        {
                \"orderData\": {
                  \"address\": \"Infoveien 1, 9999 Infoland\",
                  \"cadastre\": \"9999-1-1-0-0\"
                },
                \"products\": [
                  {
                    \"code\": \"WI99990033\"
                  }
                ],
                \"reference\": \"some-reference\",
                \"technicalReference\": \"some-technical-reference\"
        }"

JSON body :structure

Property

Description

deliveryInformation*

Object that includes information related to delivery of the products

orderData

Order data required to order the products specified which will differ based on the type of product being ordered between cadastre, share, map products

reference

This reference is used to connect multiple orders to one reference, usually an assignment key and commonly used for billing reference

technicalReference*

This reference is used to reference an order in our system, to a unique id in your system, good for debugging and lookups

products

Array of objects

  • Optional

products:

* indicates optional fields

deliveryInformation object

Property

Description

address*

Address line

address2*

Address line 2

address3*

Address line 3

alias*

Alias

companyName*

Company name

email*

Email

name*

Name

phone*

Phone

postalCode*

Postal code

* indicates optional fields

orderData object

Property

Description

For ordering cadastre products

address

Important to use this format: {street-address}, {postal-code} {postal-office}

cadastre

Cadastre should always include all parts {Kommunenummer}-{Gårdsnummer}-{Bruksnummer}-{Festenummer}-{Seksjonsnummer}, example: 0301-100-10-0-0

For ordering share products

organizationNumber

Organization number

shareNumber

Share number

For ordering map product

geometry

A closed GeoJSON polygon specified in ETRS89 / UTM zone 33N or ETRS89 / UTM zone 32N

spatialReference

Spatial reference the geometry is specified in either 25833 or 25832

products array of objects

Property

Description

code

Use product API to find correct product codes in given municipality

data*

Additional data required to order a specific products that varies based on a product

* indicates optional fields

Example response

Get products

...

Take a look at our Swagger documentation for the API here: Swagger

Example request:

Code Block
curl -s \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer ej577asf-a5k6-42yq-a3a2-fh03hb8cb58c" \
      https://beta-api.ambita.com/kode/v1/products?municipality=9999

...

Take a look at our Swagger documentation for the API here: Swagger

Example request:

Code Block
curl -s \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer ej577asf-a5k6-42yq-a3a2-fh03hb8cb58c" \
      https://beta-api.ambita.com/kode/v1/orders/1234567

...

These are the statuses that can be pushed to your system:

Status

Description

NEW

This status is the same as an order confirmation email, it confirms that our order system has received the order and is ready to process the order

UPDATED

This status is sent when a new file has arrived and you should get the new file. NB! This status can occur after an order is finished

FINISHED

This status is sent when an order is set to finished, you should check if you have received all the files

CANCELLED

This status is sent when the order is cancelled, you should delete the files that you have received on this order

REFUNDED

This status is sent when the order is refunded, you should delete the files that you have received on this order

...

Here you can find information about assets in our API

Asset object:

Code Block
{
  "name": "The-exact-name-of-the-file.pdf",
  "filename": "More-descriptive-name-of-the-file.pdf",
  "downloadUrl": "https://beta-api.ambita.com/shopping/v2/assets/d2f48dk9d267a86d2858244d0c2c1937",
  "assetStatus": "OK",
  "productCategory": "PRODUCT_UTEN_KATEGORI",
  "id": "d2f48dk9d267a86d2858244d0c2c1937"
}

...

Available product categories:

Product category

PRODUKT_UTEN_KATEGORI

KOMMUNAL_INFORMASJON

PLAN_KART_REGULERING

FERDIGATTEST_OG_MIDLERTIDIG_BRUKSTILLATELSE

...