Damus translation service requests are authenticated by nostr notes. This is a simple way to make authenticated requests, no api keys needed.

$ curl -d @<(nostril --sec $jb55sec --content '{"source":"JA","target":"EN","q":"こんにちはwill"}') https://api.damus.io/translate

{"text":"Hi will"}

It also caches translation results: translation_id = sha2(q+source+target)

So they can be looked up again without calling deepl.

This is all open source as well if you want to make your own caching deepl translator:

https://github.com/damus-io/api

Reply to this note

Please Login to reply.

Discussion

Using notes seems like a lot of extra overhead. Why not just do an auth token initially so you only need to sign once.

Otherwise if you're using an extension or something you'll need to manually approve every translation

no extension needed here. This is for damus/native clients

Still signing can be an expensive action

Creating a few notes isn’t going to kill perf

Although sleeping on it, verifying all those sigs might have performance issues when there are lots of requests. One thing I could do is return a token on first use that subsequent requests could use instead 🤔

Will make that optimization later though because im lazy.

Sha2 is quite slow, try Blake3, way faster and safe

i did originally but the libs weren’t working so i decided to do the dumb sha2 thing

Can this same thing be done for videos?

Like if there’s a DVM for translating videos, could this same principle be applied to distribute the dubbed audio in the user’s language?

Video dubbing would be too cost prohibitive otherwise if every user had to pay for each video.