Collections
...
Collections API
Collections
Create Collection
7 min
create collection create a collection to run up to 15,000 requests (100 when adding requests with include html=true set) on a schedule you can have up to 10,000 collections set up on your asin data api account at any one time collections are created by making an http post to the /collections endpoint post parameters can be either supplied as x www form urlencoded parameters or by post'ing a json object to the /collections endpoint using include html=true in collections when adding requests with include html=true to a collection the maximum number of requests per collection is 100 (rather than 15,000) because including the html within the response makes the collection result sets much larger the limit is in place to ensure result set files are of a manageable size if you have need to run a large number of requests all with include html=true then simply split the requests across multiple 100 request collections example post post /collections let's start with a simple example; we'll create a collection that is set to run every day at 9am and 5pm we'll use the notification email parameter to specify an email address to send notifications to (when the collection completes), the notification as csv parameter to request the collection results be delivered in csv format and the destination ids parameter to request that the result sets generated by running the collection be uploaded to the specified destination id of "abcdefg" $ curl "https //api asindataapi com/collections?api key=demo" \\ d name="my first collection" \\ d enabled=true \\ d schedule type="daily" \\ d priority="normal" \\ d schedule hours="9,17" \\ d destination ids="abcdefg" \\ d notification email="john smith\@example com" \\ d notification as csv=trueconst axios = require('axios'); const body = { name 'my first collection', enabled true, schedule type 'daily', priority 'normal', schedule hours \[9,17], destination ids \[ 'abcdefg' ], notification email 'john smith\@example com', notification as csv true } axios post('https //api asindataapi com/collections?api key=demo', body) then(response => { const apiresponse = response data; console log('collection created ' + json stringify(apiresponse, 0, 2)); }) catch(error => { console log(error); });import requests body = { "name" "my first collection", "enabled" true, "schedule type" "daily", "priority" "normal", "schedule hours" \[9,17], "destination ids" \[ "abcdefg" ], "notification email" "john smith\@example com", "notification as csv" true } api result = requests post('https //api asindataapi com/collections?api key=demo', json=body) api response = api result json() print "collection created ", json dumps(api response)\<?php $body = http build query(\[ "name" => "my first collection", "enabled" => true, "schedule type" => "daily", "priority" => "normal", "schedule hours" => "9,17", "destination ids" => "abcdefg", "notification email" => "john smith\@example com", "notification as csv" => true ]); $ch = curl init('https //api asindataapi com/collections?api key=demo'); curl setopt($ch, curlopt returntransfer, true); curl setopt($ch, curlopt followlocation, true); \# the following options are required if you're using an outdated openssl version \# more details https //www openssl org/blog/blog/2021/09/13/letsencryptrootcertexpire/ curl setopt($ch, curlopt ssl verifyhost, false); curl setopt($ch, curlopt ssl verifypeer, false); curl setopt($ch, curlopt timeout, 180); curl setopt($ch, curlopt customrequest, "post"); curl setopt($ch, curlopt postfields, $body); $json = curl exec($ch); curl close($ch); $api result = json decode($json, true); print r($api result); echo "collection created", php eol; ?> asin data api responds with the following json confirming the collection has been successfully created note the collection id , you'll use the collection id in subsequent calls to update https //docs trajectdata com/asindataapi/collections api/collections/update , delete https //docs trajectdata com/asindataapi/collections api/collections/delete and add requests https //docs trajectdata com/asindataapi/collections api/requests/create to the collection { "request info" { "success" true }, "collection" { "id" "f994420d", "created at" "2020 01 01 00 00 000z", "name" "my first collection", "schedule type" "daily", "priority" "normal", "schedule hours" \[ 9, 17 ], "destination ids" \[ "abcdefg" ], "enabled" true, "status" "idle", "request total count" 0, "request page count" 0, "next result set id" 1, "results count" 0, "notification email" "john smith\@example com", "notification as json" false, "notification as csv" true, "request type" "mixed", "request type locked" false } } scheduling collections collections can be scheduled on a monthly, weekly or daily basis you can also set a collection to be started manually, either via the asin data api dashboard https //app asindataapi com/collections or the start collection api https //docs trajectdata com/asindataapi/collections api/collections/start a collections' schedule is defined by the schedule type parameter the values of schedule type , and other associated parameters are shown below collection schedules are executed in the timezone set up on your profile https //app asindataapi com/profile true falsefalse left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type collection parameters post post /collections the following parameters can be used when creating a collection the api key parameter should be supplied as a querystring parameter on the request url parameters other than api key should be supplied in either x www form urlencoded or json format, in the request body true falsefalse left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type next steps update collections https //docs trajectdata com/asindataapi/collections api/collections/update