Skip to content

Conversation

@netmilk
Copy link
Contributor

@netmilk netmilk commented Nov 27, 2024

image
  • the commands are restructured in a way that the editable part is always at the end of the snippet (especially annoying in multi-line snippets)
  • added the saving of the response of the Run to a run.json
  • added convenience jq command to find the dataset in the Actor run response
  • removed (imo) unnecessary quotes
  • squished the per command line breaks to save lines

Please, try it yourself before merging:

# Prepare Actor input
echo '{ "searchStringsArray": ["Apify"] }' > input.json

# Run the Actor and retreive its default dataset id.
curl -X POST -d @input.json -H 'Content-Type: application/json' \
  -s -o >(tee run.json) \
  https://api.apify.com/v2/acts/compass~crawler-google-places/runs?token=<YOUR_API_TOKEN>

# Find the defaultDatasetId in the API response 
cat run.json | jq -r .data.defaultDatasetId

# And pass it instead of <DATASET_ID>
curl https://api.apify.com/v2/datasets/<DATASET>/items?token=<YOUR_API_TOKEN>

@jancurn
Copy link
Member

jancurn commented Nov 27, 2024

Thanks for looking into it.

  • Please can we make the code not depending on manually-entered <DATASET_ID> ? Basically so that you can run it and and see results right away
  • I'd consider using an Actor that is not PPR, e.g. Website Content Crawler

@netmilk
Copy link
Contributor Author

netmilk commented Nov 27, 2024

Please can we make the code not depending on manually-entered <DATASET_ID> ? Basically so that you can run it and and see results right away

Sure, we can do that, but I would consider the learning and communication value of the code example on the Docs API landing page. I thought about having the API key exported at the very top and the dataset ID extracted with jq into another constant, but it seemed harder to read compared to having the reader manually replace the placeholders and understand what they’re doing.

If we want a super simple one-liner curl example to demo Apify (API), I'd consider adding a convenience API endpoint that:

  • calls the actor
  • waits for its start
  • it streams the default dataset content.

(if that's even possible)

@jancurn
Copy link
Member

jancurn commented Nov 27, 2024

Yeah, cool, we have an API endpoint for that

@netmilk netmilk force-pushed the chore/netmilk/copy-paste-curl branch from a94c0b7 to 479c0af Compare January 20, 2025 13:34
@netmilk
Copy link
Contributor Author

netmilk commented Jan 20, 2025

@jancurn What about now? :) The Actor is "pay per usage" if I'm not mistaken, so it should work out of the box.

image

@jancurn
Copy link
Member

jancurn commented Jan 20, 2025

@netmilk looks good cheers

@netmilk netmilk merged commit fd3a98d into master Jan 20, 2025
7 checks passed
@netmilk netmilk deleted the chore/netmilk/copy-paste-curl branch January 20, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants