apiempresas 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -146,6 +146,31 @@ app.post('/apiempresas', express.raw({ type: 'application/json' }), (req, res) =
146
146
 
147
147
  Si tu servidor no responde 2xx, se reintenta a los 1 min, 5 min, 30 min, 2 h y 6 h.
148
148
 
149
+ ### 8. Licitaciones públicas abiertas (Business) — 1 consulta
150
+
151
+ ```typescript
152
+ // Concursos en plazo: Plataforma de Contratación del Sector Público y plataformas autonómicas
153
+ const { tenders, pagination } = await api.tenders.list({ q: 'limpieza', province: 'Madrid', type: 'services' });
154
+ console.log(pagination.total, tenders[0].title, tenders[0].deadline, tenders[0].url);
155
+
156
+ // Las parecidas a los contratos que una empresa ya ha ganado (ordenadas por match_score)
157
+ const forCompany = await api.tenders.forCompany('A82018474');
158
+ ```
159
+
160
+ ### 9. Listas de sanciones (Business) — 1 consulta
161
+
162
+ ```typescript
163
+ // Una empresa y sus administradores vigentes, en las listas de la UE, la ONU y OFAC
164
+ const r = await api.sanctions.screen({ cif: 'A46103834' });
165
+ console.log(r.summary.result); // 'clear' | 'possible_match' | 'match'
166
+
167
+ // Un nombre suelto
168
+ const p = await api.sanctions.screen({ name: 'Vladimir Putin', type: 'person' });
169
+ // Cada coincidencia trae level (strong | possible), list, programs, countries y birth_dates para confirmarla
170
+ ```
171
+
172
+ En `companies.verify()` con Business, el resultado incluye `checks.sanctions`.
173
+
149
174
  ## Entorno de Pruebas (Sandbox)
150
175
 
151
176
  Para probar la integración sin consumir saldo, apunta a la URL del Sandbox con tu misma API Key. Devuelve datos simulados: `A15075062` (empresa encontrada) y `B00000000` (no encontrada).
@@ -2,9 +2,11 @@ import { ApiEmpresasOptions, UsageData, CatalogData } from './types';
2
2
  import { Companies } from './resources/Companies';
3
3
  import { Watchlist } from './resources/Watchlist';
4
4
  import { Webhooks } from './resources/Webhooks';
5
+ import { Tenders } from './resources/Tenders';
6
+ import { Sanctions } from './resources/Sanctions';
5
7
  import { verifyWebhookSignature, constructWebhookEvent } from './webhooks/signature';
6
8
  /** Versión del SDK, enviada en el User-Agent. */
7
- export declare const SDK_VERSION = "1.3.0";
9
+ export declare const SDK_VERSION = "1.4.0";
8
10
  export declare class ApiEmpresas {
9
11
  private apiKey;
10
12
  private baseURL;
@@ -14,6 +16,10 @@ export declare class ApiEmpresas {
14
16
  watchlist: Watchlist;
15
17
  /** (Business) Webhooks. */
16
18
  webhooks: Webhooks;
19
+ /** (Business) Licitaciones públicas abiertas. */
20
+ tenders: Tenders;
21
+ /** (Business) Listas de sanciones (UE, ONU, OFAC). */
22
+ sanctions: Sanctions;
17
23
  /** Atajos: ApiEmpresas.verifyWebhookSignature(...) sin instanciar el cliente. */
18
24
  static verifyWebhookSignature: typeof verifyWebhookSignature;
19
25
  static constructWebhookEvent: typeof constructWebhookEvent;
@@ -5,9 +5,11 @@ const ApiError_1 = require("./errors/ApiError");
5
5
  const Companies_1 = require("./resources/Companies");
6
6
  const Watchlist_1 = require("./resources/Watchlist");
7
7
  const Webhooks_1 = require("./resources/Webhooks");
8
+ const Tenders_1 = require("./resources/Tenders");
9
+ const Sanctions_1 = require("./resources/Sanctions");
8
10
  const signature_1 = require("./webhooks/signature");
9
11
  /** Versión del SDK, enviada en el User-Agent. */
10
- exports.SDK_VERSION = '1.3.0';
12
+ exports.SDK_VERSION = '1.4.0';
11
13
  /**
12
14
  * Mensaje legible del cuerpo de error. Según el error, la API lo pone en
13
15
  * message, detail, error (texto) o messages (errores de validación).
@@ -37,6 +39,10 @@ class ApiEmpresas {
37
39
  watchlist;
38
40
  /** (Business) Webhooks. */
39
41
  webhooks;
42
+ /** (Business) Licitaciones públicas abiertas. */
43
+ tenders;
44
+ /** (Business) Listas de sanciones (UE, ONU, OFAC). */
45
+ sanctions;
40
46
  /** Atajos: ApiEmpresas.verifyWebhookSignature(...) sin instanciar el cliente. */
41
47
  static verifyWebhookSignature = signature_1.verifyWebhookSignature;
42
48
  static constructWebhookEvent = signature_1.constructWebhookEvent;
@@ -50,6 +56,8 @@ class ApiEmpresas {
50
56
  this.companies = new Companies_1.Companies(this);
51
57
  this.watchlist = new Watchlist_1.Watchlist(this);
52
58
  this.webhooks = new Webhooks_1.Webhooks(this);
59
+ this.tenders = new Tenders_1.Tenders(this);
60
+ this.sanctions = new Sanctions_1.Sanctions(this);
53
61
  }
54
62
  /**
55
63
  * Consumo de tu API Key: consultas del periodo, cupo, saldo de créditos e historial
package/dist/index.d.ts CHANGED
@@ -4,4 +4,6 @@ export * from './types';
4
4
  export { Companies } from './resources/Companies';
5
5
  export { Watchlist } from './resources/Watchlist';
6
6
  export { Webhooks } from './resources/Webhooks';
7
+ export { Tenders } from './resources/Tenders';
8
+ export { Sanctions } from './resources/Sanctions';
7
9
  export { verifyWebhookSignature, constructWebhookEvent } from './webhooks/signature';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.constructWebhookEvent = exports.verifyWebhookSignature = exports.Webhooks = exports.Watchlist = exports.Companies = exports.ApiError = exports.ApiEmpresas = void 0;
17
+ exports.constructWebhookEvent = exports.verifyWebhookSignature = exports.Sanctions = exports.Tenders = exports.Webhooks = exports.Watchlist = exports.Companies = exports.ApiError = exports.ApiEmpresas = void 0;
18
18
  var ApiEmpresas_1 = require("./ApiEmpresas");
19
19
  Object.defineProperty(exports, "ApiEmpresas", { enumerable: true, get: function () { return ApiEmpresas_1.ApiEmpresas; } });
20
20
  var ApiError_1 = require("./errors/ApiError");
@@ -26,6 +26,10 @@ var Watchlist_1 = require("./resources/Watchlist");
26
26
  Object.defineProperty(exports, "Watchlist", { enumerable: true, get: function () { return Watchlist_1.Watchlist; } });
27
27
  var Webhooks_1 = require("./resources/Webhooks");
28
28
  Object.defineProperty(exports, "Webhooks", { enumerable: true, get: function () { return Webhooks_1.Webhooks; } });
29
+ var Tenders_1 = require("./resources/Tenders");
30
+ Object.defineProperty(exports, "Tenders", { enumerable: true, get: function () { return Tenders_1.Tenders; } });
31
+ var Sanctions_1 = require("./resources/Sanctions");
32
+ Object.defineProperty(exports, "Sanctions", { enumerable: true, get: function () { return Sanctions_1.Sanctions; } });
29
33
  var signature_1 = require("./webhooks/signature");
30
34
  Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return signature_1.verifyWebhookSignature; } });
31
35
  Object.defineProperty(exports, "constructWebhookEvent", { enumerable: true, get: function () { return signature_1.constructWebhookEvent; } });
@@ -0,0 +1,13 @@
1
+ import { ApiEmpresas } from '../ApiEmpresas';
2
+ import { SanctionsOptions, SanctionsResult } from '../types';
3
+ /**
4
+ * (Business) Listas de sanciones de la UE, la ONU y OFAC (EE. UU.). 1 consulta por llamada.
5
+ * Cada coincidencia trae su grado (strong o possible): confírmala con la fecha de nacimiento,
6
+ * el país y los documentos antes de decidir.
7
+ */
8
+ export declare class Sanctions {
9
+ private client;
10
+ constructor(client: ApiEmpresas);
11
+ /** Comprueba una empresa (cif, con sus administradores vigentes) o un nombre (name). */
12
+ screen(options: SanctionsOptions): Promise<SanctionsResult>;
13
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sanctions = void 0;
4
+ /**
5
+ * (Business) Listas de sanciones de la UE, la ONU y OFAC (EE. UU.). 1 consulta por llamada.
6
+ * Cada coincidencia trae su grado (strong o possible): confírmala con la fecha de nacimiento,
7
+ * el país y los documentos antes de decidir.
8
+ */
9
+ class Sanctions {
10
+ client;
11
+ constructor(client) {
12
+ this.client = client;
13
+ }
14
+ /** Comprueba una empresa (cif, con sus administradores vigentes) o un nombre (name). */
15
+ async screen(options) {
16
+ if (!options || (!options.cif && !options.name)) {
17
+ throw new Error("Indica 'cif' o 'name'.");
18
+ }
19
+ const params = new URLSearchParams();
20
+ if (options.cif)
21
+ params.set('cif', options.cif);
22
+ if (options.name)
23
+ params.set('name', options.name);
24
+ if (options.type)
25
+ params.set('type', options.type);
26
+ if (options.directors === false)
27
+ params.set('directors', 'false');
28
+ const r = await this.client.request(`/sanctions/screen?${params.toString()}`);
29
+ return r.data;
30
+ }
31
+ }
32
+ exports.Sanctions = Sanctions;
@@ -0,0 +1,15 @@
1
+ import { ApiEmpresas } from '../ApiEmpresas';
2
+ import { TendersOptions, TendersResult } from '../types';
3
+ /**
4
+ * (Business) Licitaciones públicas abiertas: Plataforma de Contratación del Sector Público y
5
+ * plataformas autonómicas agregadas. 1 consulta por llamada. En Free y Pro, ApiError 403
6
+ * PLAN_RESTRICTION con el número de licitaciones y 3 de muestra en raw.upsell_opportunities.
7
+ */
8
+ export declare class Tenders {
9
+ private client;
10
+ constructor(client: ApiEmpresas);
11
+ /** Busca licitaciones. Con cif, las parecidas a los contratos que esa empresa ya ha ganado. */
12
+ list(options?: TendersOptions): Promise<TendersResult>;
13
+ /** Atajo: licitaciones abiertas parecidas a lo que ya ha ganado una empresa. */
14
+ forCompany(cif: string, options?: Omit<TendersOptions, 'cif'>): Promise<TendersResult>;
15
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tenders = void 0;
4
+ /**
5
+ * (Business) Licitaciones públicas abiertas: Plataforma de Contratación del Sector Público y
6
+ * plataformas autonómicas agregadas. 1 consulta por llamada. En Free y Pro, ApiError 403
7
+ * PLAN_RESTRICTION con el número de licitaciones y 3 de muestra en raw.upsell_opportunities.
8
+ */
9
+ class Tenders {
10
+ client;
11
+ constructor(client) {
12
+ this.client = client;
13
+ }
14
+ /** Busca licitaciones. Con cif, las parecidas a los contratos que esa empresa ya ha ganado. */
15
+ async list(options = {}) {
16
+ const params = new URLSearchParams();
17
+ for (const [k, v] of Object.entries(options)) {
18
+ if (v === undefined || v === null || v === '')
19
+ continue;
20
+ params.set(k, Array.isArray(v) ? v.join(',') : String(v));
21
+ }
22
+ const qs = params.toString();
23
+ const r = await this.client.request(`/tenders${qs ? '?' + qs : ''}`);
24
+ return { ...r.data, meta: r.meta };
25
+ }
26
+ /** Atajo: licitaciones abiertas parecidas a lo que ya ha ganado una empresa. */
27
+ async forCompany(cif, options = {}) {
28
+ return this.list({ ...options, cif });
29
+ }
30
+ }
31
+ exports.Tenders = Tenders;
package/dist/types.d.ts CHANGED
@@ -168,6 +168,17 @@ export interface VerifyResult {
168
168
  accounts?: {
169
169
  last_accounts_year: number | null;
170
170
  };
171
+ /** Solo en Business: listas de sanciones (UE, ONU, OFAC) de la empresa y sus administradores. */
172
+ sanctions?: {
173
+ result: SanctionsResultCode;
174
+ strong_matches: number;
175
+ possible_matches: number;
176
+ directors_checked: number;
177
+ company_matches: SanctionMatch[];
178
+ director_matches: SanctionDirectorMatches[];
179
+ /** Fecha de cada lista cargada: { EU: '2026-10-15', UN: ..., OFAC: ... } */
180
+ lists: Record<string, string | null>;
181
+ };
171
182
  };
172
183
  /** Solo en Business. */
173
184
  risk?: {
@@ -445,3 +456,146 @@ export interface UsageData {
445
456
  found: boolean;
446
457
  }>;
447
458
  }
459
+ export interface TendersOptions {
460
+ /** Palabras del título (todas deben aparecer). */
461
+ q?: string;
462
+ /** CPV o su principio; varios en lista o separados por comas ('72,48'). */
463
+ cpv?: string | string[];
464
+ /** Provincia del órgano de contratación (Madrid, Bizkaia, A Coruña...). */
465
+ province?: string;
466
+ type?: 'supplies' | 'services' | 'works';
467
+ /** Código de procedimiento: '1' abierto, '9' abierto simplificado... */
468
+ procedure?: string;
469
+ min_amount?: number;
470
+ max_amount?: number;
471
+ /** AAAA-MM-DD */
472
+ deadline_from?: string;
473
+ deadline_to?: string;
474
+ published_from?: string;
475
+ /** Licitaciones parecidas a los contratos que esta empresa ya ha ganado. */
476
+ cif?: string;
477
+ status?: 'open' | 'prior_notice' | 'all';
478
+ sort?: 'deadline' | 'published' | 'amount' | 'relevance';
479
+ page?: number;
480
+ /** Máximo 100. */
481
+ limit?: number;
482
+ }
483
+ export interface Tender {
484
+ tender_id: string;
485
+ file_number: string | null;
486
+ title: string | null;
487
+ status: 'open' | 'prior_notice' | 'deadline_passed' | 'under_evaluation' | 'awarded' | 'resolved' | 'cancelled' | 'withdrawn' | string;
488
+ contracting_authority: {
489
+ name: string | null;
490
+ nif: string | null;
491
+ city: string | null;
492
+ province: string | null;
493
+ };
494
+ contract_type: 'supplies' | 'services' | 'works' | 'other' | null;
495
+ procedure: string | null;
496
+ procedure_code: string | null;
497
+ amount_excl_vat: number | null;
498
+ amount_incl_vat: number | null;
499
+ estimated_value: number | null;
500
+ currency: 'EUR';
501
+ lots: number | null;
502
+ main_cpv: string | null;
503
+ cpv_codes: string[];
504
+ execution_place: string | null;
505
+ published_date: string | null;
506
+ /** ISO 8601 con desfase horario de Madrid. */
507
+ deadline: string | null;
508
+ /** Días naturales hasta el día del plazo (0 = cierra hoy). */
509
+ days_left: number | null;
510
+ submission_platform: string;
511
+ url: string | null;
512
+ last_updated: string | null;
513
+ /** Solo con cif: parecido con lo que la empresa ya ha ganado. */
514
+ match_score?: number;
515
+ }
516
+ export interface TendersResult {
517
+ /** Solo con cif. */
518
+ company?: {
519
+ cif: string;
520
+ name: string | null;
521
+ contracts_used: number;
522
+ keywords: string[];
523
+ note?: string;
524
+ };
525
+ tenders: Tender[];
526
+ pagination: {
527
+ total: number;
528
+ page: number;
529
+ limit: number;
530
+ total_pages: number;
531
+ has_more: boolean;
532
+ };
533
+ meta: {
534
+ source: string;
535
+ data_updated_at: string | null;
536
+ status_filter: string;
537
+ };
538
+ }
539
+ export type SanctionsResultCode = 'clear' | 'possible_match' | 'match';
540
+ export interface SanctionsOptions {
541
+ /** CIF: la empresa y sus administradores vigentes. */
542
+ cif?: string;
543
+ /** O un nombre suelto (persona o entidad). */
544
+ name?: string;
545
+ /** Con name: 'person', 'entity' o 'any' (por defecto). */
546
+ type?: 'person' | 'entity' | 'any';
547
+ /** Con cif: false para no comprobar los administradores. */
548
+ directors?: boolean;
549
+ }
550
+ export interface SanctionMatch {
551
+ level: 'strong' | 'possible';
552
+ score: number;
553
+ list: 'EU' | 'UN' | 'OFAC' | string;
554
+ matched_name: string;
555
+ listed_name: string;
556
+ entry_type: 'person' | 'entity' | 'vessel' | 'aircraft' | 'other';
557
+ programs: string[];
558
+ listed_on: string | null;
559
+ countries: string[];
560
+ birth_dates: string[];
561
+ identifiers: string[];
562
+ reference: string;
563
+ url: string | null;
564
+ }
565
+ export interface SanctionDirectorMatches {
566
+ name: string;
567
+ position: string | null;
568
+ matches: SanctionMatch[];
569
+ }
570
+ export interface SanctionsList {
571
+ list: string;
572
+ description: string;
573
+ entries: number;
574
+ list_date: string | null;
575
+ loaded_at: string;
576
+ }
577
+ export interface SanctionsResult {
578
+ /** Con name. */
579
+ query?: {
580
+ name: string;
581
+ type: string;
582
+ };
583
+ matches?: SanctionMatch[];
584
+ /** Con cif. */
585
+ company?: {
586
+ cif: string;
587
+ name: string;
588
+ matches: SanctionMatch[];
589
+ };
590
+ directors?: SanctionDirectorMatches[];
591
+ summary: {
592
+ strong_matches: number;
593
+ possible_matches: number;
594
+ result: SanctionsResultCode;
595
+ directors_checked?: number;
596
+ directors_included?: boolean;
597
+ };
598
+ lists: SanctionsList[];
599
+ checked_at: string;
600
+ note: string;
601
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiempresas",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "SDK oficial de APIEmpresas.es para Node.js y TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "files": [