So I finally get my ping command working using httr as script below
library(httr)
curl_com = GET("https://api.rosette.com/rest/v1/ping", add_headers(`X-RosetteAPI-Key` = "my api"))
Great stuff but now cos Im stucked at the next bit.
Now I want to call another api to do sentiment analysis
curl -X POST \
-H "X-RosetteAPI-Key: your_api_key" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Cache-Control: no-cache" \
-d '{"content": "Original Ghostbuster Dan Aykroyd, who also co-wrote the 1984 Ghostbusters film, couldn’t be more pleased with the new all-female Ghostbusters cast, telling The Hollywood Reporter, “The Aykroyd family is delighted by this inheritance of the Ghostbusters torch by these most magnificent women in comedy.”" }' \
"https://api.rosette.com/rest/v1/sentiment"
I got error 405 - Method Not Allowed – You tried to access the Rosette API with an invalid method. I dont know how to translate the above curl command using httr can someone please talk me thru step by step?
Hope someone can help please Peddie
Well, while my comment that they have R code to use was correct, it's horribad R code.
You can now just use the rosette
R package to access the full API. Just make sure to put your Rosette API key into ROSETTE_API_KEY
(easiest to just edit ~/.Renviron
).
devtools::install_github("hrbrmstr/rosette")
ros_sentiment("Original Ghostbuster Dan Aykroyd, who also co-wrote the 1984 Ghostbusters film, couldn’t be more pleased with the new all-female Ghostbusters cast, telling The Hollywood Reporter, 'The Aykroyd family is delighted by this inheritance of the Ghostbusters torch by these most magnificent women in comedy.'")
## $document
## $document$label
## [1] "pos"
##
## $document$confidence
## [1] 0.7962072
##
##
## $entities
## type mention normalized count entityId sentiment.label sentiment.confidence
## 1 PERSON Dan Aykroyd Dan Aykroyd 2 Q105221 pos 0.6385089
## 2 ORGANIZATION Hollywood Reporter Hollywood Reporter 1 Q61503 pos 0.5338094
The rest of the API is also there:
rosette_api_key
: Get or set ROSETTE_API_KEY valueros_categories
: Rosette API categorizatioin serviceros_embedding
: Rosette API text embedding serviceros_entities
: Rosette API entity extraction serviceros_info
: Rosette API version inforos_language
: Rosette API language identification serviceros_make_name
: Make a Name objectros_morph
: Rosette API morphological analysis serviceros_name_similarity
: Rosette API version inforos_name_translation
: Rosette API name translation serviceros_ping Rosette
: API availabilityros_relationships
: Rosette API relationship extraction serviceros_sentences
: Rosette API sentence determination serviceros_sentiment
: Rosette API sentiment analysis serviceros_tokens
: Rosette API tokenizatioin serviceIt will be on CRAN a bit later in the month (when I have time to polish it a bit).