smart_toy API

The Type.World service operates its own API, and if you’re a font publisher of sorts who serves their own fonts under the Type.World JSON Protocol, chances are you want to interact with the central Type.World server using the API calls documented here.

verifyCredentials

Verify that a Type.World user account exists and that it is linked to a known app instance. In other words: Verify a valid user.

Parameters:

anonymousTypeWorldUserID

Required

Anonymous Type.World User ID

anonymousAppID

Required

Anonymous App ID

APIKey

Required

Secret API Key for an API Endpoint, to be obtained through the Type.World user account

subscriptionURL

Complete subscription URL (Format C) that the user is trying to access. If this parameter is given, the user must already hold the subscription for the verification to be valid. This conforms with "Security Level 2" of the developer documention.

Return value:

success

This user and app are known and not revoked.

invalid

The combination of anonymousAppID and anonymousTypeWorldUserID is either unkown or known and revoked.

unknownAnonymousTypeWorldUserID

The user identified by unknownAnonymousTypeWorldUserID is unknown.

unknownAPIKey

The secret API Key for this API endpoint is unknown.

emailNotVerified

The user’s email address isn’t verified. A new verification email has been sent.

Python 3 Example:

import json, urllib.request, urllib.parse
response = json.loads(urllib.request.urlopen('https://api.type.world/v1/verifyCredentials', urllib.parse.urlencode( \
{   'APIKey': 'GBuzxMs32CgAIbofFp6c',
    'anonymousAppID': 'ea4723c0-112e-11ea-9348-8c8590145181',
    'anonymousTypeWorldUserID': 'agp0eXBld29yQychELEgRVc2VyGIgPi9o4UJDA'} \
).encode('ascii')).read().decode())
print(response)

Response:

{"response": "success"}

or

{"response": "invalid"}
inviteUserToSubscription

Invite an existing Type.World user (identified by his/her email address) to a subscription link. This is the only secure way to share a subscription between users. The inviter is identified either by a source email address, which must also be a valid Type.World user account and actually hold that subscription, or by a API endpoint secret key, in which case the subscription must originate from that same API endpoint.

Parameters:

targetUserEmail

Required

Email address of target Type.World user

subscriptionURL

Required

Full subscription link including typeworld:// protocol and secret key and all.

sourceUserEmail

Email address of source Type.World user (not required, but either sourceUserEmail or APIKey needs to be present)

APIKey

Secret API Key of inviting API endpoint (not required, but either sourceUserEmail or APIKey needs to be present)

Return value:

success

The request returned successfully

invalidSubscriptionURL

The subscription URL is of invalid format.

invalidSource

The system could not identify a valid source by either sourceUserEmail or APIKey.

unknownTargetEmail

The email of the invited user is unknown.

sourceAndTargetIdentical

The source user and the target user are identical.

unknownSubscriptionForUser

The source user doesn’t hold that subscription.

invalidSourceAPIEndpoint

In case of an API Endpoint being the source of this request, it could not be identified by the APIKey parameter.

invitationsRequireProAccount

Inviting users requires a Pro Plan for the user account.

Python 3 Example:

import json, urllib.request, urllib.parse
response = json.loads(urllib.request.urlopen('https://api.type.world/v1/inviteUserToSubscription', urllib.parse.urlencode( \
{   'APIKey': 'GBuzxMs32CgAIbofFp6c',
    'subscriptionURL': 'typeworld://json+https//awesomefonts.com/typeworldapi/daz4Ub54mut2XDLz6vGx',
    'targetUserEmail': 'johndoe@gmail.com'} \
).encode('ascii')).read().decode())
print(response)

Response:

{"response": "success"}

or

{"response": "invalidSubscriptionURL"}
revokeSubscriptionInvitation

Revoke the invitation to a subscription for a Type.World user (identified by his/her email address). All subsequent invitation by that user to others will also be deleted.

Parameters:

targetUserEmail

Required

Email address of target Type.World user

subscriptionURL

Required

Full subscription link including typeworld:// protocol and secret key and all.

sourceUserEmail

Email address of source Type.World user (not required, but either sourceUserEmail or APIKey needs to be present)

APIKey

Secret API Key of inviting API endpoint (not required, but either sourceUserEmail or APIKey needs to be present)

Return value:

success

The request returned successfully

invalidSubscriptionURL

The subscription URL is of invalid format.

invalidSource

The system could not identify a valid source by either sourceUserEmail or APIKey.

unknownTargetEmail

The email of the invited user is unknown in the system.

unknownSubscription

No matching subscription could be identified to be revoked.

Python 3 Example:

import json, urllib.request, urllib.parse
response = json.loads(urllib.request.urlopen('https://api.type.world/v1/revokeSubscriptionInvitation', urllib.parse.urlencode( \
{   'APIKey': 'GBuzxMs32CgAIbofFp6c',
    'subscriptionURL': 'typeworld://json+https//awesomefonts.com/typeworldapi/daz4Ub54mut2XDLz6vGx',
    'targetUserEmail': 'johndoe@gmail.com'} \
).encode('ascii')).read().decode())
print(response)

Response:

{"response": "success"}

or

{"response": "invalidSubscriptionURL"}
updateSubscription

Announce to all participating users that this particular subscription has changed and fresh data needs to be pulled by the client app from the publisher server.

Using this command is only available to publishers participating in the Pro Publisher Plan, available from your user account at https://type.world/account/developer (after login).

Currently not yet implemented: If you supply the timeStretch parameter, all users of this subscription that are currently online with the app will be notified with a delay chosen randomly within your given time window. This way you can spread your server load according to the number of users of your subscription. However, since the delay is randomized, peaks may still occur.

Parameters:

APIKey

Required

Secret API Key for an API Endpoint, to be obtained through the Type.World user account

subscriptionURL

Required

Full subscription link including typeworld:// protocol and secret key and all.

timeStretch

Number of minutes (0—60) for which client apps will randomly wait to pull updated data from the publisher’s server. (Currently not implemented)

Return value:

success

The request returned successfully

invalidSubscriptionURL

Subscription URL is invalid.

invalidTimeStretchValue

Time stretch value is invalid.

unknownAPIKey

API key in unkown

unknownSubscriptionURL

No subscription under this URL exists.

paidSubscriptionRequired

Please set up your paid publisher subscription at https://type.world/account

Python 3 Example:

import json, urllib.request, urllib.parse
response = json.loads(urllib.request.urlopen('https://api.type.world/v1/updateSubscription', urllib.parse.urlencode( \
{   'APIKey': 'GBuzxMs32CgAIbofFp6c',
    'subscriptionURL': 'typeworld://json+https//awesomefonts.com/typeworldapi/daz4Ub54mut2XDLz6vGx',
    'timeStretch': 5} \
).encode('ascii')).read().decode())
print(response)

Response:

{"response": "success"}

or

{"response": "invalidSubscriptionURL"}