### Key-Value Store Record POST Example (Python) Source: https://docs.apify.com/api/v2/key-value-store-record-post This example shows how to post a record to a Key-Value store using the Apify Python client. Make sure to install the 'apify-client' package. ```python from apify_client import ApifyClient # Initialize the client client = ApifyClient('YOUR_API_TOKEN') def post_record(): key = 'my-key' value = {'my': 'value'} store_id = 'my-store-id' try: record = client.key_value_store(store_id).set_record(key=key, value=value) print(f'Record posted successfully: {record}') except Exception as e: print(f'Error posting record: {e}') post_record() ``` -------------------------------- ### Key-Value Store Record POST Example Source: https://docs.apify.com/api/v2/key-value-store-record-post This example demonstrates how to post a record to a Key-Value store using the Apify API client. Ensure you have the 'apify-client' package installed. ```javascript const { ApifyClient } = require('apify-client'); // Initialize the client const client = new ApifyClient({ // Use your API token here // If you don't have one, you can get it from https://console.apify.com/account/settings token: 'YOUR_API_TOKEN', }); async function postRecord() { const key = 'my-key'; const value = { my: 'value' }; const storeId = 'my-store-id'; try { const record = await client.keyValueStore(storeId).setRecord({ key, value }); console.log('Record posted successfully:', record); } catch (error) { console.error('Error posting record:', error); } } postRecord(); ``` -------------------------------- ### Putting a Key-Value Pair Source: https://docs.apify.com/api/v2/act-runs-last-key-value-store-put This example demonstrates how to put a simple key-value pair into the store. Ensure you have the necessary authentication and API client setup. ```javascript const ApifyClient = require('apify-client'); // Initialize the client const client = new ApifyClient({ // Use your API token here // You can get it from https://console.apify.com/account/settings token: 'YOUR_API_TOKEN', }); async function putKeyValue() { const key = 'my-key'; const value = 'my-value'; try { const record = await client.keyValueStore('my-store-id').putRecord({ key, value }); console.log('Record put successfully:', record); } catch (err) { console.error('Error putting record:', err); } } putKeyValue(); ``` -------------------------------- ### Get All Key-Value Store Records (Python) Source: https://docs.apify.com/api/v2/key-value-store-keys-get Python example for fetching all records from a key-value store. This operation can be resource-intensive for large stores. ```python from apify_client import ApifyClient def get_all_keys(): client = ApifyClient('YOUR_API_TOKEN') store_id = 'my-store-id' # Get all records from key-value store records = client.key_value_store(store_id).get_records() print(records) get_all_keys() ``` -------------------------------- ### Actor Build Get Response Example Source: https://docs.apify.com/api/v2/actor-build-get This JSON object represents a successful Actor build, including its ID, status, start and end times, metadata, statistics, resource usage, and configuration. ```json { "data": { "id": "HG7ML7M8z78YcAPEB", "actId": "janedoe~my-actor", "userId": "klmdEpoiojmdEMlk3", "startedAt": "2019-11-30T07:34:24.202Z", "finishedAt": "2019-12-12T09:30:12.202Z", "status": "SUCCEEDED", "meta": { "origin": "WEB", "clientIp": "172.234.12.34", "userAgent": "Mozilla/5.0 (iPad)" }, "stats": { "durationMillis": 1000, "runTimeSecs": 45.718, "computeUnits": 0.012699444444444444 }, "options": { "useCache": false, "betaPackages": false, "memoryMbytes": 1024, "diskMbytes": 2048 }, "usage": { "ACTOR_COMPUTE_UNITS": 0.08 }, "usageTotalUsd": 0.02, "usageUsd": { "ACTOR_COMPUTE_UNITS": 0.02 }, "inputSchema": "{\n \"title\": \"Schema for ...\"}", "readme": "# Magic Actor\nThis Actor is magic.", "buildNumber": "0.1.1", "actorDefinition": { "actorSpecification": 1, "name": "example-actor", "version": "1.0", "buildTag": "latest", "environmentVariables": { "DEBUG_MODE": "false" }, "input": { "type": "object", "properties": { "prompt": { "type": "string", "description": "The text prompt to generate completions for." } ``` -------------------------------- ### Example Query Parameters Source: https://docs.apify.com/api/v2/act-runs-last-request-queue-requests-unlock-post Examples of query parameters that can be used to filter the unlock operation by run status and specify a client key. ```string SUCCEEDED ``` ```string client-abc ``` -------------------------------- ### GET Request Example Source: https://docs.apify.com/api/v2/tools-browser-info-get This is a basic GET request to the browser-info endpoint. ```http GET https://api.apify.com/v2/browser-info ``` -------------------------------- ### Actor Example Run Input Example Source: https://docs.apify.com/api/v2/act-get Example of the input format expected for running an actor. ```json { "body": "{ \"helloWorld\": 123 }", "contentType": "application/json; charset=utf-8" } ``` -------------------------------- ### HTTP GET Request Example Source: https://docs.apify.com/api/v2/actor-run-key-value-store-record-get This is an example of an HTTP GET request to retrieve a record from the default key-value store of an Actor run. Replace placeholders with actual values. ```http GET https://api.apify.com/v2/actor-runs/:runId/key-value-store/records/:recordKey ``` -------------------------------- ### Example Query Parameters for Synchronous Actor Run Source: https://docs.apify.com/api/v2/act-run-sync-post Illustrates common query parameters used to configure a synchronous Actor run, such as timeout, memory, and build. ```http outputRecordKey=OUTPUT timeout=60 memory=256 maxItems=1000 maxTotalChargeUsd=5 restartOnError=false build=0.1.234 ``` -------------------------------- ### Get Webhook Dispatch Example Source: https://docs.apify.com/api/v2/webhook-dispatches-get This example demonstrates how to retrieve a specific webhook dispatch using its ID. Ensure you have the correct dispatch ID. ```javascript const ApifyClient = require('apify-client'); async function getWebhookDispatch(dispatchId) { const client = new ApifyClient({ // Use your API token here // You can get it from https://console.apify.com/account/settings token: 'YOUR_API_TOKEN', }); try { const dispatch = await client.webhooks('my-webhook-id').getDispatch(dispatchId); console.log('Retrieved dispatch:', dispatch); return dispatch; } catch (err) { console.error('Error retrieving dispatch:', err); // Handle specific errors, e.g., 404 Not Found if (err.statusCode === 404) { console.error('Webhook dispatch not found.'); } throw err; } } // Replace 'YOUR_DISPATCH_ID' with the actual ID of the webhook dispatch you want to retrieve getWebhookDispatch('YOUR_DISPATCH_ID'); ``` -------------------------------- ### Example Path Parameters Source: https://docs.apify.com/api/v2/act-version-env-var-delete These are examples of the required path parameters for deleting an environment variable. ```text actorId: janedoe~my-actor versionNumber: 0.1 envVarName: MY_ENV_VAR ``` -------------------------------- ### Actor Build Default Get Response Example Source: https://docs.apify.com/api/v2/act-build-default-get This JSON object represents a successful Actor build response. It includes details such as the build ID, Actor ID, user ID, start and finish times, status, metadata, statistics, options, usage, input schema, README content, build number, and the actor definition. ```json { "data": { "id": "HG7ML7M8z78YcAPEB", "actId": "janedoe~my-actor", "userId": "klmdEpoiojmdEMlk3", "startedAt": "2019-11-30T07:34:24.202Z", "finishedAt": "2019-12-12T09:30:12.202Z", "status": "SUCCEEDED", "meta": { "origin": "WEB", "clientIp": "172.234.12.34", "userAgent": "Mozilla/5.0 (iPad)" }, "stats": { "durationMillis": 1000, "runTimeSecs": 45.718, "computeUnits": 0.012699444444444444 }, "options": { "useCache": false, "betaPackages": false, "memoryMbytes": 1024, "diskMbytes": 2048 }, "usage": { "ACTOR_COMPUTE_UNITS": 0.08 }, "usageTotalUsd": 0.02, "usageUsd": { "ACTOR_COMPUTE_UNITS": 0.02 }, "inputSchema": "{\n \"title\": \"Schema for ...\"}", "readme": "# Magic Actor\nThis Actor is magic.", "buildNumber": "0.1.1", "actorDefinition": { "actorSpecification": 1, "name": "example-actor", "version": "1.0", "buildTag": "latest", "environmentVariables": { "DEBUG_MODE": "false" }, "input": { "type": "object", "properties": { "prompt": { "type": "string", "description": "The text prompt to generate completions for." } } } } } } ``` -------------------------------- ### Actor Task Runs POST Request Example Source: https://docs.apify.com/api/v2/actor-task-runs-post This example demonstrates how to initiate a new actor task run using the API. It includes the necessary parameters for specifying the actor, input, and other run configurations. ```bash curl -X POST https://api.apify.com/v2/acts/apify/run-python/runs \ -H "Content-Type: application/json" \ -d '{ \ "actorId": "someActorId", \ "input": { \ "myParam": "myValue" \ }, \ "memory": 2048, \ "maxDurationSecs": 7200 \ }' ``` -------------------------------- ### GET Request Example Source: https://docs.apify.com/api/v2/actor-task-runs-last-key-value-store-record-get This is the base GET request URL for retrieving a record. Replace placeholders with your specific Actor task ID, record key, and optionally include query parameters for filtering or attachment. ```http GET https://api.apify.com/v2/actor-tasks/:actorTaskId/runs/last/key-value-store/records/:recordKey ``` -------------------------------- ### Actor Deployment Key Example Source: https://docs.apify.com/api/v2/act-get Example of a deployment key associated with an actor. ```text ssh-rsa AAAA ... ``` -------------------------------- ### GET /v2/actor-runs Source: https://docs.apify.com/api/v2/actor-runs-get Gets a list of all runs for a user. The response is a list of objects, where each object contains basic information about a single Actor run. Supports pagination, sorting, and filtering by status and start time. ```APIDOC ## GET /v2/actor-runs ### Description Retrieves a list of all Actor runs for a user. The response is a list of objects, where each object contains basic information about a single Actor run. The endpoint supports pagination using the `limit` and `offset` parameters and it will not return more than 1000 array elements. By default, the records are sorted by the `startedAt` field in ascending order. To sort the records in descending order, use `desc=1` parameter. You can also filter runs by `startedAt` and `status` fields. ### Method GET ### Endpoint https://api.apify.com/v2/actor-runs ### Parameters #### Query Parameters - **offset** (double) - Optional - Number of items that should be skipped at the start. The default value is `0`. - **limit** (double) - Optional - Maximum number of items to return. The default value as well as the maximum is `1000`. - **desc** (boolean) - Optional - If `true` or `1` then the objects are sorted by the `startedAt` field in descending order. By default, they are sorted in ascending order. - **status** (string[]) - Optional - Single status or comma-separated list of statuses. Used to filter runs by the specified statuses only. - **startedAfter** (date-time) - Optional - Filter runs that started after the specified date and time (inclusive). The value must be a valid ISO 8601 datetime string (UTC). - **startedBefore** (date-time) - Optional - Filter runs that started before the specified date and time (inclusive). The value must be a valid ISO 8601 datetime string (UTC). ### Response #### Success Response (200) - **items** (object[]) - List of Actor run objects. - ** ↳ nextPageToken** (string) - Token for fetching the next page of results. #### Response Example { "items": [ { "id": "63a5a4b2c3d4e5f6a7b8c9d0", "userId": "U1234567890abcdef", "actId": "aBcDeFgHiJkLmNoP", "status": "SUCCEEDED", "startedAt": "2023-01-01T10:00:00.000Z", "finishedAt": "2023-01-01T10:05:00.000Z", "createdAt": "2023-01-01T10:06:00.000Z", "runInfo": { "buildId": "63a5a4b2c3d4e5f6a7b8c9d0", "defaultKeyValueStoreId": "aBcDeFgHiJkLmNoP", "defaultLogSinkId": "aBcDeFgHiJkLmNoP", "defaultDatasetId": "aBcDeFgHiJkLmNoP", "memoryMbytes": 1024, "cpuTimeSecs": 300, "maxMemoryMbytes": 1024, "maxCpuTimeSecs": 300, "maxDiskMbytes": 1073741824, "diskMbytes": 536870912, "status": "SUCCEEDED", "buildTimestamp": "2023-01-01T09:55:00.000Z" } } ], "nextPageToken": "someToken" } ``` -------------------------------- ### Response Schema Example Source: https://docs.apify.com/api/v2/act-runs-last-log-get An example demonstrating the expected string format of the log output in the response body. ```string 2017-07-14T06:00:49.733Z Application started. 2017-07-14T06:00:49.741Z Input: { test: 123 } 2017-07-14T06:00:49.752Z Some useful debug information follows. ``` -------------------------------- ### GET Request Example Source: https://docs.apify.com/api/v2/act-runs-last-key-value-store-record-get This is the base URL structure for retrieving a record from the last Actor run's default key-value store. ```http GET https://api.apify.com/v2/actors/:actorId/runs/last/key-value-store/records/:recordKey ``` -------------------------------- ### Actor Version Source Files Example Source: https://docs.apify.com/api/v2/act-get Example of the source files array for an actor version. ```json [] ```