npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gpdb-api-client

v1.3.2

Published

Simple wrapper around NameCoach GPDB (General Pronunciation Database) API. It is useful to external developers who wish to add NameCoach services to an application.

Downloads

66

Readme

Gpdb Client

The package is a simple wrapper around NameCoach GPDB (General Pronunciation Database) API. It is useful to external developers who wish to add NameCoach services to an application.

For more information on NameCoach GPDB APi, you can visit documentation page.

Installation

Using npm:

npm i --save gpdb-api-client

Configuration:

Specify all needed values through environment variables:

GPDB_API_URL - api url (e.x. https://gpdb.name-coach.com/api/public/v1)
GPDB_ANALYTICS_API_URL - analytics api url (e.x. https://analytics-api-staging.name-coach.com/api/v1)
GPDB_ACCESS_KEY_ID - access key id for your app
GPDB_SECRET_ACCESS_KEY - secret access key for your app

Or pass it manually:

import { Configuration } from "gpdb-client";

const config = new Configuration({
  accessKeyId: 'access key',
  secretAccessKey: 'secret access key',
  apiUrl: 'https://gpdb.name-coach.com/api/public/v1',
  analyticsApiUrl: 'https://analytics-api-staging.name-coach.com/api/v1'
});

Usage

You need to create a client instance to perform requests. Basic example:

import { Client, TargetTypeSig } from "gpdb-client";
// ... configuration

const client = new Client({ instanceSig: 'example.com', typeSig: 'dns' }, config);
const result = await client.pronunciations.simpleSearch({ target: "Sergey", targetTypeSig: TargetTypeSig.FirstName, targetOwnerSig: "sergey" })

You can find detailed information about all possible parameters and the response format on the documentation page. Links to the specific methods are placed at the end of each paragraph.

All parameters should be in camelCase

API

Pronunciations

Simple search

Quick simple request to get pronunciation for a single target.

import { TargetTypeSig } from "gpdb-client";

const result = await client.pronunciations.simpleSearch({ 
  target: "Sergey", 
  targetTypeSig: TargetTypeSig.FirstName, 
  targetOwnerSig: "sergey" 
});

result
  // { target_result: { ... }, meta: { ... } }

Simple search documentation

Complex search

Perform a search in GPDB given between 1 and 10 search targets.

import { TargetTypeSig } from "gpdb-client";

const result =  await client.pronunciations.complexSearch({
  targets: [
    { target: "jack", targetTypeSig: TargetTypeSig.FirstName, targetOwnerContext: { signature: 'uuid' } },
    { target: "pavel", targetTypeSig: TargetTypeSig.FirstName, targetOwnerContext: { signature: 'uuid' } } 
    ],
  userContext: { signature: "uuid" }
});

  result
  // { target_result: { ... }, meta: { ... } }

Search by Sig

Perform a search in GPDB by target owner signature.

  const result =  await client.pronunciations.searchBySig({
    targetOwnerContext: { signature: "uuid" },
    userContext: { signature: "uuid" }
  });

  result
  // { target_result: { ... }, meta: { ... } }

TODO add link to docs after release

Create User Response

Create a user response to a pronunciation if your licensing allows it.


const result = await gpdbClient.pronunciations.userResponse({
  recordingId: "some_id",
  userResponse: "save",
  userContext: { signature: "uuid" },
  targetOwnerSig: "targetOwnerSig"
});

result
// {
//   "response_id": "aGPDBResponseSig",
//   "user_sig": "uuid",
//   "name_owner_sig": "targetOwnerSig",
//   "user_response": "save",
//   "created_at": "timestamp"
// }

Create user response documentation

Create Recording

Creating a recording requires target (name), name owner context(not required but advised), user context and application context - required.

import { TargetTypeSig } from "gpdb-client";

const result = await gpdbClient.pronunciations.createRecording({
  target: 'name',
  targetTypeSig: TargetTypeSig.FirstName,
  audioBase64: 'long_base64_string',
  userContext: { signature: 'userSig' },
  nameOwnerContext: { signature: 'nameOwnerSig' },
});

result
// {
//   "id": "ABCDE",
//   "name_text": "name",
//   "audio_url": "https://a.name-coach.audiourl",
// ...
// }

Create recording documentation

Analytics Events

Create analytics events

Create analytics event:

  await client.analyticsEvents.create({
    customerId: "uuid",
    entityId: "uuid",
    entityType: "playback",
    userId: "uuid"
  });

Create analytics events documentation

Permissions

Load

Quick simple request to get resource permissions for current app.

  const result = await client.permissions.load();

Custom Attributes

Retrieve Config

Quick simple request to retrieve custom attributes config.

  const result = await client.customAttributes.retrieveConfig();

Save Values

Post request to save user input for custom attributes.


  const result = await client.customAttributes.saveValues({ 
    userContext: { signature: 'userSig' },
    targetOwnerContext:  { signature: 'nameOwnerSig' }, 
    customAttributesValues: { some_key: 'value', another_key: true }
  });

Preferred recordings

Save

Save preferred recordings with

await.client.preferredRecordings.save({
  firstNameRecordingId: "123456",
  lastNameRecordingId: "789012",
  userContext: { signature: '[email protected]', signatureType: 'email' }
})

Get

Get saved preferred recordings with

await.client.preferredRecordings.get({
  userContext: { signature: '[email protected]', signatureType: 'email' }
})

Delete

Delete saved preferred recordings with

await.client.preferredRecordings.get({
  firstNameRecordingId: "123456",
  lastNameRecordingId: "789012",
  userContext: { signature: '[email protected]', signatureType: 'email' }
})

Custom attributes documentation