Simon Willison’s Weblog

Subscribe
Atom feed for api

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.

# 17th December 2024, 11:50 pm / claude, audio, openai, ai, llms, ai-assisted-programming, tools, generative-ai, api, security, cloudflare

2022

Datasette 1.0a2: Upserts and finely grained permissions

Visit 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.

# 20th May 2010, 5:42 pm / api, api-explorer, guardian, openplatform, recovered

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.

# 20th May 2010, 5:40 pm / api, content, guardian, json, jsonp, openplatform, recovered

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.

# 30th December 2009, 5:37 pm / json, dns, jsonp, api

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.

# 28th November 2009, 11:29 am / django-people, andy-mckay, api, appengine, json, jsonp, django, python

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.

# 15th October 2008, 2:05 pm / api, campaignfinance, new-york-times

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.

# 2nd October 2008, 5:08 pm / twitter, jsonp, projects, natalie-downe, javascript, api, tweetersation

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.

# 12th August 2008, 9:43 am / jsonp, appengine, img2json, adam-burmister, mimetype, exif, json, api

jsontime. Nat and I threw this together this morning—it runs on Google App Engine and exposes Python’s pytz timezone library over JSONP.

# 21st June 2008, 7:07 pm / jsontime, json, javascript, api, projects, python, pytz, appengine

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?

# 26th April 2008, 6:47 pm / mediawiki, wikipedia, api

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.

# 5th March 2008, 7:05 pm / fireeagle, yahoo, location, api

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.

# 19th January 2008, 7:34 am / flickrplaces, flickr, api, geocoding, geo

2007

Google Chart API Revisited. Marty does some more digging.

# 7th December 2007, 11:59 pm / google-charts, api, martyalchin

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.

# 28th September 2007, 9:10 am / csrf, stuart-langridge, crossdomain, json, api, accounts

Freebase developer documentation. The JSON API and particularly the query language are fascinating.

# 3rd September 2007, 2:38 am / json, api, freebase

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.

# 12th July 2007, 5:20 pm / banking, wesabi, rest, api

Washington Post and Facebook. Deryck Hodge on hacking against Facebook API using Django.

# 19th June 2007, 10:33 am / django, deryckhodge, facebook, api, washington-post

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.

# 2nd June 2007, 12:53 am / zonetag, api, yrb, location, cellid, tags, ydn, yahoo

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.

# 29th March 2007, 2:34 pm / api, tailrank, spinn3r

Introducing the Yahoo! Mail Web Service. 101 pages of documentation—this thing is huge!

# 29th March 2007, 2:47 am / yahoo, api, yahoomail, ydn

Highrise Forum: Using the undocumented API. Add .xml to the end of many URLs in Highrise to get an XML representation of that page.

# 19th March 2007, 11:29 pm / highrise, rest, xml, api

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.

# 24th January 2007, 7:54 pm / flickr, api, machinetags, tagging

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.

# 9th January 2007, 11:37 am / csv, dabbledb, chad-fowler, api, plugins

Writing a Jokosher extension. I like the way API calls are made through an API object passed to the extension’s startup function.

# 7th January 2007, 10:25 pm / python, api, jokosher, stuart-langridge

2006

Abusing Amazon images (via) Amazon have an amazingly flexible API for generating and modifying product images.

# 14th December 2006, 7:38 pm / amazon, api

Google’s own cornershop. Google groups has an undocumented API for generating rounded corners.

# 14th December 2006, 7:34 pm / api, google