Spaces:
Configuration error
Configuration error
| # Integraci贸n con la API de SpaceX | |
| Este documento describe la integraci贸n de Orbix con la API p煤blica de SpaceX para obtener informaci贸n sobre lanzamientos, cohetes, c谩psulas y misiones espaciales. | |
| ## Descripci贸n General | |
| La API de SpaceX proporciona acceso a datos hist贸ricos y actuales sobre las operaciones de SpaceX. Esta integraci贸n permite a Orbix: | |
| - Obtener informaci贸n sobre lanzamientos pasados y futuros | |
| - Acceder a detalles t茅cnicos de cohetes y veh铆culos espaciales | |
| - Consultar datos sobre c谩psulas y su historial de misiones | |
| - Complementar los datos orbitales de la NASA con informaci贸n comercial espacial | |
| ## Configuraci贸n | |
| La integraci贸n requiere la siguiente variable de entorno: | |
| ``` | |
| SPACEX_API_URL=https://api.spacexdata.com/v3 | |
| ``` | |
| Esta variable se puede configurar en un archivo `.env` en la ra铆z del proyecto o directamente en el entorno de ejecuci贸n. | |
| ## Uso en el C贸digo | |
| ### Inicializaci贸n del Cliente | |
| ```python | |
| from orbix.spacex_api import SpaceXApi | |
| spacex_api = SpaceXApi() | |
| ``` | |
| ### Obtener Lanzamientos | |
| ```python | |
| # Obtener todos los lanzamientos | |
| launches = spacex_api.get_launches() | |
| print(f"Total de lanzamientos: {len(launches['data'])}") | |
| # Obtener lanzamientos con paginaci贸n | |
| launches_page = spacex_api.get_launches(limit=10, offset=5) | |
| print(f"Lanzamientos (p谩gina): {len(launches_page['data'])}") | |
| ``` | |
| ### Obtener Informaci贸n de un Lanzamiento Espec铆fico | |
| ```python | |
| # Obtener informaci贸n del lanzamiento con n煤mero de vuelo 65 | |
| launch = spacex_api.get_launch(flight_number=65) | |
| print(f"Misi贸n: {launch['mission_name']}") | |
| print(f"Fecha: {launch['launch_date_utc']}") | |
| print(f"脡xito: {launch['launch_success']}") | |
| ``` | |
| ### Obtener Informaci贸n de Cohetes | |
| ```python | |
| # Obtener todos los cohetes | |
| rockets = spacex_api.get_rockets() | |
| print(f"Total de cohetes: {len(rockets['data'])}") | |
| # Obtener informaci贸n de un cohete espec铆fico | |
| rocket = spacex_api.get_rocket(rocket_id="falcon9") | |
| print(f"Nombre: {rocket['name']}") | |
| print(f"Descripci贸n: {rocket['description']}") | |
| ``` | |
| ### Obtener Informaci贸n de C谩psulas | |
| ```python | |
| # Obtener todas las c谩psulas | |
| capsules = spacex_api.get_capsules() | |
| print(f"Total de c谩psulas: {len(capsules['data'])}") | |
| # Obtener informaci贸n de una c谩psula espec铆fica | |
| capsule = spacex_api.get_capsule(capsule_serial="C101") | |
| print(f"Estado: {capsule['status']}") | |
| print(f"Tipo: {capsule['type']}") | |
| print(f"Misiones: {len(capsule['missions'])}") | |
| ``` | |
| ## Endpoints de la API | |
| La integraci贸n expone los siguientes endpoints en la API de Orbix: | |
| ### GET /spacex/launches | |
| Devuelve informaci贸n sobre lanzamientos de SpaceX. | |
| **Par谩metros:** | |
| - `limit` (opcional): N煤mero m谩ximo de lanzamientos a obtener | |
| - `offset` (opcional): N煤mero de lanzamientos a saltar | |
| **Respuesta:** | |
| ```json | |
| { | |
| "data": [ | |
| { | |
| "flight_number": 65, | |
| "mission_name": "Telstar 19V", | |
| "launch_date_utc": "2018-07-22T05:50:00.000Z", | |
| "rocket": { | |
| "rocket_id": "falcon9", | |
| "rocket_name": "Falcon 9", | |
| "rocket_type": "FT" | |
| }, | |
| "launch_site": { | |
| "site_name": "CCAFS SLC 40" | |
| }, | |
| "launch_success": true | |
| }, | |
| ... | |
| ] | |
| } | |
| ``` | |
| ### GET /spacex/launches/{flight_number} | |
| Obtiene informaci贸n sobre un lanzamiento espec铆fico de SpaceX. | |
| **Respuesta:** | |
| ```json | |
| { | |
| "flight_number": 65, | |
| "mission_name": "Telstar 19V", | |
| "launch_date_utc": "2018-07-22T05:50:00.000Z", | |
| "rocket": { | |
| "rocket_id": "falcon9", | |
| "rocket_name": "Falcon 9", | |
| "rocket_type": "FT" | |
| }, | |
| "launch_site": { | |
| "site_name": "CCAFS SLC 40" | |
| }, | |
| "launch_success": true, | |
| "details": "SSL-manufactured communications satellite intended to be placed in geostationary orbit at 63掳 West longitude, after an initial orbital raise and testing phase. The satellite is expected to have a useful life of about 15 years. Based on the SSL 1300 platform." | |
| } | |
| ``` | |
| ### GET /spacex/rockets | |
| Devuelve informaci贸n sobre cohetes de SpaceX. | |
| **Respuesta:** | |
| ```json | |
| { | |
| "data": [ | |
| { | |
| "id": "falcon9", | |
| "name": "Falcon 9", | |
| "type": "rocket", | |
| "active": true, | |
| "stages": 2, | |
| "boosters": 0, | |
| "cost_per_launch": 50000000, | |
| "success_rate_pct": 97, | |
| "first_flight": "2010-06-04", | |
| "country": "United States", | |
| "company": "SpaceX", | |
| "height": { | |
| "meters": 70, | |
| "feet": 229.6 | |
| }, | |
| "diameter": { | |
| "meters": 3.7, | |
| "feet": 12 | |
| }, | |
| "mass": { | |
| "kg": 549054, | |
| "lb": 1207920 | |
| }, | |
| "payload_weights": [...], | |
| "first_stage": {...}, | |
| "second_stage": {...}, | |
| "engines": {...}, | |
| "landing_legs": {...}, | |
| "description": "Falcon 9 is a two-stage rocket designed and manufactured by SpaceX for the reliable and safe transport of satellites and the Dragon spacecraft into orbit." | |
| }, | |
| ... | |
| ] | |
| } | |
| ``` | |
| ### GET /spacex/rockets/{rocket_id} | |
| Obtiene informaci贸n sobre un cohete espec铆fico de SpaceX. | |
| **Respuesta:** | |
| ```json | |
| { | |
| "id": "falcon9", | |
| "name": "Falcon 9", | |
| "type": "rocket", | |
| "active": true, | |
| "stages": 2, | |
| "boosters": 0, | |
| "cost_per_launch": 50000000, | |
| "success_rate_pct": 97, | |
| "first_flight": "2010-06-04", | |
| "country": "United States", | |
| "company": "SpaceX |