Custom Sentiments API - PhotonInsights/photon-public-api GitHub Wiki

API endpoint for custom sentiment

Authentication

Require x-pi-bearer key in the headers, whose value should be set to the long term access token that you have generated

URL

POST /chatbot/api/v1/live/custom-sentiments

Request JSON Data

Parameter Type Description Required Default Example
query str Query to search for   "Tesla"
startDate date start date for sentiment now - 14 "2024-06-20"
endDate date end date for sentiment (inclusive) now "2024-07-04"
customDomains List[str] custom domains for sources ["bbc.co.uk", "cnn.com"]


Example Request

Search For Tesla

    
{"query":"Tesla","startDate": "2024-06-20", "endDate":"2024-07-04", "customDomains": ["bbc.co.uk", "cnn.com"]}
    
  

Response JSON Data

Response JSON when stream is set to false

Parameter Type Description Required Example
data obj Contains all the sentiment data, on the fly as well as historical {...}
data.results list[obj] Contains all on the fly sentiment data [{...}]
data.results[].date str date of search results "2024-07-04"
data.results[].searchResults list[obj] Contains all the sentiment data for articles for a day [{...}]
data.results[].searchResults[].url str source url "https://www.businessinsider.com/elon-musk-problems-twitter-x-tesla-gamble-luck-run-out-2023-12"
data.results[].searchResults[].source str source name "Business Insider"
data.results[].searchResults[].title str article title "Elon Musk's Problems at Twitter"
data.results[].searchResults[].datetime str article date "2023-12-10T11:58:12.399182"
data.results[].searchResults[].icon str source icon "https://encrypted-tbn3.gstatic.com/faviconV2?url=https://www.businessinsider.com&client=STREAM&size=128&type=FAVICON&fallback_opts=TYPE,SIZE,URL"
data.results[].searchResults[].image str article image "https://i.insider.com/657393a80ec98e92f74dd626?width=1200&format=jpeg"
data.results[].searchResults[].article str article summary "Text"
data.results[].searchResults[].position int article search position 1
data.results[].searchResults[].pageType str Type of page scraped "article"
data.results[].searchResults[].snippet str Snippet of scraped article "Today, Apple released Final Cut Pro for iPad 2, transforming iPad into an"
data.results[].searchResults[].sentiments obj Sentiment data {}
data.results[].searchResults[].sentiments.positive float Positive sentiment score 0.2
data.results[].searchResults[].sentiments.negative float Negative sentiment score 0.5
data.results[].searchResults[].sentiments.neutral float Neutral sentiment score 0.1
data.topicSentiment obj All historical sentiment data stored for topics {...}
data.topicSentiment.sentiment obj All historical sentiment data stored for topics {...}
data.topicSentiment.sentiment.sentimentChartData List[obj] Date wise sentiment chart [{...}]
data.topicSentiment.sentiment.sentimentChartData[].topicName str Name of the topic Tesla
data.topicSentiment.sentiment.sentimentChartData[].chartDetails List[obj] Day wise positive negative sentiment [{...}]
data.topicSentiment.sentiment.sentimentChartData[].chartDetails[].date date Date "2024-07-04"
data.topicSentiment.sentiment.sentimentChartData[].chartDetails[].sentiment obj Sentiment Data {}
data.topicSentiment.sentiment.sentimentChartData[].chartDetails[].sentiment.positive float Positive sentiment score 0.05
data.topicSentiment.sentiment.sentimentChartData[].chartDetails[].sentiment.negative float Negative sentiment score 0.05
data.topicSentiment.sentiment.sentimentChartData[].chartDetails[].sentiment.neutral float Neutral sentiment score 0.05
data.topicSentiment.sentiment.sentimentChartData[].sentimentAggregate obj Aggregated Sentiment Scores {...}
data.topicSentiment.sentiment.sentimentChartData[].sentimentAggregate.positive float Aggregated Positive Sentiment Score 0.05
data.topicSentiment.sentiment.sentimentChartData[].sentimentAggregate.negative float Aggregated Negative Sentiment Score 0.043
data.topicSentiment.sentiment.sentimentChartData[].sentimentAggregate.neutral float Aggregated Neutral Sentiment Score 0.001
data.topicSentiment.potentialIndicator obj Potential indicators for historical sentiment {...}
data.topicSentiment.potentialIndicator.potentialPositives obj Positive Potential indicators for historical sentiment {...}
data.topicSentiment.potentialIndicator.potentialPositives[].topicName str Name of topic {...}
data.topicSentiment.potentialIndicator.potentialPositives[].date date Date "2024-07-04"
data.topicSentiment.potentialIndicator.potentialPositives[].summary date Date "2024-07-04"
data.topicSentiment.potentialIndicator.potentialPositives[].sources List[str] List of sources ["Threatpost", "CNET", "The New York Times"]
data.topicSentiment.potentialIndicator.potentialPositives[].highlightIndexes obj Highlighting indexes for sentiment {...}
data.topicSentiment.potentialIndicator.potentialPositives[].highlightIndexes.positive List[List] Highlighting indexes for positive sentiment [[2,10], [21, 42]]
data.topicSentiment.potentialIndicator.potentialPositives[].highlightIndexes.negative List[List] Highlighting indexes for negative sentiment [[2,10], [21, 42]]
data.topicSentiment.potentialIndicator.potentialNegatives obj Negative Potential indicators for historical sentiment Format same as potentialPositives

Example Curl Request

In the below curl replace LongTermAccessToken with the actual token obtained from long term token generation workflow

Search For Tesla

    
curl --location 'https://prod-gateway.photoninsights.com/chatbot/api/v1/live/custom-sentiments' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Sec-Fetch-Site: same-site' \
--header 'Accept-Language: en-IN,en-GB;q=0.9,en;q=0.8' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Origin: https://app.photoninsights.com' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15' \
--header 'Referer: https://app.photoninsights.com/' \
--header 'Connection: keep-alive' \
--header 'Sec-Fetch-Dest: empty' \
--header 'x-pi-request-id: 24fd6f23-6a36-48eb-8564-a266a5a5ec99' \
--header 'x-pi-bearer: LongTermAccessToken' \
--data '{"query":"Tesla","startDate": "2020-06-20", "endDate":"2022-07-04"}'
    
  
⚠️ **GitHub.com Fallback** ⚠️