Skip to main content
NSF NEON, Operated by Battelle

Main navigation

    • About Overview
    • NEON Overview
    • About the NEON Biorepository
    • Observatory Blog
    • Newsletters
    • Staff
    • FAQ
    • User Accounts
    • Contact Us
    • Data Overview
    • Data Portal
    • Data Availability Charts
    • API & GraphQL
    • Prototype Data
    • Data Collection Methods
    • Getting Started with NEON Data
    • Using Data
    • Data Notifications
    • NEON Data Management
    • Samples & Specimens Overview
    • NEON Biorepository Sample Portal at ASU
    • About NEON Samples
    • Sample Types
    • Finding and Accessing Sample Data
    • Species Checklists
    • Requesting and Using Samples
    • Requesting Samples from the NEON Biorepository
    • Sample Use Guidelines
    • Acknowledging and Citing the NEON Biorepository
    • Field Sites Overview
    • Field Site Map and Info
    • Spatial Data Layers & Maps
    • Resources Overview
    • Getting Started with NEON Data
    • Research Support Services
    • Code Hub
    • Learning Hub
    • Science Seminars and Data Skills Webinars
    • Document Library
    • Funding Opportunities
    • Impact Overview
    • Research Highlights
    • Papers & Publications
    • NEON in the News
    • Get Involved Overview
    • Upcoming Events
    • Past Events
    • Research and Collaborations
    • Advisory Groups
    • NEON Ambassador Program
    • Partnerships
    • Community Engagement
    • Work Opportunities

Search

Learning Hub

  • Tutorials
  • Workshops & Courses
  • Science Videos
  • Teaching Modules

Breadcrumb

  1. Resources
  2. Learning Hub
  3. Tutorials
  4. Set up a NEON API Token

Tutorial

Set up a NEON API Token

Authors: Claire K. Lunch

Last Updated: Apr 2, 2026

This tutorial covers how to get a NEON API token and set it as an environment variable in your coding environment. It is intended for users who want to get their tokens set up quickly and efficiently. For a longer and broader overview of NEON user accounts and token management, see the tutorial on how to use a token with neonUtilities.

Get a NEON user account and token

The first step is create a NEON user account, if you don’t have one. Follow the instructions on the Data Portal User Accounts page. If you already have an account, go to the NEON Data Portal, sign in, and go to your My Account profile page.

Once you have an account, you can create an API token for yourself. At the bottom of the My Account page, you should see this bar:

Account page on NEON Data Portal showing Get API Token button.

Click the ‘GET API TOKEN’ button. After a moment, you should see this:

Account page on NEON Data Portal showing API token has been created.

Click on the Copy button to copy your API token to the clipboard:

Account page on NEON Data Portal showing API token with Copy button highlighted

Set the token as an environment variable

R

To create a persistent environment variable in R, we use a .Renviron file. The usethis package has a handy function to open the file for your active environment:

usethis::edit_r_environ()

The .Renviron file should now be open. Add a new line to it:

NEON_TOKEN=PASTE YOUR TOKEN HERE

Save the file and re-start R. You can now retrieve the token anytime you are working in this environment using the function Sys.getenv().

token <- Sys.getenv("NEON_TOKEN")

Python

To create a persistent environment variable in Python, the simplest option is to use the dotenv module.

This code chunk is run in the command line of your project environment:

pip install python-dotenv
touch .env

This will create a file named .env in the project folder. If you’re using GitHub, make sure .env is in your .gitignore to avoid syncing tokens to GitHub.

To add variables to the .env file, move over to the Python console.

import dotenv
import os

dotenv.set_key(dotenv_path=".env", key_to_set="NEON_TOKEN", value_to_set="PASTE YOUR TOKEN HERE")

Use the command dotenv.load_dotenv() to load environment variables to the session, then use os.environ.get() to access particular variables.

dotenv.load_dotenv()
token = os.environ.get("NEON_TOKEN")

If dotenv.load_dotenv() returns False, the variables did not load. If that happens, try dotenv.load_dotenv(dotenv.find_dotenv(usecwd=True)).

You are now ready to use your token in your code!

Questions?

If you have questions or comments on this content, please contact us.

Contact Us
NSF NEON, Operated by Battelle

Follow Us:

Join Our Newsletter

Get updates on events, opportunities, and how NEON is being used today.

Subscribe Now

Footer

  • About Us
  • Contact Us
  • Terms & Conditions
  • Careers
  • Code of Conduct

Copyright © Battelle, 2026

The National Ecological Observatory Network is a major facility fully funded by the U.S. National Science Foundation.

Any opinions, findings and conclusions or recommendations expressed in this material do not necessarily reflect the views of the U.S. National Science Foundation.