Skip to content

About

Unofficial BCRPData TypeScript SDK generated with Voxgig sdkgen; mini task 1

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

BcrpData SDK

BCRPData Series API client, generated from the OpenAPI spec.

Community-authored minimal description of the official public BCRPData JSON series endpoint.

Learn more about BCRPData Series API at estadisticas.bcrp.gob.pe.

This is an unofficial SDK for the BCRPData Series public API, generated by Voxgig with @voxgig/sdkgen. It is not affiliated with, endorsed by, or sponsored by the upstream API provider.

Learn more about Voxgig SDKs at voxgig.com/sdk.

Features: test — opt-in, inactive until switched on, and configured per client. See the Features section of any SDK README below for what each one does.

Entities, not endpoints

This SDK exposes the API as a small set of semantic entities — Series — that you call directly, instead of assembling URL paths and query strings. Entities are Capitalised to mark them as the primary surface, each with the operations they support (load):

const client = new BcrpDataSDK()
const series = await client.Series().load({ code: "example", end: "example", start: "example" })

Thinking in entities keeps the mental model small — for people and AI agents alike — rather than reasoning about raw HTTP routes and query parameters.

Offline unit testing

Every SDK ships a built-in test mode that swaps the HTTP transport for an in-memory mock, so your unit tests run fully offline — no server, no network, and no credentials:

TypeScript

// The offline mock starts EMPTY — seed it with the records the test needs.
// Shape: { entity: { <entity-name>: { <id>: <record> } } }
const client = BcrpDataSDK.test({
  entity: {
    series: {
      test01: { id: 'test01' },
    },
  },
})
const series = await client.Series().load({ code: 'example_code', end: 'example_end', start: 'example_start' })
// series is the Series entity, populated with mock data
// — call series.data() for the record itself
console.log(series)

Packages

Language Package Install
TypeScript @dreamcoder08/bcrp-data-sdk publish pending — install from source

Quickstart

TypeScript

import { BcrpDataSDK } from '@dreamcoder08/bcrp-data-sdk'

const client = new BcrpDataSDK()

// Load series data (returns a Series)
const series = await client.Series().load()
console.log(series)

See the TypeScript README for the full guide.

Surfaces

Surface Path
SDK (TypeScript) ts/

Entities

The API exposes one entity:

Entity Description API path
Series The Series entity (load). /{code}/json/{start}/{end}

The operations available across these entities are load — see each entity's own list above for exactly which it supports.

Direct and prepare

For endpoints the entity model doesn't cover, use the low-level methods:

  • direct(fetchargs) — build and send an HTTP request in one step.
  • prepare(fetchargs) — build the request without sending it.

Both accept a map with path, method, params, query, headers, and body. See the How-to guides below.

How-to guides

Make a direct API call

When the entity interface does not cover an endpoint, use direct:

TypeScript:

const result = await client.direct({
  path: '/api/resource/{id}',
  method: 'GET',
  params: { id: 'example' },
})
if (result instanceof Error) {
  throw result
}
console.log(result.data)

Advanced

Everyday use only needs the sections above. This explains the internals behind every call — relevant when writing custom features.

Every SDK call runs the same five-stage pipeline:

  1. Point — resolve the API endpoint from the operation definition.
  2. Spec — build the HTTP specification (URL, method, headers, body).
  3. Request — send the HTTP request.
  4. Response — receive and parse the response.
  5. Result — extract the result data for the caller.

A feature hook fires at each stage (e.g. PrePoint, PreSpec, PreRequest), so features can inspect or modify the pipeline without forking the SDK.

Features

Feature Purpose
TestFeature Test transport

Pass custom features via the extend option at construction time.

Customizing this SDK

This repository contains its own generator (.sdk/), so the SDK is customizable without forking any upstream tool:

  • The model (.sdk/model/) declares everything this project owns: package names, versions, active features, per-target settings. It is written in aontu, a JSON-based specification language designed for building ontologies: easy to edit by hand, and files unify rather than override, so small declarations compose into one model. Regeneration re-reads it every time.
  • Templates (.sdk/tm/) and components (.sdk/src/cmp/) are the two layers of generation, copied into this repo: templates are the literal per-language source, components generate the API-shaped parts.
  • Regeneration merges. By default, newly generated content is three-way merged into existing files, so generator updates and local edits usually converge without manual conflict handling. A project can opt for plain overwrite instead.
  • Custom features and entire custom targets arrive through sdkgen packages (voxgig-sdkgen package add), on the same rails as the bundled languages, and voxgig-sdkgen doctor reports any drift from what a resync would write.

How-to: customize and propagate templates. The full story: voxgig.com/sdk/custom.

Per-language documentation

Upstream API

This SDK is generated from the upstream OpenAPI specification. It is an unofficial client and is not affiliated with the API provider.

The OpenAPI spec(s) this SDK was generated from are kept in the .sdk/def/ folder.

Security

Please report security issues to security@voxgig.com. See SECURITY.md. Do not open public issues for suspected vulnerabilities.


Generated from the BCRPData Series API OpenAPI spec by @voxgig/sdkgen.

About

Unofficial BCRPData TypeScript SDK generated with Voxgig sdkgen; mini task 1

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages