Connecting to Apify
Using API Key Authentication
To use the Apify API, you need to obtain an API token from your Apify Console. Navigate to the Settings section and generate a new API token.
After setting the following connection properties, you are ready to connect:
- AuthScheme: Set this to APIKey.
- APIKey: Set this to your Apify API token from the Console.
Example connection string:
Profile=C:\profiles\Apify.apip;AuthScheme=APIKey;ProfileSettings="APIKey=apify_api_xxx"
Usage Examples
Actor Management
Get all actors:
SELECT * FROM Actors
INSERT INTO Actors (Name, Title, Description, RestartOnError, IsPublic, IsDeprecated) VALUES ('my-actor', 'My Actor', 'Scrapes web data', false, true, false)
UPDATE Actors SET Name = 'updated-actor', Title = 'Updated Title', Description = 'Updated description', RestartOnError = false, IsPublic = true, IsDeprecated = false WHERE Id = 'actor-id'
DELETE FROM Actors WHERE Id = 'actor-id'
Get specific actor:
SELECT * FROM Actors WHERE Id = 'actor-id'
Actor Task Operations
Get all actor tasks:
SELECT * FROM ActorTasks
INSERT INTO ActorTasks (Name, ActorId, TaskOptions, TaskInputs) VALUES ('my-task', 'actor-id', '{"memory": 512}', '{"url": "https://example.com"}')
UPDATE ActorTasks SET Name = 'updated-task', TaskOptions = '{"memory": 1024}', TaskInputs = '{"url": "https://example.com"}' WHERE Id = 'task-id'
DELETE FROM ActorTasks WHERE Id = 'task-id'
Get specific actor task:
SELECT * FROM ActorTasks WHERE Id = 'your-task-id'
Actor Run Monitoring
Get all actor runs:
SELECT * FROM ActorRuns
Filter runs by status:
SELECT * FROM ActorRuns WHERE Status = 'SUCCEEDED'
Filter runs by status:
SELECT * FROM ActorRuns WHERE ActorId = 'your-actor-id'
Actor Task Runs
Get task runs with status filter:
SELECT * FROM ActorTaskRuns WHERE TaskId = 'your-task-id' AND Status = 'RUNNING'
Actor Builds
Get all actor builds:
SELECT * FROM ActorBuilds WHERE ActorId = 'your-actor-id'
Actor Versions
Get actor versions:
SELECT * FROM ActorVersions WHERE ActorId = 'your-actor-id'
INSERT INTO ActorVersions (ActorId, VersionNumber, SourceType, SourceFiles, BuildTag, ApplyEnvVarsToBuild) VALUES ('actor-id', '0.1', 'SOURCE_FILES', '[{"name": "main.js", "format": "TEXT"}]', 'latest', true)
UPDATE ActorVersions SET SourceType = 'GIT_REPO', BuildTag = 'beta', EnvironmentVariables = '[{"name": "MY_VAR", "value": "my-value"}]', ApplyEnvVarsToBuild = false, SourceFiles = '[{"name": "main.js", "format": "TEXT"}]' WHERE ActorId = 'actor-id' AND VersionNumber = '0.1'
DELETE FROM ActorVersions WHERE ActorId = 'actor-id' AND VersionNumber = '0.1'
Environment Variables
Get environment variables for specific actor version:
SELECT * FROM ActorVersionEnvironmentVariables WHERE ActorId = 'your-actor-id' AND VersionNumber = '1.0'
INSERT INTO ActorVersionEnvironmentVariables (Name, ActorId, VersionNumber, Value, IsSecret) VALUES ('API_KEY', 'actor-id', '0.1', 'my-secret-value', true)
UPDATE ActorVersionEnvironmentVariables SET Value = 'updated-value', IsSecret = false WHERE Name = 'API_KEY' AND ActorId = 'actor-id' AND VersionNumber = '0.1'
DELETE FROM ActorVersionEnvironmentVariables WHERE Name = 'API_KEY' AND ActorId = 'actor-id' AND VersionNumber = '0.1'
Dataset Management
Get all datasets:
SELECT * FROM Datasets
INSERT INTO Datasets (Name) VALUES ('my-dataset')
UPDATE Datasets SET Name = 'updated-dataset' WHERE Id = 'dataset-id'
DELETE FROM Datasets WHERE Id = 'dataset-id'
Get unnamed datasets only:
SELECT * FROM Datasets WHERE IncludeUnNamed = true
Key-Value Store Operations
Get all key-value stores:
SELECT * FROM KeyValueStores
INSERT INTO KeyValueStores (Name) VALUES ('my-store')
UPDATE KeyValueStores SET Name = 'updated-store' WHERE Id = 'store-id'
DELETE FROM KeyValueStores WHERE Id = 'store-id'
Get keys from a specific store:
SELECT * FROM KeyValueStoreKeys WHERE StoreId = 'your-store-id' AND Prefix = 'config'
Request Queue Management
Get all request queues:
SELECT * FROM RequestQueues
INSERT INTO RequestQueues (Name) VALUES ('my-queue')
UPDATE RequestQueues SET Name = 'updated-queue' WHERE Id = 'queue-id'
DELETE FROM RequestQueues WHERE Id = 'queue-id'
Get requests from a queue:
SELECT * FROM Requests WHERE QueueId = 'your-queue-id' AND ClientKey = 'your-client-key'
INSERT INTO Requests (UniqueKey, Url, QueueId, Method, Headers, Payload, NoRetry, UserData) VALUES ('req-key-001', 'https://example.com/page', 'queue-id', 'GET', '{"Accept": "application/json"}', 'request body', false, '{"source": "sitemap"}')
UPDATE Requests SET UniqueKey = 'req-key-001', Url = 'https://example.com/updated', Method = 'POST', Headers = '{"Content-Type": "application/json"}', Payload = 'updated body', NoRetry = false, UserData = '{"source": "manual"}' WHERE Id = 'request-id' AND QueueId = 'queue-id'
DELETE FROM Requests WHERE Id = 'request-id' AND QueueId = 'queue-id'
Request Locks
Get request locks:
SELECT * FROM RequestLocks WHERE QueueId = 'your-queue-id' AND ClientKey = 'your-client-key'
Schedule Management
Get all schedules:
SELECT * FROM Schedules
INSERT INTO Schedules (CronExpression, Name, IsEnabled, IsExclusive, Timezone, Description, Actions) VALUES ('0 * * * *', 'hourly-job', true, false, 'America/New_York', 'Hourly schedule', '[{"type": "ACTOR", "actorId": "actor-id"}]')
UPDATE Schedules SET Name = 'updated-job', CronExpression = '0 */6 * * *', IsEnabled = true, IsExclusive = false, Timezone = 'UTC', Description = 'Updated schedule', Actions = '[{"type": "ACTOR", "actorId": "actor-id"}]' WHERE Id = 'schedule-id'
DELETE FROM Schedules WHERE Id = 'schedule-id'
Get schedule logs:
SELECT * FROM ScheduleLogs WHERE ScheduleId = 'your-schedule-id'
Apify Store
Browse the Apify Store:
SELECT * FROM Store
Search store with filters:
SELECT * FROM Store WHERE Search = 'scraper' AND Category = 'E-commerce'
Filter by username:
SELECT * FROM Store WHERE UserName = 'specific-username' AND SortBy = 'popularity'
User Information
Get current user details:
SELECT * FROM Users
Get user account limits:
SELECT * FROM UserLimits
Get monthly usage statistics:
SELECT * FROM UserMonthlyUsage WHERE Date = '2024-01-01'
Connection Properties
The connection string properties are the various options that can be used to establish a connection. This section provides a complete list of the options you can configure in the connection string for this provider.
| Property | Description |
| APIKey | Specifies the authenticating user's Apify API token. |
| AuthScheme | Identifies the authentication scheme in use. Allowed values are: BASIC, NONE, NTLM, OAUTH, APIKEY, OAUTH_CLIENT, OAUTH_PASSWORD |