Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/MickaelRigault/ztfquery/llms.txt

Use this file to discover all available pages before exploring further.

ztfquery accesses several independent ZTF data services, each with its own authentication requirements. To avoid asking for credentials on every call, ztfquery stores them in an encrypted file at ~/.ztfquery using the cryptography package and retrieves them automatically whenever a service is contacted. You only need to supply credentials once per service — or whenever you want to update them.

How Credential Storage Works

When ztfquery needs to authenticate with a service for the first time, it checks ~/.ztfquery for a stored credential. If none is found, it prompts you interactively. The entered value is base64-encoded and written back to ~/.ztfquery under the service’s section name. On every subsequent call the credential is read and decoded transparently. To reset or update a stored credential at any time, call:
from ztfquery import io

io.set_account("irsa")     # prompts for a new IRSA username and password
io.set_account("fritz")    # prompts for a new Fritz token
io.set_account("marshal")  # prompts for a new Marshal username and password
io.set_account("pharos")   # prompts for a new Pharos username and password
set_account accepts optional keyword arguments so you can supply values programmatically instead of being prompted:
# Supply credentials directly (useful in scripts)
io.set_account("irsa", username="myuser", password="mypassword")

# Supply a Fritz token directly
io.set_account("fritz", token="my_fritz_api_token")
The ~/.ztfquery file contains your encoded credentials. It is written with your default umask permissions. Ensure the file is not readable by other users on shared systems (chmod 600 ~/.ztfquery).

Initial Setup Flow

1

Attempt to use a service

Simply import and call any ztfquery function that requires a service. On the first call, ztfquery detects that no credential exists for that service and triggers the setup prompt automatically.
from ztfquery.query import ZTFQuery

zq = ZTFQuery()
zq.load_metadata(kind="sci", radec=[245.0, 30.0], size=0.01)
# → "No irsa account setup, please provide it"
# → "Enter your irsa login: "
# → Password: (hidden input)
2

Enter your credentials

Type your username and password (or token, for Fritz) when prompted. For IRSA, ztfquery immediately tests the credentials against the IRSA login endpoint and warns you if they appear incorrect.
3

Credentials are saved

After a successful login, ztfquery writes the encoded credential to ~/.ztfquery. All future calls to that service are authenticated automatically with no further prompts.
4

Reset credentials if needed

If your password changes or you want to switch accounts, call io.set_account(servicename) to overwrite the stored credential.
from ztfquery import io
io.set_account("irsa")

Service-by-Service Authentication

IRSA (NASA/IPAC Infrared Science Archive) hosts ZTF images and light curves and is accessed by query.py and lightcurve.py. Authentication uses a standard username and password registered at https://irsa.ipac.caltech.edu.
from ztfquery import io

# Set or reset your IRSA credentials
io.set_account("irsa")
# → Enter your irsa login: youruser
# → Password: (hidden)
You can also pass credentials inline to skip the stored credential entirely:
from ztfquery.query import ZTFQuery

zq = ZTFQuery()
zq.load_metadata(
    kind="sci",
    radec=[245.0, 30.0],
    size=0.01,
    auth=["youruser", "yourpassword"],
)
Private vs public data: ZTF public data (proprietary period expired) can be downloaded with any valid IRSA account. Accessing data still within its proprietary period requires an IRSA account that has been explicitly linked to the ZTF collaboration. If you only need public data, a free IRSA registration is sufficient.
To verify that your stored IRSA credentials work:
from ztfquery import io

print(io.test_irsa_account())  # True if credentials are valid

Inline Authentication Reference

All ztfquery download functions that contact IRSA accept an auth parameter so you can supply credentials at call time without touching the stored credential:
from ztfquery.query import ZTFQuery

zq = ZTFQuery()

# Query metadata with inline credentials
zq.load_metadata(
    kind="sci",
    radec=[245.0, 30.0],
    size=0.01,
    auth=["your_irsa_username", "your_irsa_password"],
)

# Download files with inline credentials
zq.download_data(
    "sciimg.fits",
    auth=["your_irsa_username", "your_irsa_password"],
)
For Fritz, pass the token keyword directly to the relevant function instead of using auth:
from ztfquery import fritz

fritz.download_lightcurve("ZTF21abcdefg", token="your_fritz_token")
Inline credentials are never written to ~/.ztfquery. Use them when you want to keep credentials out of files entirely (for example, reading them from environment variables in a pipeline), or when running as a different user than the one whose ~/.ztfquery file holds the credentials.

Build docs developers (and LLMs) love