Unlock Adds OpenAPI Support and TypeScript Client For Locksmith

Explore all our APIs and play around with the Locksmith client.

By searchableguy on

Locksmith is our backend service. It is used for handling metadata, NFT ticketing, processing payments, Unlock accounts and other features.

Many developers have asked for documentation and tooling to interact with Locksmith to build applications or to automate various tasks such as updating metadata in bulk, adding ticket verifiers, and more. Since it would be unwieldy to handle all of these use cases on our frontend without increasing complexity, we are releasing an OpenAPI spec for our endpoints and a client SDK in unlock-protocol/unlock-js.

Our docs site has been updated to show endpoints relevant to developers with examples and usage.

docs explorer

Here is an example of how you can use the new Locksmith service client. It is fully typed so you will get intellisense for arguments and responses in your editor.

import { LocksmithService } from '@unlock-protocol/unlock-js'

const service = new LocksmithService()

async function main() {
  // Get unlock address balance on each network
  const balanceResponse = await service.balance()
  console.log(balanceResponse)
  // Get keys metadata on goerli.
  const keysResponse = await service.keysMetadata(
    5,
    '0xb77030a7e47a5eb942a4748000125e70be598632',
    '1'
  )
  console.log(keysResponse)
}

main()

Note: It is experimental so expect breaking changes until @unlock-protocol/unlock-js reaches v1.x.

For languages other than JavaScript, you can use our OpenAPI spec and generate a client using the OpenAPI generator.

If you have any feedback or find an outdated OpenAPI spec for any of our public endpoints, please open an issue on Github.