Apify Discord Mirror

Updated 5 months ago

How to get the currently running run id inside scraper code?

At a glance

The community member is looking to get information to create named datasets based on a run ID. The comments suggest two ways to obtain the run ID: using the process.env.APIFY_ACTOR_RUN_ID environment variable or the Actor.getEnv() method from the Apify SDK, which provides the actorRunId property. One community member confirms that this information seems to be what the original poster needs and plans to test it soon.

Useful resources
I would like to get this information to be able to create named datasets based on this run id.
H
A
C
3 comments
Plain Text
const runId = process.env.APIFY_ACTOR_RUN_ID

see other env vars here https://docs.apify.com/actors/development/environment-variables
you could also use Actor.getEnv(): https://sdk.apify.com/api/apify/class/Actor#getEnv - then you could use actorRunId property of the returned object: https://sdk.apify.com/api/apify/interface/ApifyEnv#actorRunId
Thanks it looks like what I need. I will test it soon
Add a reply
Sign up and join the conversation on Discord