API Reference

Complete documentation for Flask backend endpoints

Back to Metrology Suite

Overview

The thin-film metrology system provides a REST API for spectral reflectometry calculations and analysis. All endpoints accept JSON requests and return JSON responses. Base URL for local development: http://localhost:5000

Endpoints

POST /api/simulate_spectrum

Simulates reflectance spectrum for a thin-film stack using transfer matrix method.

Request Body

ParameterTypeRequiredDescription
film_materialstringYesFilm material code (sio2, si3n4, tio2, etc.)
thickness_nmnumberYesFilm thickness in nanometers
substratestringYesSubstrate material (silicon, glass, etc.)
wavelength_minnumberNoMinimum wavelength (nm), default: 400
wavelength_maxnumberNoMaximum wavelength (nm), default: 800

Example Request

{ "film_material": "sio2", "thickness_nm": 250, "substrate": "silicon", "wavelength_min": 400, "wavelength_max": 900 }

Response (200 OK)

{ "wavelengths": [400, 405, 410, ...], "reflectances": [0.234, 0.241, 0.248, ...], "film_index": 1.46, "status": "success" }
POST /api/extract_thickness

Extracts film thickness from measured reflectance spectrum using optimization algorithms.

Request Body

ParameterTypeRequiredDescription
wavelengthsarrayYesArray of wavelength values (nm)
reflectancesarrayYesArray of measured reflectance values
film_materialstringYesFilm material code
algorithmstringNo"lm" or "de", default: "lm"
initial_guessnumberNoInitial thickness guess (nm)
boundsarrayNo[min, max] thickness bounds

Response (200 OK)

{ "thickness_nm": 251.3, "uncertainty_nm": 0.8, "chi_squared": 3.2e-5, "iterations": 12, "status": "converged" }
POST /api/fft_analysis

Performs FFT-based thickness estimation from spectral data.

Request Body

ParameterTypeRequiredDescription
wavelengthsarrayYesArray of wavelength values
reflectancesarrayYesArray of reflectance values
film_materialstringYesFilm material code
windowstringNoWindow function: "hann", "hamming", "blackman"
detrendbooleanNoApply detrending, default: true

Response (200 OK)

{ "thickness_nm": 248.5, "confidence": 8.3, "snr_db": 18.4, "peak_frequency": 497.0, "fft_power": [array of power values], "status": "success" }
POST /api/thickness_map

Generates 2D thickness map from spatial scan data.

Request Body

ParameterTypeRequiredDescription
scan_patternstringYes"raster", "snake", "spiral", "random"
resolution_xnumberYesNumber of points in X direction
resolution_ynumberYesNumber of points in Y direction
film_materialstringYesFilm material code
sample_size_mmarrayNo[width, height] in mm

Response (200 OK)

{ "thickness_map": [[2D array of thickness values]], "x_positions": [array], "y_positions": [array], "statistics": { "mean_nm": 251.5, "std_nm": 3.2, "min_nm": 245.2, "max_nm": 258.7, "uniformity_percent": 2.7 }, "scan_time_seconds": 44.0, "status": "completed" }
GET /api/materials

Returns list of available materials and their optical properties.

Response (200 OK)

{ "materials": { "sio2": { "name": "Silicon Dioxide", "formula": "SiOβ‚‚", "dispersion": { "type": "cauchy", "A": 1.4508, "B": 0.0036 }, "refractive_index_550nm": 1.46 }, "si3n4": {...}, ... } }
POST /api/calculate_reflectance

Low-level reflectance calculation for single wavelength.

Request Body

ParameterTypeRequiredDescription
wavelength_nmnumberYesSingle wavelength value
thickness_nmnumberYesFilm thickness
film_materialstringYesFilm material code
substratestringYesSubstrate material

Response (200 OK)

{ "reflectance": 0.234, "film_index": 1.4596, "substrate_index": 3.48, "phase_shift": 6.283 }

Error Responses

Status CodeDescriptionExample
400 Bad Request {"error": "Missing required parameter: film_material"}
404 Not Found {"error": "Material 'unknown' not found in database"}
500 Internal Server Error {"error": "Fitting algorithm failed to converge"}

Rate Limiting

For production deployment, implement rate limiting: