Shoko
Shoko3w ago

What's the correct way to not allow free

What's the correct way to not allow free users $5 from running my actor?
10 Replies
dzomar | Web Scraping
you can block or limit them in your Actor code. Detect if the user is on a free plan Use the APIFY_USER_IS_PAYING env var (or SDK helper) in your Actor
Shoko
ShokoOP3w ago
using the sdk I get an error
Shoko
ShokoOP3w ago
No description
dzomar | Web Scraping
import { Actor } from 'apify'; await Actor.init(); const { userIsPaying } = Actor.getEnv(); // true = paying plan, false = free [User paying env] if (!userIsPaying) { // Block free users completely throw new Error('This Actor is only available for paying Apify users.'); } // …rest of your logic… await Actor.exit();
Migration guide | Platform | Apify Documentation
How to migrate your Actor to limited permissions. Common migration paths, code examples, and common issues.
Shoko
ShokoOP3w ago
do I need to configure the settings of the actor as full permissions or limited permissions? Also is this snippet outdated?
const user = await Actor.apifyClient.user().get();
isPayingUser = user.isPaying || false;
const user = await Actor.apifyClient.user().get();
isPayingUser = user.isPaying || false;
dzomar | Web Scraping
instead of blocking free users entirely, you can still allow them to run the Actor but with limits.
Shoko
ShokoOP3w ago
yes I want to allow them to run the actor with a limited set of filters and if they are paying they can fully use all the filters but I need a proper way to detect free users
dzomar | Web Scraping
You can 100% do that. The proper, supported way to detect free vs paying users is to use Apify’s built-in flag: APIFY_USER_IS_PAYING → accessible via Actor.getEnv(). const { userIsPaying } = Actor.getEnv(); This works even with limited permissions and doesn’t require calling the user API.
Shoko
ShokoOP3w ago
got it, nice is userIsPaying a string or a boolean
dzomar | Web Scraping
userIsPaying is a boolean not a string. You can also create a small dummy Actor to test this before adding it to your main one. That way you can confirm how userIsPaying behaves for free vs paying accounts without publishing or affecting your real product Actor. After you verify the behavior, just move the same logic into your main Actor.

Did you find this page helpful?