private LongObjectMap<Map<String, String>> queryWikidata(List<Long> qidsToFetch)
    throws IOException, InterruptedException {
    if (qidsToFetch.isEmpty()) {
      return Hppc.newLongObjectHashMap();
    }
    String qidList = qidsToFetch.stream().map(id -> "wd:Q" + id).collect(Collectors.joining(" "));
    String query = """
      SELECT ?id ?label where {
        VALUES ?id { %s } ?id (owl:sameAs* / rdfs:label) ?label
      }
      """.formatted(qidList).replaceAll("\\s+", " ").trim();

    HttpRequest request = HttpRequest.newBuilder(URI.create("https://query.wikidata.org/bigdata/namespace/wdq/sparql"))
      .timeout(config.httpTimeout())
      .header(USER_AGENT, config.httpUserAgent())
      .header(ACCEPT, "application/sparql-results+json")
      .header(CONTENT_TYPE, "application/sparql-query")
      .POST(HttpRequest.BodyPublishers.ofString(query, StandardCharsets.UTF_8))
      .build();

    LongObjectMap<Map<String, String>> result = null;
    for (int i = 0; i <= config.httpRetries() && result == null; i++) {
      try {
        var response = client.send(request);
        if (response != null) {
          try (var bis = new BufferedInputStream(response)) {
            result = parseResults(bis);
          }
        }
      } catch (IOException e) {
        boolean lastTry = i == config.httpRetries();
        if (!lastTry) {
          LOGGER.warn("sparql query failed, retrying: {}", e.toString());
        } else {
          LOGGER.error("sparql query failed, exhausted retries: {}", e.toString());
          throw e;
        }
        sleep(config.httpRetryWait());
      }
    }

    if (result != null) {
      return result;
    } else {
      throw new IllegalStateException("No response or exception"); // should never happen
    }
  }
Make an HTTP request to wikidata's <a href="https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service">sparql
endpoint</a> to fetch name translations for a set of QIDs.
planetiler-core/src/main/java/com/onthegomap/planetiler/util/Wikidata.java