How can I download the complete list of Observation Fields?

I want analyze all the existing Observation Fields. There are currently thousands of them, so manually scraping the nearly 500 pages of search results is not feasible.

I’ve searched the forum topics for a half-hour and have not been able to find an answer to this question anywhere. I thought it should be something available through the API. If it is, it’s not documented. https://api.inaturalist.org/v1/observation_fields returns a page titled “Error” that only says “Cannot GET observation_fields”.

1 Like

You can use the older API, documentation here: https://www.inaturalist.org/pages/api+reference#get-observation_fields

For example, https://www.inaturalist.org/observation_fields.json?page=1 gets the first page of observation fields.

Here’s a python script that will output a csv of all observation fields (takes about 10 mins to run):

import requests
import json
import csv
import time


apiurl = 'https://www.inaturalist.org/observation_fields.json?page='


fileout = open('obsfields.csv', encoding='utf-8', mode='w+', newline='')
csvwriter = csv.writer(fileout, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
csvwriter.writerow(['id','name','datatype','user_id','description','created_at','updated_at','allowed_values','values_count','users_count','uuid'])


for page in range(1,485):
    time.sleep(1)
    try:
        r = requests.get(apiurl + str(page))
        for field in r.json():
            csvwriter.writerow([field.get('id',''), field.get('name',''), field.get('datatype',''), field.get('user_id',''), field.get('description',''), field.get('created_at',''), field.get('updated_at',''), field.get('aallowed_values',''), field.get('values_count',''), field.get('users_count',''), field.get('uuid','')])

    except:
        print("error on page " + str(page))
1 Like