-> Retrieve addresses

Addresses define destinations for shipments. They come as a bundle of the actual human readable address information and the geo-location.

Some Basics about Addresses and the API in general

An address that is usually already in our system is your company address which you provided by Sign Up - Getting Started. A GET request to the company address enpoint, provides another good test to check if you're signed up properly as was explained in the previous chapter and gives an oppertunity to learn some basics about the API.

import requests

api_url = "https://<your company name>.prd.smartlane.io/api/companyaddress"

auth_header = {'Authorization': 'JWT ' + token}

response = requests.get(api_url, headers=auth_header)

You should get a response from our server that shows our address schema:

{'num_results': 1,
 'objects': [{'id': 1,
              'customernr': None,
              'contactcompany': 'Company Name',
              'contactfirstname': 'Max',
              'contactlastname': 'Mustermann',
              'email': None,
              'phonenr': None,
              'street': 'Elsenheimerstraße',
              'housenumber': '45',
              'postalcode': '80687',
              'city': 'München',
              'country': 'Germany',
              'location': {'coordinates': [11.60772, 48.12469],
                           'type': 'Point'},
              'addresstype': 'depot',
              'default_pdt_from': None,
              'default_pdt_to': None,
              'deliverylocations': [],
              'distances': None,
              'district': None,
              'additional': None,
              'code': None,
              'source_for_deliveries': []}]}

You can find all the typical properties of an address in this JSON response, like contactcompany, contactfirstname, contactlastname, street, housenumber and city. If you reference an address with its id, you can try requesting this address again via it's id by calling the address endpoint with, like this:

import requests

api_url = "https://<your company name>.prd.smartlane.io/api/address/1"

auth_header = {'Authorization': 'JWT ' + token}

response = requests.get(api_url, headers=auth_header)

Or simply get all addresses by calling the address endpoint without an id

import requests

api_url = "https://<your company name>.prd.smartlane.io/api/address"

auth_header = {'Authorization': 'JWT ' + token}

response = requests.get(api_url, headers=auth_header)