1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "endpoint": "https://query.wikidata.org/sparql",
12 "query": "SELECT ?country ?countryLabel ?population WHERE { ?country wdt:P31 wd:Q3624078 . ?country wdt:P1082 ?population . SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\" } } ORDER BY DESC(?population) LIMIT 3",
13 "maxRecords": 3
14};
15
16
17const run = await client.actor("datamule/sparql-query-runner").call(input);
18
19
20console.log('Results from dataset');
21console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
22const { items } = await client.dataset(run.defaultDatasetId).listItems();
23items.forEach((item) => {
24 console.dir(item);
25});
26
27