Optional Param noredirects
We have added support for the optional query parameter noredirects to the Diffbot API. This parameter prevents the Diffbot API from automatically following HTTP redirects for the submitted URL, giving you more control over the extraction process.
Usage
To use this parameter, simply appendnoredirects to your API call URL.
Example Request:
http://api.diffbot.com<YOUR_TOKEN>&url=<ARTICLE_URL>&noredirects
Error Handling When the noredirects parameter is used, the API will not follow a redirect. Instead, if a redirect is required to access the page content, the API will return an HTTP 500 Internal Server Error with a specific JSON response body. The final, redirected URL is not included in the response.
Example Error Response (HTTP 500):
json
{ "errorCode": 500, "error": "This page requires a redirect. Please retry with redirects enabled if this url needs to be extracted." }
Primary Use Cases & Benefits This parameter is most beneficial when using specific extraction APIs, such as the Article API or Product API, rather than the Diffbot Analyze API. Use it to:
- Prevent extractions: for example, use this param to prevent an outdated article or product offer URL from silently redirecting to a general index or homepage when the original content is no longer available. This avoids the undesired extraction of the first item from a list on the index page.
- Control the extraction source: to ensure that the extraction is performed only on the exact URL submitted, giving developers certainty regarding the data source.