Communicating with the Treasure Map to either report or get information is best done programmatically through the API using POST and GET methods (see below). However, one can also use the pages on this website to report and get the information. Below are examples of two use cases for the API methods.
We have two versions of the API, as a consequence of my adolescence in API programming in 2019... We recommend using /api/v1
Newly released is our
It fully encompasses the API endpoints, while also providing event tools to further aid in GW follow-up
Great! Before you can start you must register an account through this website. Then you will be issued a token that you will use to post your reports.
Once you have an account, also please check whether your imaging instrument is listed (either on the website or by using the instruments GET method - see below), and make a note of its ID. If it isn't listed, please submit it.
You are required to register. Use your API token you receive upon registration along with the pointings GET method (see below) to retrieve reported planned or completed pointings for a specific GW alert, time window, instrument, and/or band.
Usage
/api/v0/pointings/api/v1/pointings
Parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "pointings"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"band":"XRT",
"status":"completed",
"graceid":"GW190425"
}
url = "{}/{}".format(BASE, TARGET)
r = requests.get(url=url, json=json_params)
print(r.text)
An example of querying for completed pointings based on their central_wave and bandwidth parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "pointings"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"central_wave":5000,
"bandwidth":500,
"status":"completed",
"graceid":"GW190425"
}
url = "{}/{}".format(BASE, TARGET)
r = requests.get(url=url, json=json_params)
print(r.text)
An example of querying for completed pointings based on their wavelength_regime parameters. It filters all pointings based on their calculated central_wave and bandwidth, and tests whether or not they fall within the queried regime. This same concept can be applied for the frequency_regime and energy_regime parameters as well
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "pointings"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"wavelength_regime":[3500,7500],
"wavelength_unit":'angstrom',
"status":"completed",
"graceid":"GW190425"
}
url = "{}/{}".format(BASE, TARGET)
r = requests.get(url=url, json=json_params)
print(r.text)
USAGE:
/api/v0/pointings/api/v1/pointings
Notes
JSON Parameters
If you are posting a PLANNED pointing Observation
REQUIRED
NOT REQUIRED
OR to request through Zenodo
An example of submitting a list pointings with varying degrees of validity in:
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "pointings"
API_TOKEN = "-your-verified-account-api-token-"
json_data = {
"api_token":API_TOKEN,
"graceid":"GW190425",
"pointings":[
{
"ra":42,
"dec":42.0,
"band":"V",
"instrumentid":"20",
"depth":"19.5",
"depth_unit":"ab_mag",
"time":"2019-05-22T12:30:59",
"pos_angle":"45.0",
"status":"completed"
},
{
"position":"POINT(42 42)",
"central_wave":6500,
"bandwidth":1200,
"wavelength_unit":"angstrom",
"instrumentid":"instrumentname1",
"depth":"5e-12",
"depth_unit":"flux_erg"
"time":"2019-05-22T12:30:59",
"status":"planned"
},
{
"position":"POINT(42 42)",
"energy_regime":[0.39,1.1],
"energy_unit":"keV",
"instrumentid":"Swift/XRT",
"depth":"19.5",
"depth_unit":"ab_mag"
"time":"2019-05-22T12:30:59",
"status":"planned"
}]
}
url = "{}/{}".format(BASE, target)
r = requests.post(url=url, json=json_data)
print(r.text)
An example of updating your already submitted planned pointings to be completed, along with requesting a DOI for the completed pointings.
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "pointings"
API_TOKEN = "-your-verified-account-api-token-"
json_data = {
"api_token":API_TOKEN,
"graceid":"GW190425",
"request_doi":True,
"creators":[
{"name":"Name1", "affiliation":"affil_1"},
{"name":"Name2", "affiliation":"affil_2"}
],
"pointings":[
{
"id":"42"
"depth":"19.5",
"depth_err":"0.1"
"time":"2019-05-22T12:33:59",
"pos_angle":"45.0",
"status":"completed"
},
{
"id":"43"
"depth":"19.3",
"depth_err":"0.2"
"time":"2019-05-22T12:35:59",
"pos_angle":"45.0",
"status":"completed"
}]
}
url = "{}/{}".format(BASE, target)
r = requests.post(url=url, json=json_data)
print(r.text)
Requesting a Batch DOI for completed pointings
Usage
/api/v0/request_doi/api/v1/request_doi
Notes
This endpoint will ideally be utilized as an end of the night routine as you are uploading your completed pointings as they are taken in real time
You will request your DOI Url from a list of completed pointings, or just a GW Event GraceID for completed pointings that do not have a DOI yet.
This endpoint will validate:
JSON Parameters
Request a DOI for your completed pointings for a GW Event
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "request_doi"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"graceid":"graceid1",
"creators":[
{"name":"Name1", "affiliation":"affil_1"},
{"name":"Name2", "affiliation":"affil_2"}
]
}
url = "{}/{}".format(BASE, TARGET)
r = requests.post(url=url, json=json_params)
print(r.text)
Request a DOI for individual completed pointing IDs
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "request_doi"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"ids":"[id1, id2, id3, ...]",
"doi_url":"my_doi_url.com"
}
url = "{}/{}".format(BASE, TARGET)
r = requests.post(url=url, json=json_params)
print(r.text)
USAGE
/api/v0/update_pointings/api/v1/update_pointings
NOTES
Parameters
An example of cancelling a list of pointings based on their ids
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "update_pointings"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"ids":[42,43,44,45],
"status":"cancelled"
}
url = "{}/{}".format(BASE, TARGET)
r = requests.post(url=url, json=json_params)
print(r.text)
USAGE
/api/v0/cancel_all/api/v1/cancel_all
NOTES
Parameters
An example of cancelling all planned instrument pointings for a given graceid
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "cancel_all"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"graceid":"TEST_EVENT",
"instrumentid":1
}
url = "{}/{}".format(BASE, TARGET)
r = requests.post(url=url, json=json_params)
print(r.text)
Usage
/api/v0/instruments/api/v1/instruments
Parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "instruments"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"type":"photometric"
}
url = "{}/{}".format(BASE, target)
r = requests.get(url=url, json=json_params)
print(r.text)
Usage
/api/v0/footprints/api/v1/footprints
NOTES
Parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "footprints"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"name":"ZTF"
}
url = "{}/{}".format(BASE, target)
r = requests.get(url=url, json=json_params)
print(r.text)
Retrieving a list of posted candidates that are associated with a GW event.
Usage
/api/v1/candidate
Notes
This endpoint is for getting a list of candidates that are associated with a GW event.
The parameters my be passed in via a json argument in the request or as URL querystring arguments (i.e. /api/v1/candidate?param1=value1...)
Parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "candidate"
API_TOKEN = "-your-verified-account-api-token-"
#get all candidates associated with GW event GW170817
json_params = {
"api_token":API_TOKEN,
"graceid":"GW170817"
}
url = "{}/{}".format(BASE, target)
r = requests.get(url=url, json=json_params)
print(r.text)
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "candidate"
API_TOKEN = "-your-verified-account-api-token-"
#get all candidates associated with candidate ids
json_params = {
"api_token":API_TOKEN,
"ids": [id1, id2, id3...]
}
url = "{}/{}".format(BASE, target)
r = requests.get(url=url, json=json_params)
print(r.text)
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "candidate"
API_TOKEN = "-your-verified-account-api-token-"
#get all candidates associated with multiple filters
json_params = {
"api_token":API_TOKEN,
"graceid": "GW170817",
"associated_galaxy_redshift_gt": 0.05,
"associated_galaxy_redshift_lt": 0.15,
"discovery_date_after": "2017-08-18T12:30:00"
}
url = "{}/{}".format(BASE, target)
r = requests.get(url=url, json=json_params)
print(r.text)
Posting transient Candidates that are potentially affiliated with a GW event.
Usage
/api/v1/candidate
Notes
This endpoint is for posting a candidate (or list of candidates) that coincides with a GW event.
JSON Parameters
*parameters required unless otherwise specified as (optional)
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "candidate"
API_TOKEN = "-your-verified-account-api-token-"
json_data = {
"api_token":"API_TOKEN",
"graceid":"graceid1",
"candidates":[
{
"ra": 24.0,
"dec": 48.0,
"candidate_name": "AT2021fxy"
"tns_name": "AT2021fxy",
"tns_url": "https://www.wis-tns.org/object/2021fxy",
"discovery_date": "2021-03-17T17:23:37.000",
"discovery_magnitude": 18.0,
"magnitude_unit": "ab_mag",
"magnitude_bandpass": "r"
},
]
}
url = "{}/{}".format(BASE, target)
r = requests.post(url=url, json=json_params)
print(r.text)
Alter your candidate records
Usage
/api/v1/candidate
Notes
This endpoint is for altering your posted candidates. You can only alter candidates associated with your API_TOKEN. You can only alter one at a time
The parameters my be passed in via a json argument in the request or as URL querystring arguments (i.e. /api/v1/candidate?param1=value1...)
Parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "candidate"
API_TOKEN = "-your-verified-account-api-token-"
#update your candidate with tns information
json_params = {
"api_token":API_TOKEN,
"id": candidate_id,
"payload": {
"tns_name": "AT2024xxx",
"tns_url": "https://www.wis-tns.org/object/2024xxx"
}
}
url = "{}/{}".format(BASE, target)
r = requests.put(url=url, json=json_params)
print(r.text)
Deleting a candidate associated with a GW event
Usage
/api/v1/candidate
Notes
This endpoint is for deleting your candidate or candidates.
The parameters my be passed in via a json argument in the request or as URL querystring arguments (i.e. /api/v1/candidate?param1=value1...)
Parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "candidate"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"id":candidate_id
}
url = "{}/{}".format(BASE, target)
r = requests.delete(url=url, json=json_params)
print(r.text)
Retrieving a list of posted galaxies that are within the GW Event contour
Usage
/api/v0/event_galaxies/api/v1/event_galaxies
Notes
This endpoint is for getting a list of galaxies the lie within the GW contour.
The parameters my be passed in via a json argument in the request or as URL querystring arguments (i.e. /api/v0/event_galaxies?param1=value1...)
Parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "event_galaxies"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"graceid":"graceid1",
"groupname":groupname1
"score_lt":0.01
}
url = "{}/{}".format(BASE, target)
r = requests.get(url=url, json=json_params)
print(r.text)
Posting a list of galaxies that are within the GW Event contour
Usage
/api/v0/event_galaxies/api/v1/event_galaxies
Notes
This endpoint is for posting a list of galaxies the lie within the GW contour. For each galaxy, it accepts position, score, rank, and name. You may also append a json list of parameters about the galaxy or your calculation.
JSON Parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "event_galaxies"
API_TOKEN = "-your-verified-account-api-token-"
json_data = {
"api_token":"API_TOKEN",
"graceid":"graceid1",
"timesent_stamp":"2019-05-22T12:33:59",
"groupname":groupname1,
"reference":"https://ui.adsabs.harvard.edu/abs/2020arXivNicePaper",
"request_doi":True,
"doi_group_id":groupID
"galaxies":[
{
"position":"POINT(24.0 41.0)",
"score":19.5,
"rank":1,
"name":"test galaxy",
"info":{
"param1":"value1",
"param2":"value2",
"param3":"value3",
"param4":"value4"
}
},
]
}
url = "{}/{}".format(BASE, target)
r = requests.post(url=url, json=json_params)
print(r.text)
Deleting a convolved galaxies list
Usage
/api/v0/event_galaxies/api/v1/event_galaxies
Notes
This endpoint is for deleting your list of convolved galaxies.
The parameters my be passed in via a json argument in the request or as URL querystring arguments (i.e. /api/v0/remove_event_galaxies?param1=value1...)
Parameters
import requests
BASE = "https://treasuremap.space/api/v1"
TARGET = "remove_event_galaxies"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"listid":"listid1"
}
url = "{}/{}".format(BASE, target)
r = requests.post(url=url, json=json_params)
print(r.text)
Usage
/api/v0/grb_moc_file/api/v1/grb_moc_file
Returns a json object for the calculated MOC map for the given instrument and graceid
the MOC files are generated using MOCpy
Parameters
import requests
import json
BASE = "https://treasuremap.space/api/v1"
TARGET = "grb_moc_file"
API_TOKEN = "-your-verified-account-api-token-"
json_params = {
"api_token":API_TOKEN,
"graceid":"S200316bj",
"instrument":"bat"
}
url = "{}/{}".format(BASE, target)
r = requests.get(url=url, json=json_params)
moc_data = json.loads(r.text)