JavaScript SDK
The official @datacommonsorg/client
library wraps the REST API with a typed client. Point it at the Brasil Data Commons base URL
instead of the default datacommons.org.
Install
Section titled “Install”npm install @datacommonsorg/clientpnpm add @datacommonsorg/clientyarn add @datacommonsorg/clientConfigure
Section titled “Configure”The one thing that differs from the upstream docs: set apiRoot to this instance.
import { DataCommonsClient } from "@datacommonsorg/client";
const client = new DataCommonsClient({ apiRoot: "https://brazildatacommons.com.br/core/api",});Fetch observations
Section titled “Fetch observations”const rows = await client.getObservationsPoint({ variables: ["Count_Person"], entities: ["country/BRA"], date: "LATEST",});
console.log(rows);To fetch every state at once, use the relation-expression form:
const rows = await client.getObservationsPointWithin({ parentEntity: "country/BRA", childType: "State", variables: ["Count_Person"], date: "LATEST",});See also
Section titled “See also”- Query observations guide — the raw REST calls this wraps.
- API reference.