npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

uber_direct_api_integration

v0.1.2-beta

Published

An npm package for integrating Uber Direct API with ease.

Readme

Integración de la API de Uber Direct

Este paquete npm proporciona una interfaz fácil de usar para integrarse con la API de Uber Direct. Incluye funcionalidades para crear entregas, obtener cotizaciones, cancelar entregas y más. Esta guía te guiará a través de la configuración y el uso del paquete.

Notas

  • Para mayor detalle en el proceso de integración, dirígete a: [https://developer.uber.com/docs/deliveries/overview]
  • Debes tener una cuenta de Uber en [https://direct.uber.com/] para obtener tus credenciales.
  • Para la instalación de webhooks, sigue la guía en: [https://developer.uber.com/docs/deliveries/guides/webhooks]
  • Para una referencia de como sería una integración completa de esta API visitar [https://gitlab.com/Cristobal-Bravo-Portafolio/uber-direct-api-integration/-/tree/main/src?ref_type=heads].También en constante revisión y mejora.

Pendientes de Implementación:

  • Integración con medios de pago.
  • Pruebas en ambiente sandbox.
  • Testeo y revisión.
  • Implementación de más funcionalidades útiles para este caso, de ser posible.
  • Mallor detalle y guía en la documentación.

Tabla de Contenido

  1. Instalación
  2. Configuración
  3. Autenticación
  4. Uso
  5. Referencia de la API
  6. Tipos
  7. Manejo de Errores
  8. Registro
  9. Contribución
  10. Licencia

Instalación

Para instalar el paquete, ejecuta:

npm install uber_direct_api_integration@beta

Configuración

Antes de usar el paquete, necesitas configurar tus credenciales de la API de Uber Direct:

CUSTOMER_ID: Tu ID de Cliente de Uber Direct.

CLIENT_ID: Tu ID de Cliente de Uber Direct.

CLIENT_SECRET: Tu Clave Secreta de Cliente de Uber Direct.

Puedes proporcionar estas opciones como un parámetro config en cada método. Por ejemplo:

import { createDelivery } from 'uber_direct_api_integration'; async function main() { const delivery = await createDelivery({ pickup_name: 'John Doe', pickup_address: JSON.stringify({ street_address: '123 Main St', city: 'Anytown', state: 'CA', zip_code: '12345', }), pickup_phone_number: '555-123-4567', dropoff_name: 'Jane Smith', dropoff_address: JSON.stringify({ street_address: '456 Oak Ave', city: 'Otherville', state: 'NY', zip_code: '67890', }), dropoff_phone_number: '555-987-6543', manifest_items: [{ name: 'Item 1', quantity: 1 }], }, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', });

console.log("delivery: ", delivery)

}

main()

Autenticación

Este paquete maneja automáticamente la autenticación con la API de Uber Direct. No necesitas administrar los tokens manualmente. La función getAccessToken se usa internamente para obtener tokens de acceso basados en las credenciales proporcionadas.

Uso Aquí hay ejemplos de cómo usar las diferentes funcionalidades proporcionadas por el paquete.

Crear Cotización Usa la función createQuote para obtener una cotización de entrega:

import { createQuote } from 'uber_direct_api_integration';

async function main() { const quote = await createQuote( { pickup_address: JSON.stringify({ street_address: '123 Main St', city: 'Anytown', state: 'CA', zip_code: '12345', }), dropoff_address: JSON.stringify({ street_address: '456 Oak Ave', city: 'Otherville', state: 'NY', zip_code: '67890', }), }, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', }, ); console.log('quote', quote); } main();

Crear Entrega

Usa la función createDelivery para crear una nueva entrega:

import { createDelivery } from 'uber_direct_api_integration';

async function main() { const delivery = await createDelivery( { pickup_name: 'John Doe', pickup_address: JSON.stringify({ street_address: '123 Main St', city: 'Anytown', state: 'CA', zip_code: '12345', }), pickup_phone_number: '555-123-4567', dropoff_name: 'Jane Smith', dropoff_address: JSON.stringify({ street_address: '456 Oak Ave', city: 'Otherville', state: 'NY', zip_code: '67890', }), dropoff_phone_number: '555-987-6543', manifest_items: [{ name: 'Item 1', quantity: 1 }], }, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', }, ); console.log('delivery', delivery); } main();

Cancelar Entrega

Usa la función cancelDelivery para cancelar una entrega:

import { cancelDelivery } from 'uber_direct_api_integration';

async function main() { const deliveryId = 'del_xxxxxx'; // Reemplaza con el ID de entrega real const result = await cancelDelivery( deliveryId, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', }, ); console.log('respuesta de cancelar entrega', result); } main();

Buscar Tienda

Usa la función findStore para buscar tiendas cerca de una ubicación específica:

import { findStore } from 'uber_direct_api_integration';

async function main() { const latitude = 34.0522; // Ejemplo de latitud const longitude = -118.2437; // Ejemplo de longitud const stores = await findStore( latitude, longitude, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', }, ); console.log('buscar tiendas', stores); } main();

Obtener Entrega

Usa la función getDelivery para recuperar los detalles de una entrega:

import { getDelivery } from 'uber_direct_api_integration';

async function main() { const deliveryId = 'del_xxxxxx'; // Reemplaza con el ID de entrega real const deliveryDetails = await getDelivery( deliveryId, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', }, ); console.log('detalles de la entrega', deliveryDetails); } main();

Listar Entregas

Usa la función listDeliveries para listar todas las entregas:

import { listDeliveries } from 'uber_direct_api_integration';

async function main() { const deliveries = await listDeliveries( {}, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', }, ); console.log('entregas', deliveries); } main();

También puedes proporcionar filtros, límite y desplazamiento para listar entregas:

import { listDeliveries } from 'uber_direct_api_integration';

async function main() { const deliveries = await listDeliveries( { filter: 'status=completed', // Ejemplo de filtro limit: 10, // Ejemplo de límite offset: 0, // Ejemplo de desplazamiento }, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', }, ); console.log('entregas', deliveries); } main();

Obtener Prueba de Entrega

Usa la función getProofOfDelivery para obtener los detalles de la prueba de entrega:

import { getProofOfDelivery } from 'uber_direct_api_integration'; async function main() { const deliveryId = 'del_xxxxxx'; // Reemplaza con el ID de entrega real const proof = await getProofOfDelivery( deliveryId, { waypoint: 'dropoff', type: 'picture', }, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', }, ); console.log('prueba', proof); } main();

Actualizar Entrega

Usa la función updateDelivery para actualizar los detalles de una entrega:

import { updateDelivery } from 'uber_direct_api_integration'; async function main() { const deliveryId = 'del_xxxxxx'; // Reemplaza con el ID de entrega real const updateData = { dropoff_notes: 'Dejar en la puerta principal', }; const updatedDelivery = await updateDelivery( deliveryId, updateData, { customerId: 'tu_customer_id', clientId: 'tu_client_id', clientSecret: 'tu_client_secret', }, ); console.log('entrega actualizada', updatedDelivery); } main();

Referencia de la API

Autenticación

La función getAccessToken se utiliza internamente para obtener un token de acceso. Los tokens se almacenan en caché por ejecución, por lo que solo se solicitan una vez por cada ejecución.

Opciones de Configuración Debes pasar una opción config a cada método de este paquete con los siguientes valores de configuración:

customerId: Tu ID de Cliente de Uber Direct como string.

clientId: Tu ID de Cliente de Uber Direct como string.

clientSecret: Tu Clave Secreta de Cliente de Uber Direct como string.

DeliverySotre

El paquete incluye un almacenamiento en memoria para los detalles de la entrega. Este almacenamiento se usa para fusionar los datos de entrega recibidos de la API con la información almacenada, para acceder a los datos de recogida y entrega. Las siguientes funciones administran los detalles de la entrega:

storeDeliveryDetails(deliveryId, details): Almacena los detalles de la entrega en memoria.

hasStoredDeliveryDetails(deliveryId): Verifica si los detalles de la entrega están almacenados.

getStoredDeliveryDetails(deliveryId): Recupera los detalles de la entrega almacenados.

Endpoints

Los siguientes endpoints están disponibles en el paquete:

createQuote(reqData, config): Crea una cotización de entrega.

createDelivery(reqData, config): Crea una nueva entrega.

cancelDelivery(deliveryId, config): Cancela una entrega específica.

findStore(latitude, longitude, config): Busca tiendas cerca de las coordenadas proporcionadas.

getDelivery(deliveryId, config): Obtiene los detalles de una entrega específica.

listDeliveries(reqData, config): Lista las entregas con filtros opcionales.

getProofOfDelivery(deliveryId, requestData, config): Obtiene la prueba de entrega.

updateDelivery(deliveryId, updateData, config): Actualiza la información de la entrega.

Tipos

DeliveryAddresses interface DeliveryAddresses { pickup_address: any; dropoff_address: any; pickup_name: string; dropoff_name: string; }

UpdateDeliveryRequest

interface UpdateDeliveryRequest { dropoff_notes?: string; dropoff_verification?: any; manifest_reference?: string; pickup_notes?: string; pickup_verification?: any; tip_by_customer?: number; dropoff_latitude?: number; dropoff_longitude?: number; pickup_ready_dt?: string; pickup_deadline_dt?: string; dropoff_ready_dt?: string; dropoff_deadline_dt?: string; }

Manejo de Errores

Todas las funciones de este paquete lanzan un error si la solicitud a la API falla, con un mensaje informativo y el código de estado correspondiente si está disponible.

Registro

El paquete incluye registro en consola para varias etapas del proceso, incluyendo detalles de solicitud, cuerpos de respuesta y errores.

Licencia

Este proyecto está licenciado bajo la Licencia MIT.