Skill Tracer
Skills › Scientific Agent Skills › database-lookup › sdss.md

sdss.md

132 lines · skills/database-lookup/references/sdss.md at 5f2bc03

Open on GitHub
1# SDSS SkyServer API
2

SDSS SkyServer API

Raw lines 1 to 2
3## Base URL
4
5```
6https://skyserver.sdss.org/dr18/SkyServerWS
7```
8
9Replace `dr18` with the desired data release (e.g., `dr17`, `dr16`).

Base URL

https://skyserver.sdss.org/dr18/SkyServerWS

Replace dr18 with the desired data release (e.g., dr17, dr16).

Raw lines 3 to 10
11## Authentication
13No API key required. All endpoints are public.

Authentication

No API key required. All endpoints are public.

Raw lines 11 to 14
15## Key Endpoints

Key Endpoints

Raw lines 15 to 16
17### 1. SQL Search (CasJobs-style free-form SQL)
19```
20GET /SearchTools/SqlSearch
21```
23| Parameter | Type | Description |
24|-----------|--------|-------------|
25| `cmd` | string | **Required.** SQL query against the selected SkyServer release schema; this synchronous API is separate from asynchronous CasJobs. |
26| `format` | string | `json`, `xml`, `csv`, `html`, `votable`. Default: `html`. |
28**Example — query 10 galaxies:**
29```
30https://skyserver.sdss.org/dr18/SkyServerWS/SearchTools/SqlSearch?cmd=SELECT TOP 10 objid,ra,dec,u,g,r,i,z FROM PhotoObj WHERE type=3&format=json
31```
33Type codes: `3` = galaxy, `6` = star.
35**Response (JSON, illustrative):**
36```json
38 {"Rows": [
39 {"objid": 1237645941825863680, "ra": 195.123, "dec": 2.456, "u": 22.1, "g": 20.8, "r": 19.5, "i": 19.1, "z": 18.9}
40 ]}
42```
44The response may contain a separate `SqlQuery` table alongside the result table. Select the result by `TableName` and validate its columns, rather than concatenating every `Rows` array.

1. SQL Search (CasJobs-style free-form SQL)

GET /SearchTools/SqlSearch
ParameterTypeDescription
cmdstringRequired. SQL query against the selected SkyServer release schema; this synchronous API is separate from asynchronous CasJobs.
formatstringjson, xml, csv, html, votable. Default: html.

Example — query 10 galaxies:

https://skyserver.sdss.org/dr18/SkyServerWS/SearchTools/SqlSearch?cmd=SELECT TOP 10 objid,ra,dec,u,g,r,i,z FROM PhotoObj WHERE type=3&format=json

Type codes: 3 = galaxy, 6 = star.

Response (JSON, illustrative):

[
  {"Rows": [
    {"objid": 1237645941825863680, "ra": 195.123, "dec": 2.456, "u": 22.1, "g": 20.8, "r": 19.5, "i": 19.1, "z": 18.9}
  ]}
]

The response may contain a separate SqlQuery table alongside the result table. Select the result by TableName and validate its columns, rather than concatenating every Rows array.

Raw lines 17 to 45
46### 2. Radial Search
48```
49GET /SearchTools/RadialSearch
50```
52| Parameter | Type | Description |
53|--------------|--------|-------------|
54| `ra` | float | **Required.** Right ascension (degrees). |
55| `dec` | float | **Required.** Declination (degrees). |
56| `radius` | float | Search radius in arcminutes. Default: 1. |
57| `format` | string | `json`, `xml`, `csv`. |
58| `limit` | int | Max results. |
59| `whichquery` | string | `imaging` or `spectro`, as supported by this search. |
60| `whichway` | string | Coordinate mode, e.g. `equatorial`. |
62**Example — objects within 2 arcmin of RA=180, Dec=+0.5:**
63```
64https://skyserver.sdss.org/dr18/SkyServerWS/SearchTools/RadialSearch?ra=180&dec=0.5&radius=2&whichway=equatorial&whichquery=imaging&format=json&limit=10
65```

2. Radial Search

GET /SearchTools/RadialSearch
ParameterTypeDescription
rafloatRequired. Right ascension (degrees).
decfloatRequired. Declination (degrees).
radiusfloatSearch radius in arcminutes. Default: 1.
formatstringjson, xml, csv.
limitintMax results.
whichquerystringimaging or spectro, as supported by this search.
whichwaystringCoordinate mode, e.g. equatorial.

Example — objects within 2 arcmin of RA=180, Dec=+0.5:

https://skyserver.sdss.org/dr18/SkyServerWS/SearchTools/RadialSearch?ra=180&dec=0.5&radius=2&whichway=equatorial&whichquery=imaging&format=json&limit=10
Raw lines 46 to 66
67### 3. Rectangular Search
69```
70GET /SearchTools/RectangularSearch
71```
73| Parameter | Type | Description |
74|-----------|--------|-------------|
75| `min_ra` | float | Minimum RA (degrees). |
76| `max_ra` | float | Maximum RA (degrees). |
77| `min_dec` | float | Minimum Dec (degrees). |
78| `max_dec` | float | Maximum Dec (degrees). |
79| `format` | string | `json`, `xml`, `csv`. |
80| `limit` | int | Max results. |

3. Rectangular Search

GET /SearchTools/RectangularSearch
ParameterTypeDescription
min_rafloatMinimum RA (degrees).
max_rafloatMaximum RA (degrees).
min_decfloatMinimum Dec (degrees).
max_decfloatMaximum Dec (degrees).
formatstringjson, xml, csv.
limitintMax results.
Raw lines 67 to 81
82### 4. Object Lookup by ObjID
84```
85GET /SearchTools/SqlSearch?cmd=SELECT * FROM PhotoObj WHERE objid={objid}&format=json
86```

4. Object Lookup by ObjID

GET /SearchTools/SqlSearch?cmd=SELECT * FROM PhotoObj WHERE objid={objid}&format=json
Raw lines 82 to 87
88### 5. Spectra Search by Plate-MJD-Fiber
90```
91GET /SearchTools/SqlSearch?cmd=SELECT * FROM SpecObj WHERE plate={plate} AND mjd={mjd} AND fiberid={fiberid}&format=json
92```

5. Spectra Search by Plate-MJD-Fiber

GET /SearchTools/SqlSearch?cmd=SELECT * FROM SpecObj WHERE plate={plate} AND mjd={mjd} AND fiberid={fiberid}&format=json
Raw lines 88 to 93
94### 6. Image Cutout Service
96```
97GET /ImgCutout/getjpeg
98```
100| Parameter | Type | Description |
101|-----------|--------|-------------|
102| `ra` | float | **Required.** RA (degrees). |
103| `dec` | float | **Required.** Dec (degrees). |
104| `scale` | float | Arcsec/pixel. Default: 0.396127. |
105| `width` | int | Image width in pixels. Default: 512. |
106| `height` | int | Image height in pixels. Default: 512. |
108**Example:**
109```
110https://skyserver.sdss.org/dr18/SkyServerWS/ImgCutout/getjpeg?ra=180.0&dec=0.5&scale=0.4&width=256&height=256
111```
113Returns JPEG image data.

6. Image Cutout Service

GET /ImgCutout/getjpeg
ParameterTypeDescription
rafloatRequired. RA (degrees).
decfloatRequired. Dec (degrees).
scalefloatArcsec/pixel. Default: 0.396127.
widthintImage width in pixels. Default: 512.
heightintImage height in pixels. Default: 512.

Example:

https://skyserver.sdss.org/dr18/SkyServerWS/ImgCutout/getjpeg?ra=180.0&dec=0.5&scale=0.4&width=256&height=256

Returns JPEG image data.

Raw lines 94 to 114
115### 7. Spectrum Plot/Data
117Spectrum FITS files are on the [Science Archive Server](https://data.sdss.org/sas/dr18/). Paths depend on instrument, data release, reduction pipeline and plate/fiber formatting. Obtain the actual file URL from the selected release's object page or data model; do not construct one universal `spectro/sdss/redux` path for every survey.

7. Spectrum Plot/Data

Spectrum FITS files are on the Science Archive Server. Paths depend on instrument, data release, reduction pipeline and plate/fiber formatting. Obtain the actual file URL from the selected release's object page or data model; do not construct one universal spectro/sdss/redux path for every survey.

Raw lines 115 to 118
119## Important SQL Tables
121| Table | Description |
122|-------------|-------------|
123| `PhotoObj` | Photometric measurements (positions, magnitudes). |
124| `SpecObj` | Spectroscopic measurements (redshifts, classifications). |
125| `Galaxy` | View of PhotoObj filtered to galaxies. |
126| `Star` | View of PhotoObj filtered to stars. |
128URL-encode `cmd` (for example `curl --get --data-urlencode "cmd=SELECT TOP 10 ..."`). Preserve 64-bit object IDs as integers or strings, not floating-point numbers.

Important SQL Tables

TableDescription
PhotoObjPhotometric measurements (positions, magnitudes).
SpecObjSpectroscopic measurements (redshifts, classifications).
GalaxyView of PhotoObj filtered to galaxies.
StarView of PhotoObj filtered to stars.

URL-encode cmd (for example curl --get --data-urlencode "cmd=SELECT TOP 10 ..."). Preserve 64-bit object IDs as integers or strings, not floating-point numbers.

Raw lines 119 to 129
130## Rate Limits
132No formal documented rate limits. Queries returning very large result sets may time out. Use `TOP N` in SQL queries to limit results. For bulk data, use CasJobs (https://skyserver.sdss.org/CasJobs/) with a free account.

Rate Limits

No formal documented rate limits. Queries returning very large result sets may time out. Use TOP N in SQL queries to limit results. For bulk data, use CasJobs (https://skyserver.sdss.org/CasJobs/) with a free account.

Raw lines 130 to 132