1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "old_urls_csv": `url,importance
12https://old.example/a,critical
13https://old.example/c,low`,
14 "redirects_csv": `source_url,target_url,status_code
15https://old.example/a,https://new.example/b,301
16https://new.example/b,https://old.example/a,301`,
17 "destinations_csv": `url,status_code
18https://new.example/b,200
19https://old.example/a,200`,
20 "policy_json": `{
21 "schema_version": "redirect-migration-policy@1",
22 "allowed_source_hosts": [
23 "old.example",
24 "new.example"
25 ],
26 "allowed_target_hosts": [
27 "new.example",
28 "old.example"
29 ],
30 "required_importance_values": [
31 "critical",
32 "high"
33 ],
34 "accepted_redirect_codes": [
35 "301",
36 "302",
37 "307",
38 "308"
39 ],
40 "maximum_hops": 5,
41 "prefer_permanent_redirects": true
42}`
43};
44
45
46const run = await client.actor("biztoolsus/redirect-migration-map-preflight").call(input);
47
48
49console.log('Results from dataset');
50console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
51const { items } = await client.dataset(run.defaultDatasetId).listItems();
52items.forEach((item) => {
53 console.dir(item);
54});
55
56