Product Sentiment Insights API: Request Bazaarvoice Product Sentiment Insights data in bulk using an HTTP interface.
6. Example using cURL
Contents
Now that you've learned how to use the Product Sentiment Insights API HTTP service you can try it out using cURL.
About cURL
cURL is a command line application for making API requests. It has the advantages of being supported on both Windows, Mac, and Linux/Unix and is highly configurable.
This tutorial will make use of the following curl options.
- -i : Include headers with the output
- -L : Follow redirects
- -H : Set header
- -O : Save response as file. Uses the name of the downloaded file and saves to folder where the command was run
Learn more about cURL at https://curl.haxx.se/docs/tooldocs.html.
Steps
1. Request manifest file list
In this step you will request a manifest file list, which is a list of available manifest files. Refer to step 1 of the walk-through for more information.
curl 'https://stg.api.bazaarvoice.com/psi/v1/data' \ -H 'X-Bazaarvoice-Signature: SIGNATURE' \ -H 'X-Bazaarvoice-Timestamp: TIMESTAMP' \ -H 'X-Bazaarvoice-Passkey: PASSKEY'
2. Request manifest file location
In this step you will use a manifest file path, acquired from the manifest file list, to request the location of a manifest file. The response will be a 302 redirect. Refer to step 2 of the walk-through for more information.
Perform one of these cURL commands:
Perform this request, then use the response in step 3 below.
curl -i 'https://stg.api.bazaarvoice.com/psi/v1/data?path=PATH_FROM_MANIFEST_FILE_LIST' \ -H 'X-Bazaarvoice-Signature: SIGNATURE' \ -H 'X-Bazaarvoice-Timestamp: TIMESTAMP' \ -H 'X-Bazaarvoice-Passkey: PASSKEY'
This will show you what the redirect response looks like. Your application may follow the redirect automatically. If not, you should make another request using the redirect.
This cURL command will also do step 3, following the 302 redirect, automatically. Perform this command, then skip to 4. Request Data File Location below.
curl -L 'https://stg.api.bazaarvoice.com/psi/v1/data?path=PATH_FROM_MANIFEST_FILE_LIST' \ -H 'X-Bazaarvoice-Signature: SIGNATURE' \ -H 'X-Bazaarvoice-Timestamp: TIMESTAMP' \ -H 'X-Bazaarvoice-Passkey: PASSKEY'
3. Follow 302 redirect to manifest file
In this step you will follow the redirect URL from the previous step. Refer to step 3 of the walk-through for more information.
curl 'URL_FROM_STEP_2_RESPONSE'
4. Request data file Location
In this step you will use a data file path, acquired from the manifest file, to request the location of a data file. The response will be a 302 redirect. Refer to step 4 of the walk-through for more information.
Perform one of these cURL commands:
Perform this request, then use the response in step 5 below.
curl -i 'https://stg.api.bazaarvoice.com/psi/v1/data?path=PATH_FROM_MANIFEST_FILE' \ -H 'X-Bazaarvoice-Signature: SIGNATURE' \ -H 'X-Bazaarvoice-Timestamp: TIMESTAMP' \ -H 'X-Bazaarvoice-Passkey: PASSKEY'
This will show you what the redirect response looks like. Your application may follow the redirect automatically.
This cURL command will also do step 5, following the 302 redirect, automatically. Perform this command, then you're done. The file will be saved in the folder where you executed the cURL command.
curl -LO 'https://stg.api.bazaarvoice.com/psi/v1/data?path=PATH_FROM_MANIFEST_FILE' \ -H 'X-Bazaarvoice-Signature: SIGNATURE' \ -H 'X-Bazaarvoice-Timestamp: TIMESTAMP' \ -H 'X-Bazaarvoice-Passkey: PASSKEY'
5. Follow 302 redirect to data file
Finally, you will follow the redirect URL from the previous step. Refer to step 5 of the walk-through for more information.
Perform this command, then you're done. The CGG file will be saved in the folder where you executed the cURL command.
curl -O 'URL_FROM_STEP_4_RESPONSE'
Next steps
Head over to the Reference section to quickly look up technical details as you build your integration.