Leverage the 10000ft API to create custom exports to Excel

At IXDS we have a bunch of exports off of 10000ft, which we created manually in the past. For example, a weekly overview of over hours or the utilisation of employees etc. When 10000ft published their API, we happily jumped at it to automate these exports. This is a little example showing the basic workflow of getting data from 10.000ft, to exporting it to an excel file. We based our export tool on Python with Flask and some helpful libraries as Xlsx Writer.

1. Get some data from 10000ft.

base_url = 'http://api.10000ft.com'
auth_token = 'YOUR_AUTH_TOKEN_HERE' # [1]

headers = {
  'content-type': 'application/json'

params = {
  'per_page': '9999',
  'fields': 'availabilities, tags',
  'auth': self.auth_token

url = self.base_url + '/api/v1/holidays' # [2]
r = requests.get(url=url, params=params, headers=headers)
data = json.loads(r.text)

# [1] You can get your api authentication token by
# contacting 10.000ft support.
# [2] or "/api/v1/users" for users, "/api/v1/projects"
# for projects .. you get the drill. For all possible
# data-sets visit the 10.000ft api website.

2. Parse the data into your own data structure. (We do this to do operations on the data, and it’s more handy having proper objects than operating directly on a json structure).

holidays_raw = data

# we parse the raw data into our own model structure
holidays = []
for holiday in holidays_raw['data']:
  h = Holiday(holiday)

3. Export data into an excel file.

filename = 'export.xlsx'

workbook = xlsxwriter.Workbook(filename)
worksheet = workbook.add_worksheet('Holidays')

# widths
worksheet.set_column('A:A', 15)
worksheet.set_column('B:B', 30)

# put data
row = 1
for holiday in holidays:
  worksheet.write(row,0, holiday.date)
  worksheet.write(row,1, holiday.name)
  row += 1

# save

Useful resource: 10.000ft API documentation.

You can download an example app of the above code here (in Python, needs Flask and Xlsx Writer and Requests installed).

Comments are closed.