Migration from {httr} to {httr2} completed. {meteospain} 0.3.0 (https://emf-creaf.github.io/meteospain/) is on CRAN.

This update has removed a lot of code dealing with error responses from the APIs, as {httr2} does a really amazing job by default with retries and error managing and reporting.

#rstats #httr2

Access to Spanish Meteorological Stations Services

Access to different Spanish meteorological stations data services and APIs (AEMET, SMC, MG, Meteoclimatic...).

Two days ago I posted my blogpost on making LinkedIn carousels using Gemini and R. | Athanasia Monika Mowinckel

Two days ago I posted my blogpost on making LinkedIn carousels using Gemini and R. And here is a carousel, about making a carousel! :) In this carousel, I walk through how I used R and Google's Gemini API to turn a blog post into a ready-to-post carousel. Here’s a sneak peek at what you'll find inside: - Connecting R to Gemini: I show how to use the httr2 package to talk to the Gemini API and how to use httr2::curl_translate() to convert cURL commands to R code. - Gemini File Upload: Discover a custom R function that handles the multi-step process of uploading a markdown file to the Gemini API. - The Perfect Prompt: Learn how to craft a detailed prompt that instructs Gemini to generate a JSON output with titles, descriptions, and even code examples tailored for a carousel. - From JSON to Quarto: See how I take the structured JSON response and use a custom function to automatically generate a Quarto document, creating a clean format for review. While posting to LinkedIn still requires a manual upload for now, this automated workflow gives you a powerful head start on your content creation. Check out the full carousel to see the code and the final Quarto output example, and the blogpost for all the code! What tools do you use to streamline your content creation process? https://lnkd.in/dPZFf382 #RStats #DataScience #LinkedIn #Automation #GeminiAPI

The nice thing about having a hobby #rstats 📦 you've been working on off and on for literally ten years now is that you get to be in a forever-refactor and it's never done.

Yanked out #httr and replaced it with #httr2 successfully(ish) though, so that's nice.

Finally managed to fully migrate an API-wrapping #rstats 📦 to #httr2 and I like it a lot, particularly for the easy caching.
Only issue is that I'm using a semi-homebrewed device flow which I don't know how to make work on GitHub actions, where providing $PKG_KEY isn't enough to authenticate 🥲

#RStats #Httr2 Love when developers quietly work away on new code and features that aren't glamorous but are great improvements to infrastructure and make whole new categories of apps possible. This kind of code never gets the recognition of more visual things. If you ever want to use a web API from #R try {httr2} 👏

https://fosstodon.org/@Posit/113940558633516728

Posit (@[email protected])

Attached: 1 image We’re chuffed to announce the release of httr2 1.1.0! httr2 (pronounced “hitter2”) is a comprehensive HTTP client that provides a modern, pipeable API for working with web APIs. The headline feature of this release is a better API for streaming responses, where the body is not available immediately but is streamed back over time. This is particularly important for interacting with LLMs, where it’s needed to make chat responses feel snappy. Learn more: https://www.tidyverse.org/blog/2025/01/httr2-1-1-0/ #RStats #AI

Fosstodon

Melissa Van Bussel: “📹 My latest video is all about how to use R to interact with APIs, using the httr2 package. No background knowledge about APIs is necessary ☺️ 🔗Check it out here: https://youtu.be/8tilyqp4bZY?si=9DqhrOfSCbrqUfIt
Uses #OpenAI and #GitLab APIs

@rstats

#rstats #httr2

How to work with APIs using R (httr2 package tutorial)

YouTube
httr2 1.0.0
"httr2 is the second generation of httr: it helps you generate HTTP requests and process the responses, designed with an eye towards modern web APIs and potentially putting your code in a package."
Really handy features for getting remote data and working with APIs in #R #Httr2
https://www.tidyverse.org/blog/2023/11/httr2-1-0-0/
httr2 1.0.0

httr2 is the successor to httr, providing a pipeable interface to generate HTTP requests and handle the responses. It's focussed on the needs of an R user wrapping a modern web API, but is flexible enough to handle just about any HTTP related task.

TIL the @trakt API does not fully conform with RFC 8628, which expects the device token request to have the field "device_code", but the trakt.tv API expects a field named "code".
This is as far as I can tell the one and only reason I can't take the off-the-shelf #httr2 OAuth implementation and probably will have to kajigger the token stuff manually, which I hate 🙃
(Or I just keep my old #httr version which is "good enough" I guess)
#RStats
I thought I'd give #httr2 another go, but I still have no idea how to make an authenticated request to the trakt.tv API.
I still think it can't be *that* hard and I don't think the trakt API is *that* weird, but I have no idea whether it's just me not knowing what I'm doing or #httr2 maybe making assumptions that don't hold for this particular API or... Idunno. I guess I'll just leave my old-but-working #httr code in and call it good enough ¯\_(ツ)_/¯
I wasted so much time on trying to figure out using the #OCLC #API for a Shiny app because of poor documentation in both #httr and the API.
I mean, I did learn stuff in the process, and I knew close to nothing before starting, and I was over the moon once I got an access token back, but no one needs to spend so much time just trying things are random until it works.
Documentation is so important! Document everything!!
Looking forward to testing #httr2, it should really improve things. #RStats