CA
helpful-purple

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

I would like to get this information to be able to create named datasets based on this run id.
3 Replies
HonzaS
HonzaS3y ago
const runId = process.env.APIFY_ACTOR_RUN_ID
const runId = process.env.APIFY_ACTOR_RUN_ID
see other env vars here https://docs.apify.com/actors/development/environment-variables
flat-fuchsia
flat-fuchsia3y ago
@Casper 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
ApifyEnv | API | Apify SDK
Parsed representation of the APIFY_XXX environmental variables. This object is returned by the {@apilink Actor.getEnv} function.
Actor | API | Apify SDK
Actor class serves as an alternative approach to the static helpers exported from the package. It allows to pass configuration that will be used on the instance methods. Environment variables will have precedence over this configuration. See {@apilink Configuration} for details about what can be configured and what are the default values.
helpful-purple
helpful-purpleOP3y ago
Thanks it looks like what I need. I will test it soon

Did you find this page helpful?