30 items tagged “api”
2024
OpenAI WebRTC Audio demo. OpenAI announced a bunch of API features today, including a brand new WebRTC API for setting up a two-way audio conversation with their models.
They tweeted this opaque code example:
async function createRealtimeSession(inStream, outEl, token) { const pc = new RTCPeerConnection(); pc.ontrack = e => outEl.srcObject = e.streams[0]; pc.addTrack(inStream.getTracks()[0]); const offer = await pc.createOffer(); await pc.setLocalDescription(offer); const headers = { Authorization:
Bearer ${token}
, 'Content-Type': 'application/sdp' }; const opts = { method: 'POST', body: offer.sdp, headers }; const resp = await fetch('https://api.openai.com/v1/realtime', opts); await pc.setRemoteDescription({ type: 'answer', sdp: await resp.text() }); return pc; }
So I pasted that into Claude and had it build me this interactive demo for trying out the new API.
My demo uses an OpenAI key directly, but the most interesting aspect of the new WebRTC mechanism is its support for ephemeral tokens.
This solves a major problem with their previous realtime API: in order to connect to their endpoint you need to provide an API key, but that meant making that key visible to anyone who uses your application. The only secure way to handle this was to roll a full server-side proxy for their WebSocket API, just so you could hide your API key in your own server. cloudflare/openai-workers-relay is an example implementation of that pattern.
Ephemeral tokens solve that by letting you make a server-side call to request an ephemeral token which will only allow a connection to be initiated to their WebRTC endpoint for the next 60 seconds. The user's browser then starts the connection, which will last for up to 30 minutes.
2022
Datasette 1.0a2: Upserts and finely grained permissions
I’ve released the third alpha of Datasette 1.0. The 1.0a2 release introduces upsert support to the new JSON API and makes some major improvements to the Datasette permissions system.
[... 2,844 words]2017
How do I receive automatic updates from a Facebook group by email?
Facebook’s API does provide a feed of recent posts to a group: https://developers.facebook.com/docs/graph-api/reference/v2.8/group/feed
[... 85 words]2010
OpenPlatform Content API Explorer. The new API explorer for the Guardian’s Content API.
The Guardian’s Open Platform is open for business. The Guardian’s Content API is now out of beta. Of particular interest: you can access basic article metadata (headline, URL and tags) without using an API key at all, and the API supports JSONP—just request format=json and include a callback=foo argument.
WildlifeNearYou talk at £5 app, and being Wired (not Tired)
Two quick updates about WildlifeNearYou. First up, I gave a talk about the site at £5 app, my favourite Brighton evening event which celebrates side projects and the joy of Making Stuff. I talked about the site’s genesis on a fort, crowdsourcing photo ratings, how we use Freebase and DBpedia and how integrating with Flickr’s machine tags gave us a powerful location API for free. Here’s the video of the talk, courtesy of Ian Oszvald:
[... 171 words]2009
jsondns. A JSONP API for making DNS queries, with a nice URL structure.
Djangopeople JSON parser. Awesome—Andy McKay has compensated for the lack of an official DjangoPeople API by creating a JSONP screen scraped API and hosting it on App Engine. As far as I’m concerned this is an officially supported feature—I’ll make sure future site changes don’t break it, and when I do add an API I’ll try to keep it compatible and help Andy set up redirects.
2008
Announcing the New York Times Campaign Finance API (via) The New York Times have released their first data API, exposing campaign finance data from the Federal Election Commission.
Tweetersation. Nat and my latest side project: a JSONP API powered tool to more easily follow conversations between people on Twitter, by combining their tweets in to a single timeline.
IMG-2-JSON (via) I’m not the only person deploying simple JSON-P APIs on App Engine: Adam Burmister’s tool extracts dimension, mimetype and EXIF metadata when provided the URL to an image file.
jsontime. Nat and I threw this together this morning—it runs on Google App Engine and exposes Python’s pytz timezone library over JSONP.
jQuery style chaining with the Django ORM
Django’s ORM is, in my opinion, the unsung gem of the framework. For the subset of SQL that’s used in most web applications it’s very hard to beat. It’s a beautiful piece of API design, and I tip my hat to the people who designed and built it.
[... 820 words]MediaWiki API. Wikipedia’s best kept secret?
Welcome to Fire Eagle! It’s launched! A service and accompanying API for saving your physical location and selectively sharing it with applications that you trust.
Flickr Place IDs. flickr.places.find, flickr.places.resolvePlaceURL and flickr.places.resolvePlaceID combine to provide a really useful, lightweight not-quite-a-geocoder API. It’s a shame you can’t search for places by providing a latitude/longitude point yet.
2007
Google Chart API Revisited. Marty does some more digging.
hasAccount. Stuart proposes a light-weight API for letting any site know if a user has an account (and is signed in) on another service. I wouldn’t want to deploy this without being confident that my CSRF protection was in order.
Freebase developer documentation. The JSON API and particularly the query language are fascinating.
Wesabi: Your bank has a REST API now. Excellent—I’ve been saying for a while now that I’d really love to be able to program my bank account.
Washington Post and Facebook. Deryck Hodge on hacking against Facebook API using Django.
The Zonetag API Goes Public. Awesome new API from YRB—given a cell tower ID can provide both a location and a list of suggested tags, based on data collected by ZoneTag.
Spinn3r Launches Today. An API to the Tailrank blog index, so you can index the blogosphere without having to build your own spider / spam filter.
Introducing the Yahoo! Mail Web Service. 101 pages of documentation—this thing is huge!
Highrise Forum: Using the undocumented API. Add .xml to the end of many URLs in Highrise to get an XML representation of that page.
Flickr Machine Tags. A new feature for API developers that lets them stuff arbritrary namespaced key/value pairs in to tags and query them using the API. Even without range queries, this will enable a ton of exciting new third party developments.
Guide to the Dabble DB Plugin API (via) This is really nice—Dabble POSTs your plugin script a bunch of CSV values, your script returns CSV for the derived fields. Doesn’t seem to state which flavour of CSV though.
Writing a Jokosher extension. I like the way API calls are made through an API object passed to the extension’s startup function.
2006
Abusing Amazon images (via) Amazon have an amazingly flexible API for generating and modifying product images.
Google’s own cornershop. Google groups has an undocumented API for generating rounded corners.