# API Reference


## Data


Player search and per-player career queries against the MLB Stats API.


[data.refresh_cache()](data.refresh_cache.md#baseball_trajectory.data.refresh_cache)  
Clear the in-memory cache; the next call re-fetches from MLB Stats API.

[data.get_player_career_totals()](data.get_player_career_totals.md#baseball_trajectory.data.get_player_career_totals)  
Return a career-totals dict for a player, suitable for similarity scoring.

[data.search_player()](data.search_player.md#baseball_trajectory.data.search_player)  
Substring-match player names against cached MLB rosters.

[data.get_batting_career()](data.get_batting_career.md#baseball_trajectory.data.get_batting_career)  
Return a per-season batting career DataFrame for a MLB player ID string.

[data.get_pitching_career()](data.get_pitching_career.md#baseball_trajectory.data.get_pitching_career)  
Return a per-season pitching career DataFrame for a MLB player ID string.


## Model


Weighted quadratic aging-curve fit and career summaries.


[model.is_lower_better()](model.is_lower_better.md#baseball_trajectory.model.is_lower_better)  

[model.fit_player_curve()](model.fit_player_curve.md#baseball_trajectory.model.fit_player_curve)  

[model.fit_aging_curve()](model.fit_aging_curve.md#baseball_trajectory.model.fit_aging_curve)  
Fit a weighted quadratic in centered form.

[model.predict_curve()](model.predict_curve.md#baseball_trajectory.model.predict_curve)  

[model.summarize_career()](model.summarize_career.md#baseball_trajectory.model.summarize_career)  

[model.BATTING_METRICS](model.BATTING_METRICS.md#baseball_trajectory.model.BATTING_METRICS)  

[model.PITCHING_METRICS](model.PITCHING_METRICS.md#baseball_trajectory.model.PITCHING_METRICS)  


## Similarity


Bill James similarity scores.


[similarity.position_value()](similarity.position_value.md#baseball_trajectory.similarity.position_value)  
Return the Bill James position value for an MLB position abbreviation.

[similarity.similarity_score()](similarity.similarity_score.md#baseball_trajectory.similarity.similarity_score)  
Bill James similarity score between two career-totals dicts.

[similarity.find_similar_players()](similarity.find_similar_players.md#baseball_trajectory.similarity.find_similar_players)  
Rank candidate players by similarity to `target`.

[similarity.POSITION_VALUE](similarity.POSITION_VALUE.md#baseball_trajectory.similarity.POSITION_VALUE)  


## Plots


Matplotlib trajectory charts.


[plots.predict_curve()](plots.predict_curve.md#baseball_trajectory.plots.predict_curve)  

[plots.plot_trajectory()](plots.plot_trajectory.md#baseball_trajectory.plots.plot_trajectory)  
Scatter + fitted-curve plot.

[plots.plot_empty()](plots.plot_empty.md#baseball_trajectory.plots.plot_empty)  

[plots.plot_trajectories_facet()](plots.plot_trajectories_facet.md#baseball_trajectory.plots.plot_trajectories_facet)  
Small-multiples plot of multiple players' aging curves.

[plots.plot_peak_vs_curvature()](plots.plot_peak_vs_curvature.md#baseball_trajectory.plots.plot_peak_vs_curvature)  
Scatter of fitted peak age vs curvature, with player labels.
