API Reference¶
Client¶
MPCClient ¶
Bases: IdentifierMixin, ObscodesMixin, SubmissionStatusMixin, CNDMixin, MPECsMixin, ObservationsMixin, NEOCPMixin, OrbitsMixin, ActionCodesMixin, SubmissionMixin, BaseAPI
Python client for the Minor Planet Center REST APIs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str or None
|
Reserved for future use. Defaults to |
None
|
timeout
|
int
|
Request timeout in seconds. Defaults to 60. |
60
|
Examples:
>>> from mpc_client import MPCClient
>>> mpc = MPCClient()
>>> mpc.identify("Ceres")
{'Ceres': {'permid': '1', ...}}
Source code in src/mpc_client/client.py
submit_xml ¶
submit_xml(source: Union[str, bytes], *, ack: str, ac2: str, obj_type: Optional[str] = None, test: bool = True) -> SubmissionResponse
Submit an ADES XML file of observations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str or bytes
|
Path to an XML file or the raw XML bytes/string. |
required |
ack
|
str
|
Acknowledgement message (required by the MPC). |
required |
ac2
|
str
|
Email address for notifications (required). |
required |
obj_type
|
str or None
|
Optional object-type flag (e.g. |
None
|
test
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
SubmissionResponse
|
Response with |
Source code in src/mpc_client/_submission.py
submit_psv ¶
submit_psv(source: Union[str, bytes], *, ack: str, ac2: str, obj_type: Optional[str] = None, test: bool = True) -> SubmissionResponse
Submit an ADES PSV file of observations.
Parameters are identical to :meth:submit_xml.
Source code in src/mpc_client/_submission.py
request_action_code ¶
Request retrieval of an action code for a submission.
The action code will be emailed to the original submitter's address — it is not returned in the API response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
Submission identifier (submission ID, tracklet ID, track ID, or submission block ID). |
required |
Returns:
| Type | Description |
|---|---|
ActionCodeResponse
|
API response confirming the request. |
Source code in src/mpc_client/_action_codes.py
get_orbit ¶
Retrieve orbital elements for an object.
Returns an :class:~mpc_client.models.OrbitalElements instance, or
None if the object was not found (the API returns an empty list
rather than a 404 for unknown designations).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desig
|
str
|
Object designation (name, number, or provisional designation). |
required |
Returns:
| Type | Description |
|---|---|
OrbitalElements or None
|
The orbital elements, or |
Source code in src/mpc_client/_orbits.py
get_orbit_raw ¶
Retrieve the full, unprocessed API response for an orbit query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desig
|
str
|
Object designation. |
required |
Returns:
| Type | Description |
|---|---|
list
|
Raw JSON response from the API. |
Source code in src/mpc_client/_orbits.py
get_neocp_observations ¶
get_neocp_observations(trksub: str, *, output_format: Union[str, List[str]] = 'XML', ades_version: str = '2022') -> ObservationsResult
Retrieve observations for an object currently on the NEOCP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trksub
|
str
|
Tracklet identifier (temporary designation) on the NEOCP. |
required |
output_format
|
str or list of str
|
One or more of |
'XML'
|
ades_version
|
str
|
|
'2022'
|
Returns:
| Type | Description |
|---|---|
ObservationsResult
|
Response with attributes for each requested format. |
Source code in src/mpc_client/_neocp.py
get_neocp_observations_df ¶
Retrieve NEOCP observations as a pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trksub
|
str
|
Tracklet identifier on the NEOCP. |
required |
fmt
|
str
|
|
'ADES_DF'
|
ades_version
|
str
|
|
'2022'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in src/mpc_client/_neocp.py
get_observations ¶
get_observations(desig: str, *, output_format: Union[str, List[str]] = 'XML', ades_version: str = '2022') -> ObservationsResult
Retrieve observations for a solar-system object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desig
|
str
|
Object designation (name, number, or provisional designation). |
required |
output_format
|
str or list of str
|
One or more of |
'XML'
|
ades_version
|
str
|
ADES format version: |
'2022'
|
Returns:
| Type | Description |
|---|---|
ObservationsResult
|
Response with attributes for each requested format. |
Source code in src/mpc_client/_observations.py
get_observations_df ¶
Retrieve observations as a pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desig
|
str
|
Object designation. |
required |
fmt
|
str
|
|
'ADES_DF'
|
ades_version
|
str
|
|
'2022'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in src/mpc_client/_observations.py
get_mpecs ¶
Search for Minor Planet Electronic Circulars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_terms
|
str or list of str
|
Object designation(s), MPEC name(s), or wildcard pattern(s)
(using |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Mapping of each search term to a list of
:class: |
Source code in src/mpc_client/_mpecs.py
get_discovery_mpec ¶
Get the discovery MPEC for an object (the earliest by publication date).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
designation
|
str
|
Object designation. |
required |
Returns:
| Type | Description |
|---|---|
MPEC or None
|
The earliest :class: |
Source code in src/mpc_client/_mpecs.py
check_near_duplicates ¶
check_near_duplicates(obs: Union[str, List[str]], *, time_separation_s: float = 60, angle_separation_arcsec: float = 5, omit_separation: bool = False) -> Dict[str, List[NearDuplicateMatch]]
Check whether observations have near-duplicates in the MPC database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
str or list of str
|
Observation(s) in MPC 80-column (or 160-column) format. |
required |
time_separation_s
|
float
|
Temporal threshold in seconds (0–60). Default 60. |
60
|
angle_separation_arcsec
|
float
|
Spatial threshold in arcseconds (0–10). Default 5. |
5
|
omit_separation
|
bool
|
If True, omit separation values from results. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Mapping of each input observation to its list of
:class: |
Source code in src/mpc_client/_cnd.py
count_near_duplicates ¶
Count near-duplicates for each input observation.
Accepts the same keyword arguments as :meth:check_near_duplicates.
Returns:
| Type | Description |
|---|---|
dict
|
Mapping of each input observation to the number of matches found. |
Source code in src/mpc_client/_cnd.py
get_submission_status ¶
Check the acceptance status of an MPC observation submission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
submission_id
|
str
|
Submission ID in the format |
required |
Returns:
| Type | Description |
|---|---|
SubmissionStatus
|
Status with |
Source code in src/mpc_client/_submission_status.py
get_observatory ¶
Get information about a specific observatory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obscode
|
str
|
Three-character observatory code (e.g. |
required |
Returns:
| Type | Description |
|---|---|
Observatory
|
Observatory data including name, longitude, parallax constants. |
Source code in src/mpc_client/_obscodes.py
get_all_observatories ¶
Get information about all registered observatories.
Returns:
| Type | Description |
|---|---|
dict
|
Mapping of observatory code to :class: |
Source code in src/mpc_client/_obscodes.py
get_all_observatories_df ¶
Get all observatories as a pandas DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame indexed by observatory code. |
Source code in src/mpc_client/_obscodes.py
search_observatories ¶
Search observatories by name (case-insensitive substring match).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name_pattern
|
str
|
Substring to search for in observatory names. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Matching observatories. |
Source code in src/mpc_client/_obscodes.py
identify ¶
Look up designation information for one or more objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
str or list of str
|
Object identifier(s) — names, numbers, or provisional designations. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Mapping of each queried identifier to its
:class: |
Source code in src/mpc_client/_identifier.py
Exceptions¶
MPCAPIError ¶
Bases: Exception
Base exception for all MPC API errors.
MPCRequestError ¶
Bases: MPCAPIError
Network or timeout failure when making a request.
MPCResponseError ¶
Bases: MPCAPIError
Non-2xx HTTP status code returned by the API.
Source code in src/mpc_client/exceptions.py
MPCNotFoundError ¶
Bases: MPCResponseError
HTTP 404 — requested resource was not found.
Source code in src/mpc_client/exceptions.py
MPCValidationError ¶
Bases: MPCAPIError
Local input validation failure before sending a request.
Response Models¶
OrbitalElements ¶
Bases: BaseModel
Orbital elements for a solar-system object (mpc_orb structure).
All fields beyond the declared ones are preserved and accessible via attribute access.
COM
class-attribute
instance-attribute
¶
Cometarian (perihelion-based) orbital elements.
CAR
class-attribute
instance-attribute
¶
Cartesian state-vector elements.
designation_data
class-attribute
instance-attribute
¶
Designation and identification metadata.
magnitude_data
class-attribute
instance-attribute
¶
Absolute magnitude and slope parameter.
OrbitalCoefficients ¶
Bases: BaseModel
A set of orbital coefficients (cometarian or Cartesian).
coefficient_names
instance-attribute
¶
Names of the orbital elements in order
(cometarian: ['q', 'e', 'i', 'node', 'argperi', 'tp'];
Cartesian: ['x', 'y', 'z', 'vx', 'vy', 'vz']).
coefficient_values
instance-attribute
¶
Fitted values for each orbital element in SI/au/deg units.
coefficient_uncertainties
class-attribute
instance-attribute
¶
1-σ uncertainties on each element, if available.
DesignationData ¶
Bases: BaseModel
Designation metadata embedded in an orbital elements record.
permid
class-attribute
instance-attribute
¶
Permanent object number as a string (e.g. "1" for Ceres).
packed_primary_provisional_designation
class-attribute
instance-attribute
¶
Packed MPC provisional designation (e.g. "I01A00A").
unpacked_primary_provisional_designation
class-attribute
instance-attribute
¶
Human-readable provisional designation (e.g. "A801 AA").
MagnitudeData ¶
DesignationInfo ¶
Bases: BaseModel
Designation look-up result for a single queried identifier.
found
class-attribute
instance-attribute
¶
1 if the identifier was resolved, 0 otherwise.
permid
class-attribute
instance-attribute
¶
Permanent identifier (object number as a string), if assigned.
name
class-attribute
instance-attribute
¶
IAU-approved name, if assigned.
iau_designation
class-attribute
instance-attribute
¶
IAU designation string (e.g. "(90377)" for numbered objects).
object_type
class-attribute
instance-attribute
¶
Two-element list [type_name (str), type_code (int)] classifying the object.
Observatory ¶
Bases: BaseModel
Observatory information from the MPC observatory-codes list.
obscode
class-attribute
instance-attribute
¶
Three-character MPC observatory code (e.g. "500", "F51").
longitude
class-attribute
instance-attribute
¶
East longitude in degrees.
rhocosphi
class-attribute
instance-attribute
¶
Parallax constant ρ cos φ′.
rhosinphi
class-attribute
instance-attribute
¶
Parallax constant ρ sin φ′.
observations_type
class-attribute
instance-attribute
¶
Observation type (e.g. "optical", "radar").
MPEC ¶
Bases: BaseModel
A single Minor Planet Electronic Circular entry.
ObservationsResult ¶
Bases: BaseModel
Observations returned by the MPC Observations API.
Which fields are populated depends on the output_format requested.
XML
class-attribute
instance-attribute
¶
ADES XML string (when "XML" format is requested).
OBS80
class-attribute
instance-attribute
¶
Observations in MPC 80-column format (when "OBS80" is requested).
ADES_DF
class-attribute
instance-attribute
¶
ADES observations as a list of dicts (when "ADES_DF" is requested).
OBS_DF
class-attribute
instance-attribute
¶
Observations as a list of dicts (when "OBS_DF" is requested).
NearDuplicateMatch ¶
Bases: BaseModel
A single near-duplicate match returned by the CND API.
SubmissionResponse ¶
ActionCodeResponse ¶
SubmissionStatus ¶
Bases: BaseModel
Acceptance status of an MPC observation submission.
accepted
instance-attribute
¶
Whether the submission was accepted into the MPC pipeline.
pipeline_entry_time
class-attribute
instance-attribute
¶
ISO timestamp of pipeline ingestion, or None if not yet ingested.
fault_events
class-attribute
instance-attribute
¶
List of fault events describing rejection reasons, if any.
FaultEvent ¶
Bases: BaseModel
A single fault event recorded by the MPC observation pipeline.