API Queries - Fetch
If, when using the Report API function, a report is not generated instantly, you can use the fetch function to check if the report is ready and retrieve the report once it is ready. This function requires additional parameters. Failing to include them will result in an error response.
Additional Parameters
- reportid - ID of the report you wish to retrieve (Required)
- start - The starting offset for results. Default is 0 (Optional)
- num - The number of results to show from the report. Default is 100, maximum is 1,000 (Optional)
- demographics - This will display the hits from the top 10 countries. Default is "0" (disabled). Accepted values are "0" (disabled) and "1" (enabled). (Optional)
- format : Default= xml. Accepted values are 'csv' or 'xml' (Optional)
Note: Make sure to URL encode all values.
Example query and response:
Example query:
https://www.above.com/api.php?username=user&password=pass&api_key=key&mode=fetch&reportid=12345&start=0&num=100
If the requested report is not yet ready, the status "Generating" will be returned. Try again in a few minutes.
Response:
<results> <result reportid="12345" status="Generating" /> </results>
Once the report is ready, it will be returned in CSV format, wrapped in XML.
Response:
<results> Name,Total Hits,Total Uniques,Total Reported,Total Clicks,Total Revenue,Total CTR,Total EPC,Total RPM a-domain123456.com,8,2,3,3,0.73,100.00,0.24,243.33 a-domain123456-2.com,28,2,2,0,0.00,0.00,0.00,0.00 a-domain123456-3.com,156,14,78,1,0.03,1.28,0.03,0.38 a-domain123456-4.com,15,3,2,0,0.00,0.00,0.00,0.00 </results>
If the report is empty or there is no more data, the response will still include the header row:
Response:
<results> Name,Total Hits,Total Uniques,Total Reported,Total Clicks,Total Revenue,Total CTR,Total EPC,Total RPM </results>
Error Responses:
Possible error responses for this function are:
- 411 - Report ID is Missing or Invalid
- General errors, such as 200 - Internal Error or 300 - Username or password invalid.