Skip to content

Commit a94c0b7

Browse files
committed
chore: copy & paste friendly curl API example
1 parent bc9a6e8 commit a94c0b7

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/pages/api/index.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,18 @@ export default function Api() {
138138
<ClientCodeWrapper>
139139
<CodeBlock title="cURL" language='bash'>
140140
{`# Prepare Actor input
141-
cat > input.json <<'EOF'
142-
{
143-
// Define the input in JSON here
144-
}
145-
EOF
141+
echo '{ "searchStringsArray": ["Apify"] }' > input.json
142+
143+
# Run the Actor and retreive its default dataset id.
144+
curl -X POST -d @input.json -H 'Content-Type: application/json' \\
145+
-s -o >(tee run.json) \\
146+
https://api.apify.com/v2/acts/compass~crawler-google-places/runs?token=<YOUR_API_TOKEN>
146147
147-
# Run the Actor
148-
curl "https://api.apify.com/v2/acts/username~actorname/runs?token=<YOUR_API_TOKEN>" \\
149-
-X POST \\
150-
-d @input.json \\
151-
-H 'Content-Type: application/json'
148+
# Find the defaultDatasetId in the API response
149+
cat run.json | jq -r .data.defaultDatasetId
152150
153-
# Use the defaultDatasetId from response and pass it instead of <DATASET_ID>
154-
curl "https://api.apify.com/v2/datasets/<DATASET_ID>/items?token=<YOUR_API_TOKEN>"`
151+
# And pass it instead of <DATASET_ID>
152+
curl https://api.apify.com/v2/datasets/<DATASET>/items?token=<YOUR_API_TOKEN>`
155153
}
156154
</CodeBlock>
157155
</ClientCodeWrapper>

0 commit comments

Comments
 (0)