Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.44 KB

File metadata and controls

45 lines (33 loc) · 1.44 KB

bpstat (Java)

Unofficial client for the BPstat API (Banco de Portugal statistics). Part of bpstat-pt.

<dependency>
  <groupId>io.github.marcelogdomingues</groupId>
  <artifactId>bpstat</artifactId>
  <version>0.1.0</version>
</dependency>

Usage

import io.github.marcelogdomingues.bpstat.BpstatClient;
import io.github.marcelogdomingues.bpstat.model.*;
import java.util.List;

BpstatClient bp = BpstatClient.builder().build(); // or .lang("PT")

List<Domain> domains = bp.domains();
SeriesPage page = bp.seriesByDomain(domains.get(0).id, 1);
List<Observation> obs = bp.observations(List.of(page.data.get(0).id));

Observation latest = obs.get(obs.size() - 1);
System.out.println(latest.referenceDate + " " + latest.numericValue());

API

  • BpstatClient.builder().baseUrl(..).lang(..).timeout(..).httpClient(..).build()
  • domains() / domains(lang)List<Domain>
  • seriesByDomain(domainId, page[, lang])SeriesPage (paginated, links.next)
  • seriesByIds(ids[, lang])SeriesPage
  • observations(seriesIds[, lang])List<Observation>
  • Observation.numericValue() parses the string value; titles are LocalizedText { en, pt }
  • Errors throw BpstatException (with getStatus(), getBody())

Java 17+, Jackson. Unofficial — not affiliated with Banco de Portugal.

License

MIT © Marcelo Domingues · Data © Banco de Portugal (BPstat)